[Python-modules-commits] [python-coloredlogs] 01/03: New upstream version 7.1

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sat Jul 29 12:19:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository python-coloredlogs.

commit 75974a4335ec498f850853e1772503a04e304940
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Fri Jul 28 18:05:53 2017 +0100

    New upstream version 7.1
---
 LICENSE.txt                               |   20 +
 MANIFEST.in                               |    3 +
 PKG-INFO                                  |  219 ++++++
 README.rst                                |  184 +++++
 coloredlogs.egg-info/PKG-INFO             |  219 ++++++
 coloredlogs.egg-info/SOURCES.txt          |   21 +
 coloredlogs.egg-info/dependency_links.txt |    1 +
 coloredlogs.egg-info/entry_points.txt     |    3 +
 coloredlogs.egg-info/requires.txt         |    7 +
 coloredlogs.egg-info/top_level.txt        |    1 +
 coloredlogs.pth                           |    1 +
 coloredlogs/__init__.py                   | 1121 +++++++++++++++++++++++++++++
 coloredlogs/cli.py                        |  102 +++
 coloredlogs/converter.py                  |  258 +++++++
 coloredlogs/demo.py                       |   47 ++
 coloredlogs/syslog.py                     |  237 ++++++
 coloredlogs/tests.py                      |  478 ++++++++++++
 requirements-checks.txt                   |    4 +
 requirements-tests.txt                    |    6 +
 requirements.txt                          |    1 +
 setup.cfg                                 |    7 +
 setup.py                                  |  164 +++++
 22 files changed, 3104 insertions(+)

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..71c0236
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2017 Peter Odding
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..41b05ab
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include *.rst
+include *.txt
+include coloredlogs.pth
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..83e7707
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,219 @@
+Metadata-Version: 1.1
+Name: coloredlogs
+Version: 7.1
+Summary: Colored terminal output for Python's logging module
+Home-page: https://coloredlogs.readthedocs.io
+Author: Peter Odding
+Author-email: peter at peterodding.com
+License: UNKNOWN
+Description: coloredlogs: Colored terminal output for Python's logging module
+        ================================================================
+        
+        .. image:: https://travis-ci.org/xolox/python-coloredlogs.svg?branch=master
+           :target: https://travis-ci.org/xolox/python-coloredlogs
+        
+        .. image:: https://coveralls.io/repos/xolox/python-coloredlogs/badge.png?branch=master
+           :target: https://coveralls.io/r/xolox/python-coloredlogs?branch=master
+        
+        The `coloredlogs` package enables colored terminal output for Python's logging_
+        module. The ColoredFormatter_ class inherits from `logging.Formatter`_ and uses
+        `ANSI escape sequences`_ to render your logging messages in color. It uses only
+        standard colors so it should work on any UNIX terminal. It's currently tested
+        on Python 2.6, 2.7, 3.4, 3.5, 3.6 and PyPy. On Windows `coloredlogs`
+        automatically pulls in Colorama_ as a dependency and enables ANSI escape
+        sequence translation using Colorama. Here is a screen shot of the demo that is
+        printed when the command ``coloredlogs --demo`` is executed:
+        
+        .. image:: https://peterodding.com/code/python/coloredlogs/screenshots/terminal.png
+        
+        Note that the screenshot above includes the custom logging level `VERBOSE`
+        defined by my verboselogs_ package: if you install both `coloredlogs` and
+        `verboselogs` it will Just Work (`verboselogs` is of course not required to use
+        `coloredlogs`).
+        
+        .. contents::
+           :local:
+        
+        Format of log messages
+        ----------------------
+        
+        The ColoredFormatter_ class supports user defined log formats so you can use
+        any log format you like. The default log format is as follows::
+        
+         %(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s
+        
+        This log format results in the following output::
+        
+         2015-10-23 03:32:22 peter-macbook coloredlogs.demo[30462] DEBUG message with level 'debug'
+         2015-10-23 03:32:23 peter-macbook coloredlogs.demo[30462] VERBOSE message with level 'verbose'
+         2015-10-23 03:32:24 peter-macbook coloredlogs.demo[30462] INFO message with level 'info'
+         ...
+        
+        You can customize the log format and styling using environment variables as
+        well as programmatically, please refer to the `online documentation`_ for
+        details.
+        
+        Enabling millisecond precision
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        If you're switching from `logging.basicConfig()`_ to `coloredlogs.install()`_
+        you may notice that timestamps no longer include milliseconds. This is because
+        coloredlogs doesn't output milliseconds in timestamps unless you explicitly
+        tell it to. There are two ways to do that:
+        
+        1. The easy way is to pass the `milliseconds` argument to
+           `coloredlogs.install()`_::
+        
+            coloredlogs.install(milliseconds=True)
+        
+        2. Alternatively you can change the log format `to include 'msecs'`_::
+        
+            %(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s
+        
+           Here's what the call to `coloredlogs.install()`_ would then look like::
+        
+            coloredlogs.install(fmt='%(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s')
+        
+           Customizing the log format also enables you to change the delimiter that
+           separates seconds from milliseconds (the comma above).
+        
+        Usage
+        -----
+        
+        Here's an example of how easy it is to get started:
+        
+        .. code-block:: python
+        
+           import coloredlogs, logging
+        
+           # Create a logger object.
+           logger = logging.getLogger('your-module')
+        
+           # By default the install() function installs a handler on the root logger,
+           # this means that log messages from your code and log messages from the
+           # libraries that you use will all show up on the terminal.
+           coloredlogs.install(level='DEBUG')
+        
+           # If you don't want to see log messages from libraries, you can pass a
+           # specific logger object to the install() function. In this case only log
+           # messages originating from that logger will show up on the terminal.
+           coloredlogs.install(level='DEBUG', logger=logger)
+        
+           # Some examples.
+           logger.debug("this is a debugging message")
+           logger.info("this is an informational message")
+           logger.warn("this is a warning message")
+           logger.error("this is an error message")
+           logger.critical("this is a critical message")
+        
+        Colored output from cron
+        ------------------------
+        
+        When `coloredlogs` is used in a cron_ job, the output that's e-mailed to you by
+        cron won't contain any ANSI escape sequences because `coloredlogs` realizes
+        that it's not attached to an interactive terminal. If you'd like to have colors
+        e-mailed to you by cron there are two ways to make it happen:
+        
+        .. contents::
+           :local:
+        
+        You can use this feature without using `coloredlogs` in your Python modules,
+        but please note that only normal text, bold text and text with one of the
+        foreground colors black, red, green, yellow, blue, magenta, cyan and white
+        (these are the portable ANSI color codes) are supported.
+        
+        Modifying your crontab
+        ~~~~~~~~~~~~~~~~~~~~~~
+        
+        Here's an example of a minimal crontab::
+        
+            MAILTO="your-email-address at here"
+            CONTENT_TYPE="text/html"
+            * * * * * root coloredlogs --to-html your-command
+        
+        The ``coloredlogs`` program is installed when you install the `coloredlogs`
+        Python package. When you execute ``coloredlogs --to-html your-command`` it runs
+        ``your-command`` under the external program ``script`` (you need to have this
+        installed). This makes ``your-command`` think that it's attached to an
+        interactive terminal which means it will output ANSI escape sequences which
+        will then be converted to HTML by the ``coloredlogs`` program. Yes, this is a
+        bit convoluted, but it works great :-)
+        
+        Modifying your Python code
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        The ColoredCronMailer_ class provides a context manager that automatically
+        enables HTML output when the ``$CONTENT_TYPE`` variable has been correctly set
+        in the crontab.
+        
+        This requires my capturer_ package which you can install using ``pip install
+        'coloredlogs[cron]'``. The ``[cron]`` extra will pull in capturer_ 2.4 or newer
+        which is required to capture the output while silencing it - otherwise you'd
+        get duplicate output in the emails sent by ``cron``.
+        
+        The context manager can also be used to retroactively silence output that has
+        already been produced, this can be useful to avoid spammy cron jobs that have
+        nothing useful to do but still email their output to the system administrator
+        every few minutes :-).
+        
+        Contact
+        -------
+        
+        The latest version of `coloredlogs` is available on PyPI_ and GitHub_. The
+        `online documentation`_ is available on Read The Docs. For bug reports please
+        create an issue on GitHub_. If you have questions, suggestions, etc. feel free
+        to send me an e-mail at `peter at peterodding.com`_.
+        
+        License
+        -------
+        
+        This software is licensed under the `MIT license`_.
+        
+        © 2017 Peter Odding.
+        
+        
+        .. External references:
+        .. _ANSI escape sequences: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+        .. _capturer: https://pypi.python.org/pypi/capturer
+        .. _Colorama: https://pypi.python.org/pypi/colorama
+        .. _ColoredCronMailer: https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.converter.ColoredCronMailer
+        .. _ColoredFormatter: https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.ColoredFormatter
+        .. _coloredlogs.install(): https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.install
+        .. _cron: https://en.wikipedia.org/wiki/Cron
+        .. _GitHub: https://github.com/xolox/python-coloredlogs
+        .. _logging.basicConfig(): https://docs.python.org/2/library/logging.html#logging.basicConfig
+        .. _logging.Formatter: https://docs.python.org/2/library/logging.html#logging.Formatter
+        .. _logging: https://docs.python.org/2/library/logging.html
+        .. _MIT license: https://en.wikipedia.org/wiki/MIT_License
+        .. _online documentation: https://coloredlogs.readthedocs.io/
+        .. _peter at peterodding.com: peter at peterodding.com
+        .. _PyPI: https://pypi.python.org/pypi/coloredlogs
+        .. _to include 'msecs': https://stackoverflow.com/questions/6290739/python-logging-use-milliseconds-in-time-format
+        .. _verboselogs: https://pypi.python.org/pypi/verboselogs
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: Information Technology
+Classifier: Intended Audience :: System Administrators
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: Unix
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Software Development :: User Interfaces
+Classifier: Topic :: System
+Classifier: Topic :: System :: Console Fonts
+Classifier: Topic :: System :: Logging
+Classifier: Topic :: System :: Systems Administration
+Classifier: Topic :: Terminals
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..5edbb38
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,184 @@
+coloredlogs: Colored terminal output for Python's logging module
+================================================================
+
+.. image:: https://travis-ci.org/xolox/python-coloredlogs.svg?branch=master
+   :target: https://travis-ci.org/xolox/python-coloredlogs
+
+.. image:: https://coveralls.io/repos/xolox/python-coloredlogs/badge.png?branch=master
+   :target: https://coveralls.io/r/xolox/python-coloredlogs?branch=master
+
+The `coloredlogs` package enables colored terminal output for Python's logging_
+module. The ColoredFormatter_ class inherits from `logging.Formatter`_ and uses
+`ANSI escape sequences`_ to render your logging messages in color. It uses only
+standard colors so it should work on any UNIX terminal. It's currently tested
+on Python 2.6, 2.7, 3.4, 3.5, 3.6 and PyPy. On Windows `coloredlogs`
+automatically pulls in Colorama_ as a dependency and enables ANSI escape
+sequence translation using Colorama. Here is a screen shot of the demo that is
+printed when the command ``coloredlogs --demo`` is executed:
+
+.. image:: https://peterodding.com/code/python/coloredlogs/screenshots/terminal.png
+
+Note that the screenshot above includes the custom logging level `VERBOSE`
+defined by my verboselogs_ package: if you install both `coloredlogs` and
+`verboselogs` it will Just Work (`verboselogs` is of course not required to use
+`coloredlogs`).
+
+.. contents::
+   :local:
+
+Format of log messages
+----------------------
+
+The ColoredFormatter_ class supports user defined log formats so you can use
+any log format you like. The default log format is as follows::
+
+ %(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s
+
+This log format results in the following output::
+
+ 2015-10-23 03:32:22 peter-macbook coloredlogs.demo[30462] DEBUG message with level 'debug'
+ 2015-10-23 03:32:23 peter-macbook coloredlogs.demo[30462] VERBOSE message with level 'verbose'
+ 2015-10-23 03:32:24 peter-macbook coloredlogs.demo[30462] INFO message with level 'info'
+ ...
+
+You can customize the log format and styling using environment variables as
+well as programmatically, please refer to the `online documentation`_ for
+details.
+
+Enabling millisecond precision
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you're switching from `logging.basicConfig()`_ to `coloredlogs.install()`_
+you may notice that timestamps no longer include milliseconds. This is because
+coloredlogs doesn't output milliseconds in timestamps unless you explicitly
+tell it to. There are two ways to do that:
+
+1. The easy way is to pass the `milliseconds` argument to
+   `coloredlogs.install()`_::
+
+    coloredlogs.install(milliseconds=True)
+
+2. Alternatively you can change the log format `to include 'msecs'`_::
+
+    %(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s
+
+   Here's what the call to `coloredlogs.install()`_ would then look like::
+
+    coloredlogs.install(fmt='%(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s')
+
+   Customizing the log format also enables you to change the delimiter that
+   separates seconds from milliseconds (the comma above).
+
+Usage
+-----
+
+Here's an example of how easy it is to get started:
+
+.. code-block:: python
+
+   import coloredlogs, logging
+
+   # Create a logger object.
+   logger = logging.getLogger('your-module')
+
+   # By default the install() function installs a handler on the root logger,
+   # this means that log messages from your code and log messages from the
+   # libraries that you use will all show up on the terminal.
+   coloredlogs.install(level='DEBUG')
+
+   # If you don't want to see log messages from libraries, you can pass a
+   # specific logger object to the install() function. In this case only log
+   # messages originating from that logger will show up on the terminal.
+   coloredlogs.install(level='DEBUG', logger=logger)
+
+   # Some examples.
+   logger.debug("this is a debugging message")
+   logger.info("this is an informational message")
+   logger.warn("this is a warning message")
+   logger.error("this is an error message")
+   logger.critical("this is a critical message")
+
+Colored output from cron
+------------------------
+
+When `coloredlogs` is used in a cron_ job, the output that's e-mailed to you by
+cron won't contain any ANSI escape sequences because `coloredlogs` realizes
+that it's not attached to an interactive terminal. If you'd like to have colors
+e-mailed to you by cron there are two ways to make it happen:
+
+.. contents::
+   :local:
+
+You can use this feature without using `coloredlogs` in your Python modules,
+but please note that only normal text, bold text and text with one of the
+foreground colors black, red, green, yellow, blue, magenta, cyan and white
+(these are the portable ANSI color codes) are supported.
+
+Modifying your crontab
+~~~~~~~~~~~~~~~~~~~~~~
+
+Here's an example of a minimal crontab::
+
+    MAILTO="your-email-address at here"
+    CONTENT_TYPE="text/html"
+    * * * * * root coloredlogs --to-html your-command
+
+The ``coloredlogs`` program is installed when you install the `coloredlogs`
+Python package. When you execute ``coloredlogs --to-html your-command`` it runs
+``your-command`` under the external program ``script`` (you need to have this
+installed). This makes ``your-command`` think that it's attached to an
+interactive terminal which means it will output ANSI escape sequences which
+will then be converted to HTML by the ``coloredlogs`` program. Yes, this is a
+bit convoluted, but it works great :-)
+
+Modifying your Python code
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ColoredCronMailer_ class provides a context manager that automatically
+enables HTML output when the ``$CONTENT_TYPE`` variable has been correctly set
+in the crontab.
+
+This requires my capturer_ package which you can install using ``pip install
+'coloredlogs[cron]'``. The ``[cron]`` extra will pull in capturer_ 2.4 or newer
+which is required to capture the output while silencing it - otherwise you'd
+get duplicate output in the emails sent by ``cron``.
+
+The context manager can also be used to retroactively silence output that has
+already been produced, this can be useful to avoid spammy cron jobs that have
+nothing useful to do but still email their output to the system administrator
+every few minutes :-).
+
+Contact
+-------
+
+The latest version of `coloredlogs` is available on PyPI_ and GitHub_. The
+`online documentation`_ is available on Read The Docs. For bug reports please
+create an issue on GitHub_. If you have questions, suggestions, etc. feel free
+to send me an e-mail at `peter at peterodding.com`_.
+
+License
+-------
+
+This software is licensed under the `MIT license`_.
+
+© 2017 Peter Odding.
+
+
+.. External references:
+.. _ANSI escape sequences: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+.. _capturer: https://pypi.python.org/pypi/capturer
+.. _Colorama: https://pypi.python.org/pypi/colorama
+.. _ColoredCronMailer: https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.converter.ColoredCronMailer
+.. _ColoredFormatter: https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.ColoredFormatter
+.. _coloredlogs.install(): https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.install
+.. _cron: https://en.wikipedia.org/wiki/Cron
+.. _GitHub: https://github.com/xolox/python-coloredlogs
+.. _logging.basicConfig(): https://docs.python.org/2/library/logging.html#logging.basicConfig
+.. _logging.Formatter: https://docs.python.org/2/library/logging.html#logging.Formatter
+.. _logging: https://docs.python.org/2/library/logging.html
+.. _MIT license: https://en.wikipedia.org/wiki/MIT_License
+.. _online documentation: https://coloredlogs.readthedocs.io/
+.. _peter at peterodding.com: peter at peterodding.com
+.. _PyPI: https://pypi.python.org/pypi/coloredlogs
+.. _to include 'msecs': https://stackoverflow.com/questions/6290739/python-logging-use-milliseconds-in-time-format
+.. _verboselogs: https://pypi.python.org/pypi/verboselogs
diff --git a/coloredlogs.egg-info/PKG-INFO b/coloredlogs.egg-info/PKG-INFO
new file mode 100644
index 0000000..83e7707
--- /dev/null
+++ b/coloredlogs.egg-info/PKG-INFO
@@ -0,0 +1,219 @@
+Metadata-Version: 1.1
+Name: coloredlogs
+Version: 7.1
+Summary: Colored terminal output for Python's logging module
+Home-page: https://coloredlogs.readthedocs.io
+Author: Peter Odding
+Author-email: peter at peterodding.com
+License: UNKNOWN
+Description: coloredlogs: Colored terminal output for Python's logging module
+        ================================================================
+        
+        .. image:: https://travis-ci.org/xolox/python-coloredlogs.svg?branch=master
+           :target: https://travis-ci.org/xolox/python-coloredlogs
+        
+        .. image:: https://coveralls.io/repos/xolox/python-coloredlogs/badge.png?branch=master
+           :target: https://coveralls.io/r/xolox/python-coloredlogs?branch=master
+        
+        The `coloredlogs` package enables colored terminal output for Python's logging_
+        module. The ColoredFormatter_ class inherits from `logging.Formatter`_ and uses
+        `ANSI escape sequences`_ to render your logging messages in color. It uses only
+        standard colors so it should work on any UNIX terminal. It's currently tested
+        on Python 2.6, 2.7, 3.4, 3.5, 3.6 and PyPy. On Windows `coloredlogs`
+        automatically pulls in Colorama_ as a dependency and enables ANSI escape
+        sequence translation using Colorama. Here is a screen shot of the demo that is
+        printed when the command ``coloredlogs --demo`` is executed:
+        
+        .. image:: https://peterodding.com/code/python/coloredlogs/screenshots/terminal.png
+        
+        Note that the screenshot above includes the custom logging level `VERBOSE`
+        defined by my verboselogs_ package: if you install both `coloredlogs` and
+        `verboselogs` it will Just Work (`verboselogs` is of course not required to use
+        `coloredlogs`).
+        
+        .. contents::
+           :local:
+        
+        Format of log messages
+        ----------------------
+        
+        The ColoredFormatter_ class supports user defined log formats so you can use
+        any log format you like. The default log format is as follows::
+        
+         %(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s
+        
+        This log format results in the following output::
+        
+         2015-10-23 03:32:22 peter-macbook coloredlogs.demo[30462] DEBUG message with level 'debug'
+         2015-10-23 03:32:23 peter-macbook coloredlogs.demo[30462] VERBOSE message with level 'verbose'
+         2015-10-23 03:32:24 peter-macbook coloredlogs.demo[30462] INFO message with level 'info'
+         ...
+        
+        You can customize the log format and styling using environment variables as
+        well as programmatically, please refer to the `online documentation`_ for
+        details.
+        
+        Enabling millisecond precision
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        If you're switching from `logging.basicConfig()`_ to `coloredlogs.install()`_
+        you may notice that timestamps no longer include milliseconds. This is because
+        coloredlogs doesn't output milliseconds in timestamps unless you explicitly
+        tell it to. There are two ways to do that:
+        
+        1. The easy way is to pass the `milliseconds` argument to
+           `coloredlogs.install()`_::
+        
+            coloredlogs.install(milliseconds=True)
+        
+        2. Alternatively you can change the log format `to include 'msecs'`_::
+        
+            %(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s
+        
+           Here's what the call to `coloredlogs.install()`_ would then look like::
+        
+            coloredlogs.install(fmt='%(asctime)s,%(msecs)03d %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s')
+        
+           Customizing the log format also enables you to change the delimiter that
+           separates seconds from milliseconds (the comma above).
+        
+        Usage
+        -----
+        
+        Here's an example of how easy it is to get started:
+        
+        .. code-block:: python
+        
+           import coloredlogs, logging
+        
+           # Create a logger object.
+           logger = logging.getLogger('your-module')
+        
+           # By default the install() function installs a handler on the root logger,
+           # this means that log messages from your code and log messages from the
+           # libraries that you use will all show up on the terminal.
+           coloredlogs.install(level='DEBUG')
+        
+           # If you don't want to see log messages from libraries, you can pass a
+           # specific logger object to the install() function. In this case only log
+           # messages originating from that logger will show up on the terminal.
+           coloredlogs.install(level='DEBUG', logger=logger)
+        
+           # Some examples.
+           logger.debug("this is a debugging message")
+           logger.info("this is an informational message")
+           logger.warn("this is a warning message")
+           logger.error("this is an error message")
+           logger.critical("this is a critical message")
+        
+        Colored output from cron
+        ------------------------
+        
+        When `coloredlogs` is used in a cron_ job, the output that's e-mailed to you by
+        cron won't contain any ANSI escape sequences because `coloredlogs` realizes
+        that it's not attached to an interactive terminal. If you'd like to have colors
+        e-mailed to you by cron there are two ways to make it happen:
+        
+        .. contents::
+           :local:
+        
+        You can use this feature without using `coloredlogs` in your Python modules,
+        but please note that only normal text, bold text and text with one of the
+        foreground colors black, red, green, yellow, blue, magenta, cyan and white
+        (these are the portable ANSI color codes) are supported.
+        
+        Modifying your crontab
+        ~~~~~~~~~~~~~~~~~~~~~~
+        
+        Here's an example of a minimal crontab::
+        
+            MAILTO="your-email-address at here"
+            CONTENT_TYPE="text/html"
+            * * * * * root coloredlogs --to-html your-command
+        
+        The ``coloredlogs`` program is installed when you install the `coloredlogs`
+        Python package. When you execute ``coloredlogs --to-html your-command`` it runs
+        ``your-command`` under the external program ``script`` (you need to have this
+        installed). This makes ``your-command`` think that it's attached to an
+        interactive terminal which means it will output ANSI escape sequences which
+        will then be converted to HTML by the ``coloredlogs`` program. Yes, this is a
+        bit convoluted, but it works great :-)
+        
+        Modifying your Python code
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        The ColoredCronMailer_ class provides a context manager that automatically
+        enables HTML output when the ``$CONTENT_TYPE`` variable has been correctly set
+        in the crontab.
+        
+        This requires my capturer_ package which you can install using ``pip install
+        'coloredlogs[cron]'``. The ``[cron]`` extra will pull in capturer_ 2.4 or newer
+        which is required to capture the output while silencing it - otherwise you'd
+        get duplicate output in the emails sent by ``cron``.
+        
+        The context manager can also be used to retroactively silence output that has
+        already been produced, this can be useful to avoid spammy cron jobs that have
+        nothing useful to do but still email their output to the system administrator
+        every few minutes :-).
+        
+        Contact
+        -------
+        
+        The latest version of `coloredlogs` is available on PyPI_ and GitHub_. The
+        `online documentation`_ is available on Read The Docs. For bug reports please
+        create an issue on GitHub_. If you have questions, suggestions, etc. feel free
+        to send me an e-mail at `peter at peterodding.com`_.
+        
+        License
+        -------
+        
+        This software is licensed under the `MIT license`_.
+        
+        © 2017 Peter Odding.
+        
+        
+        .. External references:
+        .. _ANSI escape sequences: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+        .. _capturer: https://pypi.python.org/pypi/capturer
+        .. _Colorama: https://pypi.python.org/pypi/colorama
+        .. _ColoredCronMailer: https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.converter.ColoredCronMailer
+        .. _ColoredFormatter: https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.ColoredFormatter
+        .. _coloredlogs.install(): https://coloredlogs.readthedocs.io/en/latest/#coloredlogs.install
+        .. _cron: https://en.wikipedia.org/wiki/Cron
+        .. _GitHub: https://github.com/xolox/python-coloredlogs
+        .. _logging.basicConfig(): https://docs.python.org/2/library/logging.html#logging.basicConfig
+        .. _logging.Formatter: https://docs.python.org/2/library/logging.html#logging.Formatter
+        .. _logging: https://docs.python.org/2/library/logging.html
+        .. _MIT license: https://en.wikipedia.org/wiki/MIT_License
+        .. _online documentation: https://coloredlogs.readthedocs.io/
+        .. _peter at peterodding.com: peter at peterodding.com
+        .. _PyPI: https://pypi.python.org/pypi/coloredlogs
+        .. _to include 'msecs': https://stackoverflow.com/questions/6290739/python-logging-use-milliseconds-in-time-format
+        .. _verboselogs: https://pypi.python.org/pypi/verboselogs
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: Information Technology
+Classifier: Intended Audience :: System Administrators
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: POSIX
+Classifier: Operating System :: Unix
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Software Development :: User Interfaces
+Classifier: Topic :: System
+Classifier: Topic :: System :: Console Fonts
+Classifier: Topic :: System :: Logging
+Classifier: Topic :: System :: Systems Administration
+Classifier: Topic :: Terminals
diff --git a/coloredlogs.egg-info/SOURCES.txt b/coloredlogs.egg-info/SOURCES.txt
new file mode 100644
index 0000000..64eaf0e
--- /dev/null
+++ b/coloredlogs.egg-info/SOURCES.txt
@@ -0,0 +1,21 @@
+LICENSE.txt
+MANIFEST.in
+README.rst
+coloredlogs.pth
+requirements-checks.txt
+requirements-tests.txt
+requirements.txt
+setup.cfg
+setup.py
+coloredlogs/__init__.py
+coloredlogs/cli.py
+coloredlogs/converter.py
+coloredlogs/demo.py
+coloredlogs/syslog.py
+coloredlogs/tests.py
+coloredlogs.egg-info/PKG-INFO
+coloredlogs.egg-info/SOURCES.txt
+coloredlogs.egg-info/dependency_links.txt
+coloredlogs.egg-info/entry_points.txt
+coloredlogs.egg-info/requires.txt
+coloredlogs.egg-info/top_level.txt
\ No newline at end of file
diff --git a/coloredlogs.egg-info/dependency_links.txt b/coloredlogs.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/coloredlogs.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/coloredlogs.egg-info/entry_points.txt b/coloredlogs.egg-info/entry_points.txt
new file mode 100644
index 0000000..564b838
--- /dev/null
+++ b/coloredlogs.egg-info/entry_points.txt
@@ -0,0 +1,3 @@
+[console_scripts]
+coloredlogs = coloredlogs.cli:main
+
diff --git a/coloredlogs.egg-info/requires.txt b/coloredlogs.egg-info/requires.txt
new file mode 100644
index 0000000..df8abd0
--- /dev/null
+++ b/coloredlogs.egg-info/requires.txt
@@ -0,0 +1,7 @@
+humanfriendly>=3.2
+
+[:sys_platform == "win32"]
+colorama
+
+[cron]
+capturer>=2.4
diff --git a/coloredlogs.egg-info/top_level.txt b/coloredlogs.egg-info/top_level.txt
new file mode 100644
index 0000000..4a6c8e5
--- /dev/null
+++ b/coloredlogs.egg-info/top_level.txt
@@ -0,0 +1 @@
+coloredlogs
diff --git a/coloredlogs.pth b/coloredlogs.pth
new file mode 100644
index 0000000..01d69c9
--- /dev/null
+++ b/coloredlogs.pth
@@ -0,0 +1 @@
+import os; exec('try: __import__("coloredlogs").auto_install() if "COLOREDLOGS_AUTO_INSTALL" in os.environ else None\nexcept ImportError: pass')
diff --git a/coloredlogs/__init__.py b/coloredlogs/__init__.py
new file mode 100644
index 0000000..4a7ca6c
--- /dev/null
+++ b/coloredlogs/__init__.py
@@ -0,0 +1,1121 @@
+# Colored terminal output for Python's logging module.
+#
+# Author: Peter Odding <peter at peterodding.com>
+# Last Change: July 15, 2017
+# URL: https://coloredlogs.readthedocs.io
+
+"""
+Colored terminal output for Python's :mod:`logging` module.
+
+.. contents::
+   :local:
+
+Getting started
+===============
+
+The easiest way to get started is by importing :mod:`coloredlogs` and calling
+:mod:`coloredlogs.install()` (similar to :func:`logging.basicConfig()`):
+
+ >>> import coloredlogs, logging
+ >>> coloredlogs.install(level='DEBUG')
+ >>> logger = logging.getLogger('some.module.name')
+ >>> logger.info("this is an informational message")
+ 2015-10-22 19:13:52 peter-macbook some.module.name[28036] INFO this is an informational message
+
+The :mod:`~coloredlogs.install()` function creates a :class:`ColoredFormatter`
+that injects `ANSI escape sequences`_ into the log output.
+
+.. _ANSI escape sequences: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+
+Environment variables
+=====================
+
+The following environment variables can be used to configure the
+:mod:`coloredlogs` module without writing any code:
+
+=============================  ============================  ==================================
+Environment variable           Default value                 Type of value
+=============================  ============================  ==================================
+``$COLOREDLOGS_AUTO_INSTALL``  'false'                       a boolean that controls whether
+                                                             :func:`auto_install()` is called
+``$COLOREDLOGS_LOG_LEVEL``     'INFO'                        a log level name
+``$COLOREDLOGS_LOG_FORMAT``    :data:`DEFAULT_LOG_FORMAT`    a log format string
+``$COLOREDLOGS_DATE_FORMAT``   :data:`DEFAULT_DATE_FORMAT`   a date/time format string
+``$COLOREDLOGS_LEVEL_STYLES``  :data:`DEFAULT_LEVEL_STYLES`  see :func:`parse_encoded_styles()`
+``$COLOREDLOGS_FIELD_STYLES``  :data:`DEFAULT_FIELD_STYLES`  see :func:`parse_encoded_styles()`
+=============================  ============================  ==================================
+
+Examples of customization
+=========================
+
+Here we'll take a look at some examples of how you can customize
+:mod:`coloredlogs` using environment variables.
+
+.. contents::
+   :local:
+
+Changing the log format
+-----------------------
+
+The simplest customization is to change the log format, for example:
+
+.. code-block:: sh
+
+   $ export COLOREDLOGS_LOG_FORMAT='[%(hostname)s] %(asctime)s - %(message)s'
+   $ coloredlogs --demo
+   [peter-macbook] 2015-10-22 23:42:28 - message with level 'debug'
+   [peter-macbook] 2015-10-22 23:42:29 - message with level 'verbose'
+   ...
+
+Here's what that looks like in a terminal (I always work in terminals with a
+black background and white text):
+
+.. image:: images/custom-log-format.png
+   :alt: Screen shot of colored logging with custom log format.
+   :align: center
+   :width: 80%
+
+Changing the date/time format
+-----------------------------
+
+You can also change the date/time format, for example you can remove the date
+part and leave only the time:
+
+.. code-block:: sh
+
+   $ export COLOREDLOGS_LOG_FORMAT='%(asctime)s - %(message)s'
+   $ export COLOREDLOGS_DATE_FORMAT='%H:%M:%S'
+   $ coloredlogs --demo
+   23:45:22 - message with level 'debug'
+   23:45:23 - message with level 'verbose'
+   ...
+
+Here's what it looks like in a terminal:
+
+.. image:: images/custom-datetime-format.png
+   :alt: Screen shot of colored logging with custom date/time format.
+   :align: center
+   :width: 80%
+
+Changing the colors/styles
+--------------------------
+
+Finally you can customize the colors and text styles that are used:
+
+.. code-block:: sh
+
+   $ export COLOREDLOGS_LOG_FORMAT='%(asctime)s - %(message)s'
+   $ export COLOREDLOGS_DATE_FORMAT='%H:%M:%S'
+   $ export COLOREDLOGS_FIELD_STYLES='' # no styles
+   $ export COLOREDLOGS_LEVEL_STYLES='warning=yellow;error=red;critical=red,bold'
+   $ coloredlogs --demo
+   23:45:22 - message with level 'debug'
+   23:45:23 - message with level 'verbose'
+   ...
+
+The difference isn't apparent from the above text but take a look at the
+following screen shot:
+
+.. image:: images/custom-colors.png
+   :alt: Screen shot of colored logging with custom colors.
+   :align: center
+   :width: 80%
+
+.. _notes about log levels:
+
+Some notes about log levels
+===========================
+
+With regards to the handling of log levels, the :mod:`coloredlogs` package
+differs from Python's :mod:`logging` module in two aspects:
+
+1. While the :mod:`logging` module uses the default logging level
+   :data:`logging.WARNING`, the :mod:`coloredlogs` package has always used
+   :data:`logging.INFO` as its default log level.
+
+2. When logging to the terminal or system log is initialized by
+   :func:`install()` or :func:`.enable_system_logging()` the effective
+   level [#]_ of the selected logger [#]_ is compared against the requested
+   level [#]_ and if the effective level is more restrictive than the requested
+   level, the logger's level will be set to the requested level (this happens
+   in :func:`adjust_level()`). The reason for this is to work around a
+   combination of design choices in Python's :mod:`logging` module that can
+   easily confuse people who aren't already intimately familiar with it:
+
+   - All loggers are initialized with the level :data:`logging.NOTSET`.
+
+   - When a logger's level is set to :data:`logging.NOTSET` the
+     :func:`~logging.Logger.getEffectiveLevel()` method will
+     fall back to the level of the parent logger.
+
+   - The parent of all loggers is the root logger and the root logger has its
+     level set to :data:`logging.WARNING` by default (after importing the
+     :mod:`logging` module).
+
+   Effectively all user defined loggers inherit the default log level
+   :data:`logging.WARNING` from the root logger, which isn't very intuitive for
+   those who aren't already familiar with the hierarchical nature of the
+   :mod:`logging` module.
+
+   By avoiding this potentially confusing behavior (see `#14`_, `#18`_, `#21`_,
+   `#23`_ and `#24`_), while at the same time allowing the caller to specify a
+   logger object, my goal and hope is to provide sane defaults that can easily
+   be changed when the need arises.
+
+   .. [#] Refer to :func:`logging.Logger.getEffectiveLevel()` for details.
+   .. [#] The logger that is passed as an argument by the caller or the root
+          logger which is selected as a default when no logger is provided.
+   .. [#] The log level that is passed as an argument by the caller or the
+          default log level :data:`logging.INFO` when no level is provided.
+
+   .. _#14: https://github.com/xolox/python-coloredlogs/issues/14
+   .. _#18: https://github.com/xolox/python-coloredlogs/issues/18
+   .. _#21: https://github.com/xolox/python-coloredlogs/pull/21
+   .. _#23: https://github.com/xolox/python-coloredlogs/pull/23
+   .. _#24: https://github.com/xolox/python-coloredlogs/issues/24
+
+Classes and functions
+=====================
+"""
+
+# Standard library modules.
+import collections
+import logging
+import os
+import re
+import socket
+import sys
+
+# External dependencies.
+from humanfriendly import coerce_boolean
+from humanfriendly.compat import coerce_string, is_string
+from humanfriendly.terminal import ANSI_COLOR_CODES, ansi_wrap, terminal_supports_colors
+from humanfriendly.text import split
+
+# Windows requires special handling and the first step is detecting it :-).
+WINDOWS = sys.platform.startswith('win')
+
+# Optional external dependency (only needed on Windows).
+NEED_COLORAMA = WINDOWS
+
+# Semi-standard module versioning.
+__version__ = '7.1'
+
+DEFAULT_LOG_LEVEL = logging.INFO
+"""The default log level for :mod:`coloredlogs` (:data:`logging.INFO`)."""
+
+DEFAULT_LOG_FORMAT = '%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s'
+"""The default log format for :class:`ColoredFormatter` objects (a string)."""
+
+DEFAULT_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
+"""The default date/time format for :class:`ColoredFormatter` objects (a string)."""
+
+CHROOT_FILES = ['/etc/debian_chroot']
+"""A list of filenames that indicate a chroot and contain the name of the chroot."""
+
+CAN_USE_BOLD_FONT = (not NEED_COLORAMA)
+"""
+Whether bold fonts can be used in default styles (a boolean).
... 2267 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-coloredlogs.git



More information about the Python-modules-commits mailing list