diff -Nru python-colorlog-2.10.0/colorlog/colorlog.py python-colorlog-2.6.0/colorlog/colorlog.py --- python-colorlog-2.10.0/colorlog/colorlog.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/colorlog.py 2015-02-02 12:23:36.000000000 +0000 @@ -8,8 +8,7 @@ from colorlog.escape_codes import escape_codes, parse_colors -__all__ = ('escape_codes', 'default_log_colors', 'ColoredFormatter', - 'LevelFormatter', 'TTYColoredFormatter') +__all__ = ('escape_codes', 'default_log_colors', 'ColoredFormatter') # The default colors to use for the debug levels default_log_colors = { @@ -65,8 +64,8 @@ Intended to help in creating more readable logging output. """ - def __init__(self, fmt=None, datefmt=None, style='%', - log_colors=None, reset=True, + def __init__(self, fmt=None, datefmt=None, + log_colors=None, reset=True, style='%', secondary_log_colors=None): """ Set the format and colors the ColoredFormatter will use. @@ -76,7 +75,7 @@ The ``secondary_log_colors`` argument can be used to create additional ``log_color`` attributes. Each key in the dictionary will set - ``{key}_log_color``, using the value to select from a different + ``log_color_{key}``, using the value to select from a different ``log_colors`` set. :Parameters: @@ -85,7 +84,7 @@ - log_colors (dict): A mapping of log level names to color names - reset (bool): - Implicitly append a color reset to all records unless False + Implictly append a color reset to all records unless False - style ('%' or '{' or '$'): The format style to use. (*No meaning prior to Python 3.2.*) - secondary_log_colors (dict): @@ -109,9 +108,9 @@ self.secondary_log_colors = secondary_log_colors self.reset = reset - def color(self, log_colors, level_name): + def color(self, log_colors, name): """Return escape codes from a ``log_colors`` dict.""" - return parse_colors(log_colors.get(level_name, "")) + return parse_colors(log_colors.get(name, "")) def format(self, record): """Format a message from a record object.""" @@ -136,86 +135,3 @@ message += escape_codes['reset'] return message - - -class LevelFormatter(ColoredFormatter): - """An extension of ColoredFormatter that uses per-level format strings.""" - - def __init__(self, fmt=None, datefmt=None, style='%', - log_colors=None, reset=True, - secondary_log_colors=None): - """ - Set the per-loglevel format that will be used. - - Supports fmt as a dict. All other args are passed on to the - ``colorlog.ColoredFormatter`` constructor. - - :Parameters: - - fmt (dict): - A mapping of log levels (represented as strings, e.g. 'WARNING') to - different formatters. (*New in version 2.7.0) - (All other parameters are the same as in colorlog.ColoredFormatter) - - Example: - - formatter = colorlog.LevelFormatter(fmt={ - 'DEBUG':'%(log_color)s%(msg)s (%(module)s:%(lineno)d)', - 'INFO': '%(log_color)s%(msg)s', - 'WARNING': '%(log_color)sWARN: %(msg)s (%(module)s:%(lineno)d)', - 'ERROR': '%(log_color)sERROR: %(msg)s (%(module)s:%(lineno)d)', - 'CRITICAL': '%(log_color)sCRIT: %(msg)s (%(module)s:%(lineno)d)', - }) - """ - if sys.version_info > (2, 7): - super(LevelFormatter, self).__init__( - fmt=fmt, datefmt=datefmt, style=style, log_colors=log_colors, - reset=reset, secondary_log_colors=secondary_log_colors) - else: - ColoredFormatter.__init__( - self, fmt=fmt, datefmt=datefmt, style=style, - log_colors=log_colors, reset=reset, - secondary_log_colors=secondary_log_colors) - self.style = style - self.fmt = fmt - - def format(self, record): - """Customize the message format based on the log level.""" - if isinstance(self.fmt, dict): - self._fmt = self.fmt[record.levelname] - if sys.version_info > (3, 2): - # Update self._style because we've changed self._fmt - # (code based on stdlib's logging.Formatter.__init__()) - if self.style not in logging._STYLES: - raise ValueError('Style must be one of: %s' % ','.join( - logging._STYLES.keys())) - self._style = logging._STYLES[self.style][0](self._fmt) - - if sys.version_info > (2, 7): - message = super(LevelFormatter, self).format(record) - else: - message = ColoredFormatter.format(self, record) - - return message - - -class TTYColoredFormatter(ColoredFormatter): - """ - Blanks all color codes if not running under a TTY. - - This is useful when you want to be able to pipe colorlog output to a file. - """ - - def __init__(self, *args, **kwargs): - """Overwrites the `reset` argument to False if stream is not a TTY.""" - self.stream = kwargs.pop('stream', sys.stdout) - - # Both `reset` and `isatty` must be true to insert reset codes. - kwargs['reset'] = kwargs.get('reset', True) and self.stream.isatty() - - ColoredFormatter.__init__(self, *args, **kwargs) - - def color(self, log_colors, level_name): - """Only returns colors if STDOUT is a TTY.""" - if not self.stream.isatty(): - log_colors = {} - return ColoredFormatter.color(self, log_colors, level_name) diff -Nru python-colorlog-2.10.0/colorlog/escape_codes.py python-colorlog-2.6.0/colorlog/escape_codes.py --- python-colorlog-2.10.0/colorlog/escape_codes.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/escape_codes.py 2015-02-02 12:23:36.000000000 +0000 @@ -15,11 +15,8 @@ __all__ = ('escape_codes', 'parse_colors') - # Returns escape codes from format codes -def esc(*x): - return '\033[' + ';'.join(x) + 'm' - +esc = lambda *x: '\033[' + ';'.join(x) + 'm' # The initial list of escape codes escape_codes = { diff -Nru python-colorlog-2.10.0/colorlog/__init__.py python-colorlog-2.6.0/colorlog/__init__.py --- python-colorlog-2.10.0/colorlog/__init__.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/__init__.py 2015-02-02 12:23:36.000000000 +0000 @@ -3,14 +3,12 @@ from __future__ import absolute_import from colorlog.colorlog import ( - escape_codes, default_log_colors, - ColoredFormatter, LevelFormatter, TTYColoredFormatter) + ColoredFormatter, escape_codes, default_log_colors) from colorlog.logging import ( basicConfig, root, getLogger, log, - debug, info, warning, error, exception, critical, StreamHandler) + debug, info, warning, error, exception, critical) __all__ = ('ColoredFormatter', 'default_log_colors', 'escape_codes', 'basicConfig', 'root', 'getLogger', 'debug', 'info', 'warning', - 'error', 'exception', 'critical', 'log', 'exception', - 'StreamHandler', 'LevelFormatter', 'TTYColoredFormatter') + 'error', 'exception', 'critical', 'log', 'exception') diff -Nru python-colorlog-2.10.0/colorlog/logging.py python-colorlog-2.6.0/colorlog/logging.py --- python-colorlog-2.10.0/colorlog/logging.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/logging.py 2015-02-02 12:23:36.000000000 +0000 @@ -33,7 +33,6 @@ return func(*args, **kwargs) return wrapper - root = logging.root getLogger = logging.getLogger debug = ensure_configured(logging.debug) @@ -43,5 +42,3 @@ critical = ensure_configured(logging.critical) log = ensure_configured(logging.log) exception = ensure_configured(logging.exception) - -StreamHandler = logging.StreamHandler diff -Nru python-colorlog-2.10.0/colorlog/tests/conftest.py python-colorlog-2.6.0/colorlog/tests/conftest.py --- python-colorlog-2.10.0/colorlog/tests/conftest.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/tests/conftest.py 2015-02-02 12:23:36.000000000 +0000 @@ -52,9 +52,7 @@ def create_and_test_logger(test_logger): def function(*args, **kwargs): validator = kwargs.pop('validator', None) - formatter_cls = kwargs.pop('formatter_class', colorlog.ColoredFormatter) - - formatter = formatter_cls(*args, **kwargs) + formatter = colorlog.ColoredFormatter(*args, **kwargs) stream = logging.StreamHandler() stream.setLevel(logging.DEBUG) diff -Nru python-colorlog-2.10.0/colorlog/tests/test_colorlog.py python-colorlog-2.6.0/colorlog/tests/test_colorlog.py --- python-colorlog-2.10.0/colorlog/tests/test_colorlog.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/tests/test_colorlog.py 2015-02-02 12:23:36.000000000 +0000 @@ -4,8 +4,6 @@ import pytest -import colorlog - def test_colored_formatter(create_and_test_logger): create_and_test_logger() @@ -81,14 +79,3 @@ def test_template_style(create_and_test_logger): create_and_test_logger( fmt='${log_color}${levelname}:${name}:${message}', style='$') - - -@pytest.mark.parametrize('isatty', [True, False]) -def test_ttycolorlog(create_and_test_logger, monkeypatch, isatty): - def isatty_func(): - return isatty - monkeypatch.setattr(sys.stdout, 'isatty', isatty_func) - - create_and_test_logger( - formatter_class=colorlog.TTYColoredFormatter, - validator=lambda line: ('\x1b[' in line) == isatty) diff -Nru python-colorlog-2.10.0/colorlog/tests/test_example.py python-colorlog-2.6.0/colorlog/tests/test_example.py --- python-colorlog-2.10.0/colorlog/tests/test_example.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/colorlog/tests/test_example.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -def test_example(): - """Tests the usage example from the README""" - import colorlog - - handler = colorlog.StreamHandler() - handler.setFormatter(colorlog.ColoredFormatter( - '%(log_color)s%(levelname)s:%(name)s:%(message)s')) - logger = colorlog.getLogger('example') - logger.addHandler(handler) diff -Nru python-colorlog-2.10.0/debian/changelog python-colorlog-2.6.0/debian/changelog --- python-colorlog-2.10.0/debian/changelog 2016-11-23 21:49:49.000000000 +0000 +++ python-colorlog-2.6.0/debian/changelog 2016-12-14 11:55:16.000000000 +0000 @@ -1,24 +1,8 @@ -python-colorlog (2.10.0-1) unstable; urgency=medium +python-colorlog (2.6.0-1ppa1) trusty; urgency=medium - * New upstream version 2.10.0 + * Include colorlog in Ubuntu PPA - -- Philipp Huebner Wed, 23 Nov 2016 22:49:49 +0100 - -python-colorlog (2.7.0-1) unstable; urgency=medium - - * Imported Upstream version 2.7.0 - - -- Philipp Huebner Sun, 29 May 2016 20:25:17 +0200 - -python-colorlog (2.6.3-1) unstable; urgency=medium - - * Imported Upstream version 2.6.3 - * Updated Standards-Version: 3.9.8 (no changes needed) - * Updated years in debian/copyright - * Updated Vcs-* fields in debian/control - * Install docs and examples correctly - - -- Philipp Huebner Sun, 01 May 2016 11:40:24 +0200 + -- Sander Steffann Wed, 14 Dec 2016 12:55:10 +0100 python-colorlog (2.6.0-1) unstable; urgency=medium diff -Nru python-colorlog-2.10.0/debian/control python-colorlog-2.6.0/debian/control --- python-colorlog-2.10.0/debian/control 2016-11-23 21:40:16.000000000 +0000 +++ python-colorlog-2.6.0/debian/control 2015-04-21 04:32:43.000000000 +0000 @@ -2,11 +2,11 @@ Priority: optional Maintainer: Philipp Huebner Build-Depends: debhelper (>= 9), dh-python, python-all (>= 2.5), python-setuptools, python3-all, python3-setuptools -Standards-Version: 3.9.8 +Standards-Version: 3.9.6 Section: python Homepage: https://github.com/borntyping/python-colorlog -Vcs-Git: https://anonscm.debian.org/git/users/debalance/python-colorlog.git -Vcs-Browser: https://anonscm.debian.org/git/users/debalance/python-colorlog.git +Vcs-Git: git://anonscm.debian.org/users/debalance/python-colorlog.git +Vcs-Browser: https://anonscm.debian.org/cgit/users/debalance/python-colorlog.git Package: python-colorlog Architecture: all diff -Nru python-colorlog-2.10.0/debian/copyright python-colorlog-2.6.0/debian/copyright --- python-colorlog-2.10.0/debian/copyright 2016-11-23 21:40:16.000000000 +0000 +++ python-colorlog-2.6.0/debian/copyright 2015-04-21 04:32:43.000000000 +0000 @@ -3,11 +3,11 @@ Source: https://github.com/borntyping/python-colorlog Files: * -Copyright: 2012-2016 Sam Clements +Copyright: 2012-2014 Sam Clements License: MIT Files: debian/* -Copyright: 2014-2016 Philipp Huebner +Copyright: 2014 Philipp Huebner License: MIT License: MIT diff -Nru python-colorlog-2.10.0/debian/docs python-colorlog-2.6.0/debian/docs --- python-colorlog-2.10.0/debian/docs 1970-01-01 00:00:00.000000000 +0000 +++ python-colorlog-2.6.0/debian/docs 2015-04-21 04:32:43.000000000 +0000 @@ -0,0 +1 @@ +README.rst diff -Nru python-colorlog-2.10.0/debian/python3-colorlog.docs python-colorlog-2.6.0/debian/python3-colorlog.docs --- python-colorlog-2.10.0/debian/python3-colorlog.docs 2016-11-23 21:40:16.000000000 +0000 +++ python-colorlog-2.6.0/debian/python3-colorlog.docs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -README.md diff -Nru python-colorlog-2.10.0/debian/python3-colorlog.examples python-colorlog-2.6.0/debian/python3-colorlog.examples --- python-colorlog-2.10.0/debian/python3-colorlog.examples 2016-11-23 21:40:16.000000000 +0000 +++ python-colorlog-2.6.0/debian/python3-colorlog.examples 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -doc/* diff -Nru python-colorlog-2.10.0/debian/python-colorlog.docs python-colorlog-2.6.0/debian/python-colorlog.docs --- python-colorlog-2.10.0/debian/python-colorlog.docs 2016-11-23 21:40:16.000000000 +0000 +++ python-colorlog-2.6.0/debian/python-colorlog.docs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -README.md diff -Nru python-colorlog-2.10.0/debian/python-colorlog.examples python-colorlog-2.6.0/debian/python-colorlog.examples --- python-colorlog-2.10.0/debian/python-colorlog.examples 2016-11-23 21:40:16.000000000 +0000 +++ python-colorlog-2.6.0/debian/python-colorlog.examples 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -doc/* diff -Nru python-colorlog-2.10.0/.gitignore python-colorlog-2.6.0/.gitignore --- python-colorlog-2.10.0/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ python-colorlog-2.6.0/.gitignore 2015-02-02 12:23:36.000000000 +0000 @@ -0,0 +1,8 @@ +MANIFEST +MANIFEST.in +dist/* +build/* +*.egg-info/* +*.pyc +.tox +.cache diff -Nru python-colorlog-2.10.0/LICENSE python-colorlog-2.6.0/LICENSE --- python-colorlog-2.10.0/LICENSE 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2016 Sam Clements - -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 -Nru python-colorlog-2.10.0/MANIFEST.in python-colorlog-2.6.0/MANIFEST.in --- python-colorlog-2.10.0/MANIFEST.in 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/MANIFEST.in 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -include README.md diff -Nru python-colorlog-2.10.0/README.md python-colorlog-2.6.0/README.md --- python-colorlog-2.10.0/README.md 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ - -# Log formatting with colors! - -[![](https://img.shields.io/pypi/v/colorlog.svg)](https://warehouse.python.org/project/colorlog/) [![](https://img.shields.io/pypi/l/colorlog.svg)](https://warehouse.python.org/project/colorlog/) [![](https://img.shields.io/travis/borntyping/python-colorlog/master.svg)](https://travis-ci.org/borntyping/python-colorlog) - -`colorlog.ColoredFormatter` is a formatter for use with Python's `logging` -module that outputs records using terminal colors. - -* [Source on GitHub](https://github.com/borntyping/python-colorlog) -* [Packages on PyPI](https://pypi.python.org/pypi/colorlog) -* [Builds on Travis CI](https://travis-ci.org/borntyping/python-colorlog) - -Installation ------------- - -Install from PyPI with: - -```bash -pip install colorlog -``` - -Several Linux distributions provide offical packages ([Debian], [Gentoo], -[OpenSuse] and [Ubuntu]), and others have user provided packages ([Arch AUR], -[BSD ports], [Conda], [Fedora packaging scripts]). - -Usage ------ - -```python -import colorlog - -handler = colorlog.StreamHandler() -handler.setFormatter(colorlog.ColoredFormatter( - '%(log_color)s%(levelname)s:%(name)s:%(message)s')) - -logger = colorlog.getLogger('example') -logger.addHandler(handler) -``` - -The `ColoredFormatter` class takes several arguments: - -- `format`: The format string used to output the message (required). -- `datefmt`: An optional date format passed to the base class. See [`logging.Formatter`]. -- `reset`: Implicitly adds a color reset code to the message output, unless the output already ends with one. Defaults to `True`. -- `log_colors`: A mapping of record level names to color names. The defaults can be found in `colorlog.default_log_colors`, or the below example. -- `secondary_log_colors`: A mapping of names to `log_colors` style mappings, defining additional colors that can be used in format strings. See below for an example. -- `style`: Available on Python 3.2 and above. See [`logging.Formatter`]. - -Color escape codes can be selected based on the log records level, by adding -parameters to the format string: - -- `log_color`: Return the color associated with the records level. -- `_log_color`: Return another color based on the records level if the formatter has secondary colors configured (see `secondary_log_colors` below). - -The following escape codes are made available for use in the format string: - -- `{color}`, `fg_{color}`, `bg_{color}`: Foreground and background colors. -- `bold`, `bold_{color}`, `fg_bold_{color}`, `bg_bold_{color}`: Bold/bright colors. -- `reset`: Clear all formatting (both foreground and background colors). - -The availible color names are `black`, `red`, `green`, `yellow`, `blue`, -`purple`, `cyan` and `white`. Multiple escape codes can be used at once by -joining them with commas. This example would return the escape codes for black -text on a white background: - -```python -colorlog.escape_codes.parse_colors("black,bg_white") -``` - -Examples --------- - -![Example output](doc/example.png) - -The following code creates a `ColoredFormatter` for use in a logging setup, -using the default values for each argument. - -```python -from colorlog import ColoredFormatter - -formatter = ColoredFormatter( - "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s", - datefmt=None, - reset=True, - log_colors={ - 'DEBUG': 'cyan', - 'INFO': 'green', - 'WARNING': 'yellow', - 'ERROR': 'red', - 'CRITICAL': 'red,bg_white', - }, - secondary_log_colors={}, - style='%' -) -``` - -Using `secondary_log_colors` ------------------------------- - -Secondary log colors are a way to have more than one color that is selected -based on the log level. Each key in `secondary_log_colors` adds an attribute -that can be used in format strings (`message` becomes `message_log_color`), and -has a corresponding value that is identical in format to the `log_colors` -argument. - -The following example highlights the level name using the default log colors, -and highlights the message in red for `error` and `critical` level log messages. - -```python -from colorlog import ColoredFormatter - -formatter = ColoredFormatter( - "%(log_color)s%(levelname)-8s%(reset)s %(message_log_color)s%(message)s", - secondary_log_colors={ - 'message': { - 'ERROR': 'red', - 'CRITICAL': 'red' - } - } -) -``` - -With [`dictConfig`] -------------------- - -```python -logging.config.dictConfig({ - 'formatters': { - 'colored': { - '()': 'colorlog.ColoredFormatter', - 'format': "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s" - } - }, - - ... -}) -``` - -A full example dictionary can be found in `tests/test_colorlog.py`. - -With [`fileConfig`] -------------------- - -```ini -... - -[formatters] -keys=color - -[formatter_color] -class=colorlog.ColoredFormatter -format=%(log_color)s%(levelname)-8s%(reset)s %(bg_blue)s[%(name)s]%(reset)s %(message)s from fileConfig -datefmt=%m-%d %H:%M:%S -``` - -An instance of ColoredFormatter created with those arguments will then be used -by any handlers that are configured to use the `color` formatter. - -A full example configuration can be found in `tests/test_config.ini`. - -Compatibility -============= - -colorlog works on Python 2.6 and above, including Python 3. - -On Windows, requires [colorama] to work properly. A dependancy on [colorama] is -included as an optional package dependancy - depending on `colorlog[windows]` -instead of `colorlog` will ensure it is included when installing. - -Tests -===== - -Tests similar to the above examples are found in `tests/test_colorlog.py`. - -[`tox`] will run the tests under all compatible python versions. - - -Projects using colorlog ------------------------ - -- [Counterparty] -- [Errbot] -- [Pythran] -- [zenlog] - -Licence -------- - -Copyright (c) 2012 Sam Clements - -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. - -[`dictConfig`]: http://docs.python.org/3/library/logging.config.html#logging.config.dictConfig -[`fileConfig`]: http://docs.python.org/3/library/logging.config.html#logging.config.fileConfig -[`logging.Formatter`]: http://docs.python.org/3/library/logging.html#logging.Formatter -[`tox`]: http://tox.readthedocs.org/ -[Arch AUR]: https://aur.archlinux.org/packages/python-colorlog/ -[BSD ports]: https://www.freshports.org/devel/py-colorlog/ -[colorama]: https://pypi.python.org/pypi/colorama -[Conda]: https://anaconda.org/auto/colorlog -[Counterparty]: https://counterparty.io/ -[Debian]: https://packages.debian.org/jessie/python-colorlog -[Errbot]: http://errbot.io/ -[Fedora packaging scripts]: https://github.com/bartv/python-colorlog -[Gentoo]: https://packages.gentoo.org/packages/dev-python/colorlog -[OpenSuse]: http://rpm.pbone.net/index.php3?stat=3&search=python-colorlog&srodzaj=3 -[Pythran]: http://pythonhosted.org/pythran/DEVGUIDE.html -[Ubuntu]: https://launchpad.net/python-colorlog -[zenlog]: https://github.com/ManufacturaInd/python-zenlog diff -Nru python-colorlog-2.10.0/README.rst python-colorlog-2.6.0/README.rst --- python-colorlog-2.10.0/README.rst 1970-01-01 00:00:00.000000000 +0000 +++ python-colorlog-2.6.0/README.rst 2015-02-02 12:23:36.000000000 +0000 @@ -0,0 +1,180 @@ +=========================== +Log formatting with colors! +=========================== + +.. image:: http://img.shields.io/pypi/v/colorlog.svg?style=flat-square + :target: https://pypi.python.org/pypi/colorlog + :alt: colorlog on PyPI + +.. image:: http://img.shields.io/pypi/l/colorlog.svg?style=flat-square + :target: https://pypi.python.org/pypi/colorlog + :alt: colorlog on PyPI + +.. image:: http://img.shields.io/travis/borntyping/python-colorlog/master.svg?style=flat-square + :target: https://travis-ci.org/borntyping/python-colorlog + :alt: Travis-CI build status for python-colorlog + +.. image:: https://img.shields.io/github/issues/borntyping/python-colorlog.svg?style=flat-square + :target: https://github.com/borntyping/python-colorlog/issues + :alt: GitHub issues for python-colorlog + +| + +``colorlog.ColoredFormatter`` is a formatter for use with pythons logging module. + +It allows colors to be placed in the format string, which is mostly useful when paired with a StreamHandler that is outputting to a terminal. This is accomplished by added a set of terminal color codes to the record before it is used to format the string. + +* `Source on GitHub `_ +* `Packages on PyPI `_ +* `Builds on Travis CI `_ + +Codes +===== + +Color escape codes can be selected based on the log records level, by adding parameters to the format string: + +- ``log_color``: Return the color associated with the records level (from ``color_levels``). +- ``_log_color``: Return another color based on the records level if the ``ColoredFormatter`` was created with a ``secondary_log_colors`` parameter (see below). + +The following escape codes are made availible for use in the format string: + +- ``{color}``, ``fg_{color}``, ``bg_{color}``: Foreground and background colors. The color names are ``black``, ``red``, ``green``, ``yellow``, ``blue``, ``purple``, ``cyan`` and ``white``. +- ``bold``, ``bold_{color}``, ``fg_bold_{color}``, ``bg_bold_{color}``: Bold/bright colors. +- ``reset``: Clear all formatting (both foreground and background colors). + +Multiple escape codes can be used at once by joining them with commas. This example would return the escape codes for black text on a white background: + +.. code-block:: python + + colorlog.escape_codes.parse_colors("black,bg_white") + +Arguments +========= + +``ColoredFormatter`` takes several arguments: + +- ``format``: The format string used to output the message (required). +- ``datefmt``: An optional date format passed to the base class. See `logging.Formatter`_. +- ``reset``: Implicitly adds a color reset code to the message output, unless the output already ends with one. Defaults to ``True``. +- ``log_colors``: A mapping of record level names to color names. The defaults can be found in ``colorlog.default_log_colors``, or the below example. +- ``secondary_log_colors``: A mapping of names to ``log_colors`` style mappings, defining additional colors that can be used in format strings. See below for an example. +- ``style``: Available on Python 3.2 and above. See `logging.Formatter`_. + +Examples +======== + +.. image:: doc/example.png + :alt: Example output + +The following code creates a ColoredFormatter for use in a logging setup, passing each arguments defaults to the constructor: + +.. code-block:: python + + from colorlog import ColoredFormatter + + formatter = ColoredFormatter( + "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s", + datefmt=None, + reset=True, + log_colors={ + 'DEBUG': 'cyan', + 'INFO': 'green', + 'WARNING': 'yellow', + 'ERROR': 'red', + 'CRITICAL': 'red,bg_white', + }, + secondary_log_colors={}, + style='%' + ) + +Using ``secondary_log_colors`` +------------------------------ + +Secondary log colors are a way to have more than one color that is selected based on the log level. Each key in ``secondary_log_colors`` adds an attribute that can be used in format strings (``message`` becomes ``message_log_color``), and has a corresponding value that is identical in format to the ``log_colors`` argument. + +The following example highlights the level name using the default log colors, and highlights the message in red for ``error`` and ``critical`` level log messages. + +.. code-block:: python + + from colorlog import ColoredFormatter + + formatter = ColoredFormatter( + "%(log_color)s%(levelname)-8s%(reset)s %(message_log_color)s%(message)s", + secondary_log_colors={ + 'message': { + 'ERROR': 'red', + 'CRITICAL': 'red' + } + } + ) + +With `dictConfig`_ +------------------ + +.. code-block:: python + + logging.config.dictConfig({ + 'formatters': { + 'colored': { + '()': 'colorlog.ColoredFormatter', + 'format': "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s" + } + }, + + ... + }) + +A full example dictionary can be found in ``tests/test_colorlog.py``. + + +With `fileConfig`_ +------------------ + +.. code-block:: ini + + ... + + [formatters] + keys=color + + [formatter_color] + class=colorlog.ColoredFormatter + format=%(log_color)s%(levelname)-8s%(reset)s %(bg_blue)s[%(name)s]%(reset)s %(message)s from fileConfig + datefmt=%m-%d %H:%M:%S + + ... + +An instance of ColoredFormatter created with those arguments will then be used by any handlers that are configured to use the ``color`` formatter. + +A full example configuration can be found in ``tests/test_config.ini``. + +Compatibility +============= + +colorlog works on Python 2.6 and above, including Python 3. + +On Windows, requires `colorama`_ to work properly. A dependancy on `colorama`_ is included as an optional package dependancy - depending on ``colorlog[windows]`` instead of ``colorlog`` will ensure it is included when installing. + +Tests +===== + +Tests similar to the above examples are found in ``tests/test_colorlog.py``. + +`tox`_ will run the tests under all compatible python versions. + +Licence +======= + +Copyright (c) 2012 Sam Clements + +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. + +.. _logging.Formatter: http://docs.python.org/3/library/logging.html#logging.Formatter +.. _dictConfig: http://docs.python.org/3/library/logging.config.html#logging.config.dictConfig +.. _fileConfig: http://docs.python.org/3/library/logging.config.html#logging.config.fileConfig +.. _tox: http://tox.readthedocs.org/ +.. _colorama: https://pypi.python.org/pypi/colorama diff -Nru python-colorlog-2.10.0/setup.py python-colorlog-2.6.0/setup.py --- python-colorlog-2.10.0/setup.py 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/setup.py 2015-02-02 12:23:36.000000000 +0000 @@ -2,20 +2,22 @@ setup( name='colorlog', - version='2.10.0', + version='2.6.0', description='Log formatting with colors!', - long_description=open('README.md').read(), + long_description=open("README.rst").read(), author='Sam Clements', author_email='sam@borntyping.co.uk', url='https://github.com/borntyping/python-colorlog', license='MIT License', - packages=['colorlog', 'colorlog.tests'], + packages=[ + 'colorlog' + ], extras_require={ - ':sys_platform=="win32"': [ + 'windows': [ 'colorama' ] }, @@ -31,8 +33,8 @@ 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Topic :: Terminals', 'Topic :: Utilities', ], diff -Nru python-colorlog-2.10.0/tox.ini python-colorlog-2.6.0/tox.ini --- python-colorlog-2.10.0/tox.ini 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/tox.ini 2015-02-02 12:23:36.000000000 +0000 @@ -1,6 +1,6 @@ [tox] minversion=1.8.0 -envlist=py{26,27,34,35,py},py{26,27,34,35,py}-colorama,lint +envlist=py{26,27,33,34,py},py{26,27,33,34,py}-colorama,lint [testenv] commands=py.test -v {posargs} colorlog diff -Nru python-colorlog-2.10.0/.travis.yml python-colorlog-2.6.0/.travis.yml --- python-colorlog-2.10.0/.travis.yml 2016-11-23 17:50:50.000000000 +0000 +++ python-colorlog-2.6.0/.travis.yml 2015-02-02 12:23:36.000000000 +0000 @@ -2,13 +2,13 @@ env: - TOXENV=py26 - TOXENV=py27 + - TOXENV=py32 - TOXENV=py33 - - TOXENV=py34 - TOXENV=pypy - TOXENV=py26-colorama - TOXENV=py27-colorama + - TOXENV=py32-colorama - TOXENV=py33-colorama - - TOXENV=py34-colorama - TOXENV=pypy-colorama - TOXENV=lint install: