[Python-modules-commits] [python-coloredlogs] 01/02: New upstream version 5.2
Gaurav Juvekar
gauravjuvekar-guest at moszumanska.debian.org
Sun Mar 12 20:19:57 UTC 2017
This is an automated email from the git hooks/post-receive script.
gauravjuvekar-guest pushed a commit to branch upstream
in repository python-coloredlogs.
commit 740605358e91e902af6f1cff6795f64a5468dd3b
Author: Gaurav Juvekar <gauravjuvekar at gmail.com>
Date: Sun Jan 29 20:32:29 2017 +0100
New upstream version 5.2
---
LICENSE.txt | 20 +
MANIFEST.in | 3 +
PKG-INFO | 157 +++++
README.rst | 123 ++++
coloredlogs.egg-info/PKG-INFO | 157 +++++
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 | 4 +
coloredlogs.egg-info/top_level.txt | 1 +
coloredlogs.pth | 1 +
coloredlogs/__init__.py | 934 ++++++++++++++++++++++++++++++
coloredlogs/cli.py | 102 ++++
coloredlogs/converter.py | 149 +++++
coloredlogs/demo.py | 47 ++
coloredlogs/syslog.py | 207 +++++++
coloredlogs/tests.py | 361 ++++++++++++
requirements-checks.txt | 4 +
requirements-tests.txt | 5 +
requirements.txt | 1 +
setup.cfg | 8 +
setup.py | 163 ++++++
22 files changed, 2472 insertions(+)
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..3af15dd
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2015 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..c294cb6
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,157 @@
+Metadata-Version: 1.1
+Name: coloredlogs
+Version: 5.2
+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 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.
+
+ Usage
+ -----
+
+ Here's an example of how easy it is to get started:
+
+ .. code-block:: python
+
+ # Create a logger object.
+ import logging
+ logger = logging.getLogger('your-module')
+
+ # Initialize coloredlogs.
+ import coloredlogs
+ coloredlogs.install(level='DEBUG')
+
+ # 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's a simple way to set it up::
+
+ 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`
+ 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 :-)
+
+ 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.
+
+ 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`_.
+
+ © 2015 Peter Odding.
+
+
+ .. External references:
+ .. _ANSI escape sequences: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+ .. _Colorama: https://pypi.python.org/pypi/colorama
+ .. _ColoredFormatter: http://coloredlogs.readthedocs.io/en/latest/#coloredlogs.ColoredFormatter
+ .. _cron: https://en.wikipedia.org/wiki/Cron
+ .. _GitHub: https://github.com/xolox/python-coloredlogs
+ .. _logging.Formatter: http://docs.python.org/2/library/logging.html#logging.Formatter
+ .. _logging: https://docs.python.org/2/library/logging.html
+ .. _MIT license: http://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
+ .. _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: 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..b44647a
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,123 @@
+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 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.
+
+Usage
+-----
+
+Here's an example of how easy it is to get started:
+
+.. code-block:: python
+
+ # Create a logger object.
+ import logging
+ logger = logging.getLogger('your-module')
+
+ # Initialize coloredlogs.
+ import coloredlogs
+ coloredlogs.install(level='DEBUG')
+
+ # 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's a simple way to set it up::
+
+ 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`
+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 :-)
+
+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.
+
+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`_.
+
+© 2015 Peter Odding.
+
+
+.. External references:
+.. _ANSI escape sequences: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+.. _Colorama: https://pypi.python.org/pypi/colorama
+.. _ColoredFormatter: http://coloredlogs.readthedocs.io/en/latest/#coloredlogs.ColoredFormatter
+.. _cron: https://en.wikipedia.org/wiki/Cron
+.. _GitHub: https://github.com/xolox/python-coloredlogs
+.. _logging.Formatter: http://docs.python.org/2/library/logging.html#logging.Formatter
+.. _logging: https://docs.python.org/2/library/logging.html
+.. _MIT license: http://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
+.. _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..c294cb6
--- /dev/null
+++ b/coloredlogs.egg-info/PKG-INFO
@@ -0,0 +1,157 @@
+Metadata-Version: 1.1
+Name: coloredlogs
+Version: 5.2
+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 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.
+
+ Usage
+ -----
+
+ Here's an example of how easy it is to get started:
+
+ .. code-block:: python
+
+ # Create a logger object.
+ import logging
+ logger = logging.getLogger('your-module')
+
+ # Initialize coloredlogs.
+ import coloredlogs
+ coloredlogs.install(level='DEBUG')
+
+ # 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's a simple way to set it up::
+
+ 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`
+ 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 :-)
+
+ 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.
+
+ 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`_.
+
+ © 2015 Peter Odding.
+
+
+ .. External references:
+ .. _ANSI escape sequences: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
+ .. _Colorama: https://pypi.python.org/pypi/colorama
+ .. _ColoredFormatter: http://coloredlogs.readthedocs.io/en/latest/#coloredlogs.ColoredFormatter
+ .. _cron: https://en.wikipedia.org/wiki/Cron
+ .. _GitHub: https://github.com/xolox/python-coloredlogs
+ .. _logging.Formatter: http://docs.python.org/2/library/logging.html#logging.Formatter
+ .. _logging: https://docs.python.org/2/library/logging.html
+ .. _MIT license: http://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
+ .. _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: 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..202b527
--- /dev/null
+++ b/coloredlogs.egg-info/requires.txt
@@ -0,0 +1,4 @@
+humanfriendly>=2.1
+
+[:sys_platform == "win32"]
+colorama
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..3a5b077
--- /dev/null
+++ b/coloredlogs/__init__.py
@@ -0,0 +1,934 @@
+# Colored terminal output for Python's logging module.
+#
+# Author: Peter Odding <peter at peterodding.com>
+# Last Change: November 1, 2016
+# 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: http://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%
+
+Classes and functions
+=====================
+"""
+
+# Standard library modules.
+import collections
+import copy
+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
+
+# Optional external dependency (only needed on Windows).
+NEED_COLORAMA = sys.platform.startswith('win')
+HAVE_COLORAMA = False
+if NEED_COLORAMA:
+ try:
+ import colorama
+ HAVE_COLORAMA = True
+ except ImportError:
+ pass
+
+# Semi-standard module versioning.
+__version__ = '5.2'
+
+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).
+
+This is disabled on Windows because in my (admittedly limited) experience the
+ANSI escape sequence for bold font is simply not translated by Colorama,
+instead it's printed to the terminal without any translation.
+"""
+
+DEFAULT_FIELD_STYLES = dict(
+ asctime=dict(color='green'),
+ hostname=dict(color='magenta'),
+ levelname=dict(color='black', bold=CAN_USE_BOLD_FONT),
+ programname=dict(color='cyan'),
+ name=dict(color='blue'))
+"""Mapping of log format names to default font styles."""
+
+DEFAULT_LEVEL_STYLES = dict(
+ spam=dict(color='green'),
+ debug=dict(color='green'),
+ verbose=dict(color='blue'),
+ info=dict(),
+ notice=dict(color='magenta'),
+ warning=dict(color='yellow'),
+ error=dict(color='red'),
+ critical=dict(color='red', bold=CAN_USE_BOLD_FONT))
+"""Mapping of log level names to default font styles."""
+
+
+def auto_install():
+ """
+ Automatically call :func:`install()` when ``$COLOREDLOGS_AUTO_INSTALL`` is set.
+
+ The `coloredlogs` package includes a `path configuration file`_ that
+ automatically imports the :mod:`coloredlogs` module and calls
+ :func:`auto_install()` when the environment variable
+ ``$COLOREDLOGS_AUTO_INSTALL`` is set.
+
+ This function uses :func:`~humanfriendly.coerce_boolean()` to check whether
+ the value of ``$COLOREDLOGS_AUTO_INSTALL`` should be considered :data:`True`.
+
+ .. _path configuration file: https://docs.python.org/2/library/site.html#module-site
+ """
+ if coerce_boolean(os.environ.get('COLOREDLOGS_AUTO_INSTALL', 'false')):
+ install()
+
+
+def install(level=None, **kw):
+ """
+ Enable colored terminal output for Python's :mod:`logging` module.
+
+ :param level: The default logging level (an integer or a string with a
+ level name, defaults to :data:`logging.INFO`).
+ :param logger: The logger to which the stream handler should be attached (a
+ :class:`~logging.Logger` object, defaults to the root logger).
+ :param fmt: Set the logging format (a string like those accepted by
+ :class:`~logging.Formatter`, defaults to
+ :data:`DEFAULT_LOG_FORMAT`).
+ :param datefmt: Set the date/time format (a string, defaults to
+ :data:`DEFAULT_DATE_FORMAT`).
+ :param level_styles: A dictionary with custom level styles (defaults to
+ :data:`DEFAULT_LEVEL_STYLES`).
+ :param field_styles: A dictionary with custom field styles (defaults to
+ :data:`DEFAULT_FIELD_STYLES`).
+ :param stream: The stream where log messages should be written to (a
+ file-like object, defaults to :data:`sys.stderr`).
+ :param isatty: :data:`True` to use a :class:`ColoredFormatter`,
+ :data:`False` to use a normal :class:`~logging.Formatter`
+ (defaults to auto-detection using
+ :func:`~humanfriendly.terminal.terminal_supports_colors()`).
+ :param reconfigure: If :data:`True` (the default) multiple calls to
+ :func:`coloredlogs.install()` will each override
+ the previous configuration.
+ :param use_chroot: Refer to :class:`HostNameFilter`.
+ :param programname: Refer to :class:`ProgramNameFilter`.
+ :param syslog: If :data:`True` then :func:`~coloredlogs.syslog.enable_system_logging()`
+ will be called without arguments (defaults to :data:`False`).
+
+ The :func:`coloredlogs.install()` function is similar to
+ :func:`logging.basicConfig()`, both functions take a lot of optional
+ keyword arguments but try to do the right thing by default:
+
+ 1. If `reconfigure` is :data:`True` (it is by default) and an existing
+ :class:`~logging.StreamHandler` is found that is connected to either
+ :data:`~sys.stdout` or :data:`~sys.stderr` the handler will be removed.
+ This means that first calling :func:`logging.basicConfig()` and then
+ calling :func:`coloredlogs.install()` will replace the stream handler
+ instead of adding a duplicate stream handler. If `reconfigure` is
+ :data:`False` and an existing handler is found no further steps are
+ taken (to avoid installing a duplicate stream handler).
+
+ 2. A :class:`~logging.StreamHandler` is created and connected to the stream
+ given by the `stream` keyword argument (:data:`sys.stderr` by
+ default). The stream handler's level is set to the value of the `level`
+ keyword argument.
+
+ 3. A :class:`ColoredFormatter` is created if the `isatty` keyword argument
+ allows it (or auto-detection allows it), otherwise a normal
+ :class:`~logging.Formatter` is created. The formatter is initialized
+ with the `fmt` and `datefmt` keyword arguments (or their computed
+ defaults).
+
+ 4. :func:`HostNameFilter.install()` and :func:`ProgramNameFilter.install()`
+ are called to enable the use of additional fields in the log format.
+
+ 5. The formatter is added to the handler and the handler is added to the
+ logger. The logger's level is set to :data:`logging.NOTSET` so that each
+ handler gets to decide which records they filter. This makes it possible
+ to have controllable verbosity on the terminal while logging at full
+ verbosity to the system log or a file.
+ """
+ logger = kw.get('logger') or logging.getLogger()
+ reconfigure = kw.get('reconfigure', True)
+ stream = kw.get('stream', sys.stderr)
+ # Remove any existing stream handler that writes to stdout or stderr, even
+ # if the stream handler wasn't created by coloredlogs because multiple
+ # stream handlers (in the same hierarchy) writing to stdout or stderr would
+ # create duplicate output.
+ standard_streams = (sys.stdout, sys.stderr)
+ match_streams = standard_streams if stream in standard_streams else (stream,)
+ match_handler = lambda handler: match_stream_handler(handler, match_streams)
+ handler, logger = replace_handler(logger, match_handler, reconfigure)
+ # Make sure reconfiguration is allowed or not relevant.
+ if not (handler and not reconfigure):
+ # Make it easy to enable system logging.
+ if kw.get('syslog', False):
+ from coloredlogs import syslog
+ syslog.enable_system_logging()
+ # Figure out whether we can use ANSI escape sequences.
+ use_colors = kw.get('isatty', None)
+ if use_colors or use_colors is None:
+ if NEED_COLORAMA:
+ if HAVE_COLORAMA:
+ # On Windows we can only use ANSI escape
+ # sequences if Colorama is available.
+ colorama.init()
+ use_colors = True
+ else:
+ # If Colorama isn't available then we specifically
+ # shouldn't emit ANSI escape sequences!
+ use_colors = False
+ elif use_colors is None:
+ # Auto-detect terminal support on other platforms.
+ use_colors = terminal_supports_colors(stream)
+ # Create a stream handler.
+ handler = logging.StreamHandler(stream)
+ if level is None:
+ level = os.environ.get('COLOREDLOGS_LOG_LEVEL') or 'INFO'
+ handler.setLevel(level_to_number(level))
+ # Prepare the arguments to the formatter. The caller is
+ # allowed to customize `fmt' and/or `datefmt' as desired.
+ formatter_options = dict(fmt=kw.get('fmt'), datefmt=kw.get('datefmt'))
+ # Come up with a default log format?
+ if not formatter_options['fmt']:
+ # Use the log format defined by the environment variable
+ # $COLOREDLOGS_LOG_FORMAT or fall back to the default.
+ formatter_options['fmt'] = os.environ.get('COLOREDLOGS_LOG_FORMAT') or DEFAULT_LOG_FORMAT
+ # If the caller didn't specify a date/time format we'll use the format
+ # defined by the environment variable $COLOREDLOGS_DATE_FORMAT (or fall
+ # back to the default).
+ if not formatter_options['datefmt']:
+ formatter_options['datefmt'] = os.environ.get('COLOREDLOGS_DATE_FORMAT') or DEFAULT_DATE_FORMAT
+ # Do we need to make %(hostname) available to the formatter?
+ HostNameFilter.install(
+ handler=handler,
+ fmt=formatter_options['fmt'],
+ use_chroot=kw.get('use_chroot', True),
+ )
+ # Do we need to make %(programname) available to the formatter?
+ ProgramNameFilter.install(
+ handler=handler,
+ fmt=formatter_options['fmt'],
+ programname=kw.get('programname'),
+ )
+ # Inject additional formatter arguments specific to ColoredFormatter?
+ if use_colors:
+ for name, environment_name in (('field_styles', 'COLOREDLOGS_FIELD_STYLES'),
+ ('level_styles', 'COLOREDLOGS_LEVEL_STYLES')):
+ value = kw.get(name)
+ if value is None:
+ # If no styles have been specified we'll fall back
+ # to the styles defined by the environment variable.
+ environment_value = os.environ.get(environment_name)
+ if environment_value is not None:
+ value = parse_encoded_styles(environment_value)
+ if value is not None:
+ formatter_options[name] = value
+ # Create a (possibly colored) formatter.
+ formatter_type = ColoredFormatter if use_colors else logging.Formatter
+ handler.setFormatter(formatter_type(**formatter_options))
+ # Install the stream handler.
+ logger.setLevel(logging.NOTSET)
+ logger.addHandler(handler)
+
+
+def increase_verbosity():
+ """
+ Increase the verbosity of the root handler by one defined level.
+
+ Understands custom logging levels like defined by my ``verboselogs``
+ module.
+ """
+ defined_levels = sorted(set(find_defined_levels().values()))
+ current_index = defined_levels.index(get_level())
+ selected_index = max(0, current_index - 1)
+ set_level(defined_levels[selected_index])
+
+
+def decrease_verbosity():
+ """
+ Decrease the verbosity of the root handler by one defined level.
+
+ Understands custom logging levels like defined by my ``verboselogs``
+ module.
+ """
+ defined_levels = sorted(set(find_defined_levels().values()))
+ current_index = defined_levels.index(get_level())
+ selected_index = min(current_index + 1, len(defined_levels) - 1)
+ set_level(defined_levels[selected_index])
+
+
+def is_verbose():
+ """
+ Check whether the log level of the root handler is set to a verbose level.
+
+ :returns: ``True`` if the root handler is verbose, ``False`` if not.
+ """
+ return get_level() < logging.INFO
+
+
+def get_level():
+ """
+ Get the logging level of the root handler.
+
+ :returns: The logging level of the root handler (an integer) or
+ :data:`logging.INFO` (if no root handler exists).
+ """
+ handler, logger = find_handler(logging.getLogger(), match_stream_handler)
+ return handler.level if handler else logging.INFO
+
+
+def set_level(level):
... 1635 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