Hello community,
here is the log from the commit of package python-colorlog for openSUSE:Factory
checked in at 2019-01-21 10:59:09
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-colorlog (Old)
and /work/SRC/openSUSE:Factory/.python-colorlog.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-colorlog"
Mon Jan 21 10:59:09 2019 rev:2 rq:666684 version:4.0.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-colorlog/python-colorlog.changes
2017-03-31 15:06:01.801712825 +0200
+++
/work/SRC/openSUSE:Factory/.python-colorlog.new.28833/python-colorlog.changes
2019-01-21 11:00:44.415245141 +0100
@@ -1,0 +2,16 @@
+Wed Jan 16 09:37:28 UTC 2019 - [email protected]
+
+- Update to 4.0.0:
+ * Breaking change: TTYColoredFormatter requires the stream
+ argument, avoiding checking the wrong stream and still
+ displaying colors when it shouldn't.
+ * Includes some other minor changes, and attempts to close the
+ last few months worth of minor issues (#54, #62, #64, #65).
+- Changes from 3.1.0:
+ * This removed the use of parse_colors directly in format
+ strings, as it relied on an implementation specific detail of
+ Python 2 and was broken on Python 3
+- Install LICENSE
+- Run tests
+
+-------------------------------------------------------------------
Old:
----
colorlog-2.10.0.tar.gz
New:
----
colorlog-4.0.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-colorlog.spec ++++++
--- /var/tmp/diff_new_pack.UzwcJZ/_old 2019-01-21 11:00:45.399243867 +0100
+++ /var/tmp/diff_new_pack.UzwcJZ/_new 2019-01-21 11:00:45.407243857 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-colorlog
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,18 +18,18 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-colorlog
-Version: 2.10.0
+Version: 4.0.0
Release: 0
Summary: Log formatting with colors
License: MIT
Group: Development/Languages/Python
-Url: https://github.com/borntyping/python-colorlog
+URL: https://github.com/borntyping/python-colorlog
Source:
https://pypi.io/packages/source/c/colorlog/colorlog-%{version}.tar.gz
BuildRequires: %{python_module devel}
+BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
%python_subpackages
%description
@@ -49,9 +49,14 @@
%python_install
%python_expand %fdupes -s %{buildroot}%{$python_sitelib}
+%check
+%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitelib}
+py.test-%{$python_bin_suffix} colorlog/tests/
+}
+
%files %{python_files}
-%defattr(-,root,root,-)
%doc README.md
+%license LICENSE
%{python_sitelib}/colorlog
%{python_sitelib}/colorlog-%{version}-py%{py_ver}.egg-info
++++++ colorlog-2.10.0.tar.gz -> colorlog-4.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/LICENSE new/colorlog-4.0.0/LICENSE
--- old/colorlog-2.10.0/LICENSE 1970-01-01 01:00:00.000000000 +0100
+++ new/colorlog-4.0.0/LICENSE 2018-12-14 17:15:50.000000000 +0100
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2018 Sam Clements <[email protected]>
+
+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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/MANIFEST.in
new/colorlog-4.0.0/MANIFEST.in
--- old/colorlog-2.10.0/MANIFEST.in 2016-11-21 13:32:05.000000000 +0100
+++ new/colorlog-4.0.0/MANIFEST.in 2018-12-14 17:06:21.000000000 +0100
@@ -1 +1,4 @@
include README.md
+include LICENSE
+include colorlog/tests/test_config.ini
+graft doc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/PKG-INFO new/colorlog-4.0.0/PKG-INFO
--- old/colorlog-2.10.0/PKG-INFO 2016-11-23 18:51:00.000000000 +0100
+++ new/colorlog-4.0.0/PKG-INFO 2018-12-14 17:33:54.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: colorlog
-Version: 2.10.0
+Version: 4.0.0
Summary: Log formatting with colors!
Home-page: https://github.com/borntyping/python-colorlog
Author: Sam Clements
@@ -27,7 +27,7 @@
pip install colorlog
```
- Several Linux distributions provide offical packages ([Debian],
[Gentoo],
+ Several Linux distributions provide official packages ([Debian],
[Gentoo],
[OpenSuse] and [Ubuntu]), and others have user provided packages
([Arch AUR],
[BSD ports], [Conda], [Fedora packaging scripts]).
@@ -60,20 +60,20 @@
- `log_color`: Return the color associated with the records level.
- `<name>_log_color`: Return another color based on the records level
if the formatter has secondary colors configured (see `secondary_log_colors`
below).
+ Multiple escape codes can be used at once by joining them with commas
when
+ configuring the color for a log level (but can't be used directly in
the format
+ string). For example, `black,bg_white` would use the escape codes for
black
+ text on a white background.
+
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.
+ - `thin`, `thin_{color}`, `fg_thin_{color}`: Thin colors (terminal
dependent).
- `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")
- ```
+ The available color names are `black`, `red`, `green`, `yellow`,
`blue`,
+ `purple`, `cyan` and `white`.
Examples
--------
@@ -138,9 +138,7 @@
'()': 'colorlog.ColoredFormatter',
'format':
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s"
}
- },
-
- ...
+ }
})
```
@@ -166,14 +164,32 @@
A full example configuration can be found in `tests/test_config.ini`.
+ With custom log levels
+ ----------------------
+
+ ColoredFormatter will work with custom log levels added with
+ [`logging.addLevelName`]:
+
+ ```python
+ import logging, colorlog
+ TRACE = 5
+ logging.addLevelName(TRACE, 'TRACE')
+ formatter = colorlog.ColoredFormatter(log_colors={'TRACE': 'yellow'})
+ handler = logging.StreamHandler()
+ handler.setFormatter(formatter)
+ logger = logging.getLogger('example')
+ logger.addHandler(handler)
+ logger.setLevel('TRACE')
+ logger.log(TRACE, 'a message using a custom level')
+ ```
+
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.
+ On Windows, [colorama] is required for `colorlog` to work properly.
It will
+ automatically be included when installing `colorlog` on windows.
Tests
=====
@@ -215,6 +231,7 @@
[`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.addLevelName`]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
[`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/
@@ -246,3 +263,4 @@
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Terminals
Classifier: Topic :: Utilities
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/README.md
new/colorlog-4.0.0/README.md
--- old/colorlog-2.10.0/README.md 2016-11-21 13:32:05.000000000 +0100
+++ new/colorlog-4.0.0/README.md 2018-12-14 17:17:39.000000000 +0100
@@ -19,7 +19,7 @@
pip install colorlog
```
-Several Linux distributions provide offical packages ([Debian], [Gentoo],
+Several Linux distributions provide official packages ([Debian], [Gentoo],
[OpenSuse] and [Ubuntu]), and others have user provided packages ([Arch AUR],
[BSD ports], [Conda], [Fedora packaging scripts]).
@@ -52,20 +52,20 @@
- `log_color`: Return the color associated with the records level.
- `<name>_log_color`: Return another color based on the records level if the
formatter has secondary colors configured (see `secondary_log_colors` below).
+Multiple escape codes can be used at once by joining them with commas when
+configuring the color for a log level (but can't be used directly in the format
+string). For example, `black,bg_white` would use the escape codes for black
+text on a white background.
+
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.
+- `thin`, `thin_{color}`, `fg_thin_{color}`: Thin colors (terminal dependent).
- `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")
-```
+The available color names are `black`, `red`, `green`, `yellow`, `blue`,
+`purple`, `cyan` and `white`.
Examples
--------
@@ -130,9 +130,7 @@
'()': 'colorlog.ColoredFormatter',
'format': "%(log_color)s%(levelname)-8s%(reset)s
%(blue)s%(message)s"
}
- },
-
- ...
+ }
})
```
@@ -158,14 +156,32 @@
A full example configuration can be found in `tests/test_config.ini`.
+With custom log levels
+----------------------
+
+ColoredFormatter will work with custom log levels added with
+[`logging.addLevelName`]:
+
+```python
+import logging, colorlog
+TRACE = 5
+logging.addLevelName(TRACE, 'TRACE')
+formatter = colorlog.ColoredFormatter(log_colors={'TRACE': 'yellow'})
+handler = logging.StreamHandler()
+handler.setFormatter(formatter)
+logger = logging.getLogger('example')
+logger.addHandler(handler)
+logger.setLevel('TRACE')
+logger.log(TRACE, 'a message using a custom level')
+```
+
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.
+On Windows, [colorama] is required for `colorlog` to work properly. It will
+automatically be included when installing `colorlog` on windows.
Tests
=====
@@ -207,6 +223,7 @@
[`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.addLevelName`]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
[`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/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog/colorlog.py
new/colorlog-4.0.0/colorlog/colorlog.py
--- old/colorlog-2.10.0/colorlog/colorlog.py 2016-11-23 18:49:55.000000000
+0100
+++ new/colorlog-4.0.0/colorlog/colorlog.py 2018-12-14 17:33:22.000000000
+0100
@@ -3,7 +3,6 @@
from __future__ import absolute_import
import logging
-import collections
import sys
from colorlog.escape_codes import escape_codes, parse_colors
@@ -30,27 +29,18 @@
class ColoredRecord(object):
"""
- Wraps a LogRecord and attempts to parse missing keys as escape codes.
+ Wraps a LogRecord, adding named escape codes to the internal dict.
- When the record is formatted, the logging library uses ``record.__dict__``
- directly - so this class replaced the dict with a ``defaultdict`` that
- checks if a missing key is an escape code.
+ The internal dict is used when formatting the message (by the PercentStyle,
+ StrFormatStyle, and StringTemplateStyle classes).
"""
- class __dict(collections.defaultdict):
- def __missing__(self, name):
- try:
- return parse_colors(name)
- except Exception:
- raise KeyError("{} is not a valid record attribute "
- "or color sequence".format(name))
-
def __init__(self, record):
- # Replace the internal dict with one that can handle missing keys
- self.__dict__ = self.__dict()
+ """Add attributes from the escape_codes dict and the record."""
+ self.__dict__.update(escape_codes)
self.__dict__.update(record.__dict__)
- # Keep a refrence to the original refrence so ``__getattr__`` can
+ # Keep a reference to the original record so ``__getattr__`` can
# access functions that are not in ``__dict__``
self.__record = record
@@ -206,8 +196,8 @@
"""
def __init__(self, *args, **kwargs):
- """Overwrites the `reset` argument to False if stream is not a TTY."""
- self.stream = kwargs.pop('stream', sys.stdout)
+ """Overwrite the `reset` argument to False if stream is not a TTY."""
+ self.stream = kwargs.pop('stream')
# Both `reset` and `isatty` must be true to insert reset codes.
kwargs['reset'] = kwargs.get('reset', True) and self.stream.isatty()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog/escape_codes.py
new/colorlog-4.0.0/colorlog/escape_codes.py
--- old/colorlog-2.10.0/colorlog/escape_codes.py 2016-11-21
15:21:34.000000000 +0100
+++ new/colorlog-4.0.0/colorlog/escape_codes.py 2018-12-14 17:14:54.000000000
+0100
@@ -3,7 +3,7 @@
http://en.wikipedia.org/wiki/ANSI_escape_code
-Uses colorama as an optional dependancy to support color on Windows
+Uses colorama as an optional dependency to support color on Windows
"""
try:
@@ -25,6 +25,7 @@
escape_codes = {
'reset': esc('0'),
'bold': esc('01'),
+ 'thin': esc('02')
}
# The color names
@@ -41,10 +42,10 @@
PREFIXES = [
# Foreground without prefix
- ('3', ''), ('01;3', 'bold_'),
+ ('3', ''), ('01;3', 'bold_'), ('02;3', 'thin_'),
# Foreground with fg_ prefix
- ('3', 'fg_'), ('01;3', 'fg_bold_'),
+ ('3', 'fg_'), ('01;3', 'fg_bold_'), ('02;3', 'fg_thin_'),
# Background with bg_ prefix - bold/light works differently
('4', 'bg_'), ('10', 'bg_bold_'),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog/tests/conftest.py
new/colorlog-4.0.0/colorlog/tests/conftest.py
--- old/colorlog-2.10.0/colorlog/tests/conftest.py 2016-11-21
15:13:08.000000000 +0100
+++ new/colorlog-4.0.0/colorlog/tests/conftest.py 2018-12-14
17:30:54.000000000 +0100
@@ -6,9 +6,17 @@
import logging
import sys
+import pytest
+
import colorlog
-import pytest
+
+class TestingStreamHandler(logging.StreamHandler):
+ """Raise errors to be caught by py.test instead of printing to stdout."""
+
+ def handleError(self, record):
+ _type, value, _traceback = sys.exc_info()
+ raise value
def assert_log_message(log_function, message, capsys):
@@ -45,6 +53,7 @@
assert valid, "{!r} did not validate".format(line.strip())
return lines
+
return function
@@ -56,7 +65,7 @@
formatter = formatter_cls(*args, **kwargs)
- stream = logging.StreamHandler()
+ stream = TestingStreamHandler(stream=sys.stderr)
stream.setLevel(logging.DEBUG)
stream.setFormatter(formatter)
@@ -65,4 +74,5 @@
logger.addHandler(stream)
return test_logger(logger, validator)
+
return function
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog/tests/test_colorlog.py
new/colorlog-4.0.0/colorlog/tests/test_colorlog.py
--- old/colorlog-2.10.0/colorlog/tests/test_colorlog.py 2016-11-23
18:47:54.000000000 +0100
+++ new/colorlog-4.0.0/colorlog/tests/test_colorlog.py 2018-12-14
17:31:53.000000000 +0100
@@ -71,24 +71,34 @@
assert len([l for l in lines if '\x1b[31m' in l]) == 2
+def test_percent_style(create_and_test_logger):
+ create_and_test_logger(
+ fmt='%(log_color)s%(levelname)s%(reset)s:%(name)s:%(message)s',
style='%')
+
+
@pytest.mark.skipif(sys.version_info < (3, 2), reason="requires python3.2")
def test_braces_style(create_and_test_logger):
create_and_test_logger(
- fmt='{log_color}{levelname}:{name}:{message}', style='{')
+ fmt='{log_color}{levelname}{reset}:{name}:{message}', style='{')
@pytest.mark.skipif(sys.version_info < (3, 2), reason="requires python3.2")
def test_template_style(create_and_test_logger):
create_and_test_logger(
- fmt='${log_color}${levelname}:${name}:${message}', style='$')
+ fmt='${log_color}${levelname}${reset}:${name}:${message}', style='$')
[email protected]('isatty', [True, False])
-def test_ttycolorlog(create_and_test_logger, monkeypatch, isatty):
- def isatty_func():
- return isatty
- monkeypatch.setattr(sys.stdout, 'isatty', isatty_func)
+def test_ttycolorlog(create_and_test_logger, monkeypatch):
+ monkeypatch.setattr(sys.stderr, 'isatty', lambda: True)
+ create_and_test_logger(
+ formatter_class=colorlog.TTYColoredFormatter,
+ validator=lambda line: '\x1b[' in line,
+ stream=sys.stderr)
+
+def test_ttycolorlog_notty(create_and_test_logger, monkeypatch):
+ monkeypatch.setattr(sys.stderr, 'isatty', lambda: False)
create_and_test_logger(
formatter_class=colorlog.TTYColoredFormatter,
- validator=lambda line: ('\x1b[' in line) == isatty)
+ validator=lambda line: '\x1b[' not in line,
+ stream=sys.stderr)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog/tests/test_config.ini
new/colorlog-4.0.0/colorlog/tests/test_config.ini
--- old/colorlog-2.10.0/colorlog/tests/test_config.ini 1970-01-01
01:00:00.000000000 +0100
+++ new/colorlog-4.0.0/colorlog/tests/test_config.ini 2018-12-14
17:05:48.000000000 +0100
@@ -0,0 +1,22 @@
+[loggers]
+keys=root
+
+[logger_root]
+handlers=stream
+level=DEBUG
+
+[formatters]
+keys=color
+
+[formatter_color]
+class=colorlog.ColoredFormatter
+format=%(log_color)s%(levelname)s:%(name)s:%(message)s:test_config.ini
+datefmt=%H:%M:%S
+
+[handlers]
+keys=stream
+
+[handler_stream]
+class=StreamHandler
+formatter=color
+args=()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog/tests/test_exports.py
new/colorlog-4.0.0/colorlog/tests/test_exports.py
--- old/colorlog-2.10.0/colorlog/tests/test_exports.py 2016-11-21
13:32:05.000000000 +0100
+++ new/colorlog-4.0.0/colorlog/tests/test_exports.py 2018-12-14
17:17:14.000000000 +0100
@@ -4,8 +4,8 @@
def test_exports():
- assert set((
+ assert {
'ColoredFormatter', 'default_log_colors', 'escape_codes',
'basicConfig', 'root', 'getLogger', 'debug', 'info', 'warning',
'error', 'exception', 'critical', 'log', 'exception'
- )) < set(globals())
+ } < set(globals())
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog.egg-info/PKG-INFO
new/colorlog-4.0.0/colorlog.egg-info/PKG-INFO
--- old/colorlog-2.10.0/colorlog.egg-info/PKG-INFO 2016-11-23
18:51:00.000000000 +0100
+++ new/colorlog-4.0.0/colorlog.egg-info/PKG-INFO 2018-12-14
17:33:54.000000000 +0100
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: colorlog
-Version: 2.10.0
+Version: 4.0.0
Summary: Log formatting with colors!
Home-page: https://github.com/borntyping/python-colorlog
Author: Sam Clements
@@ -27,7 +27,7 @@
pip install colorlog
```
- Several Linux distributions provide offical packages ([Debian],
[Gentoo],
+ Several Linux distributions provide official packages ([Debian],
[Gentoo],
[OpenSuse] and [Ubuntu]), and others have user provided packages
([Arch AUR],
[BSD ports], [Conda], [Fedora packaging scripts]).
@@ -60,20 +60,20 @@
- `log_color`: Return the color associated with the records level.
- `<name>_log_color`: Return another color based on the records level
if the formatter has secondary colors configured (see `secondary_log_colors`
below).
+ Multiple escape codes can be used at once by joining them with commas
when
+ configuring the color for a log level (but can't be used directly in
the format
+ string). For example, `black,bg_white` would use the escape codes for
black
+ text on a white background.
+
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.
+ - `thin`, `thin_{color}`, `fg_thin_{color}`: Thin colors (terminal
dependent).
- `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")
- ```
+ The available color names are `black`, `red`, `green`, `yellow`,
`blue`,
+ `purple`, `cyan` and `white`.
Examples
--------
@@ -138,9 +138,7 @@
'()': 'colorlog.ColoredFormatter',
'format':
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s"
}
- },
-
- ...
+ }
})
```
@@ -166,14 +164,32 @@
A full example configuration can be found in `tests/test_config.ini`.
+ With custom log levels
+ ----------------------
+
+ ColoredFormatter will work with custom log levels added with
+ [`logging.addLevelName`]:
+
+ ```python
+ import logging, colorlog
+ TRACE = 5
+ logging.addLevelName(TRACE, 'TRACE')
+ formatter = colorlog.ColoredFormatter(log_colors={'TRACE': 'yellow'})
+ handler = logging.StreamHandler()
+ handler.setFormatter(formatter)
+ logger = logging.getLogger('example')
+ logger.addHandler(handler)
+ logger.setLevel('TRACE')
+ logger.log(TRACE, 'a message using a custom level')
+ ```
+
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.
+ On Windows, [colorama] is required for `colorlog` to work properly.
It will
+ automatically be included when installing `colorlog` on windows.
Tests
=====
@@ -215,6 +231,7 @@
[`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.addLevelName`]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
[`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/
@@ -246,3 +263,4 @@
Classifier: Programming Language :: Python :: 3.5
Classifier: Topic :: Terminals
Classifier: Topic :: Utilities
+Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/colorlog.egg-info/SOURCES.txt
new/colorlog-4.0.0/colorlog.egg-info/SOURCES.txt
--- old/colorlog-2.10.0/colorlog.egg-info/SOURCES.txt 2016-11-23
18:51:00.000000000 +0100
+++ new/colorlog-4.0.0/colorlog.egg-info/SOURCES.txt 2018-12-14
17:33:54.000000000 +0100
@@ -1,3 +1,4 @@
+LICENSE
MANIFEST.in
README.md
setup.cfg
@@ -13,8 +14,12 @@
colorlog.egg-info/top_level.txt
colorlog/tests/conftest.py
colorlog/tests/test_colorlog.py
+colorlog/tests/test_config.ini
colorlog/tests/test_config.py
colorlog/tests/test_escape_codes.py
colorlog/tests/test_example.py
colorlog/tests/test_exports.py
-colorlog/tests/test_logging.py
\ No newline at end of file
+colorlog/tests/test_logging.py
+doc/custom_level.py
+doc/example.png
+doc/example.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/doc/custom_level.py
new/colorlog-4.0.0/doc/custom_level.py
--- old/colorlog-2.10.0/doc/custom_level.py 1970-01-01 01:00:00.000000000
+0100
+++ new/colorlog-4.0.0/doc/custom_level.py 2018-12-14 17:05:48.000000000
+0100
@@ -0,0 +1,23 @@
+import logging
+
+from colorlog import ColoredFormatter
+
+logging.addLevelName(5, 'TRACE')
+
+
+def main():
+ """Create and use a logger."""
+ formatter = ColoredFormatter(log_colors={'TRACE': 'yellow'})
+
+ handler = logging.StreamHandler()
+ handler.setFormatter(formatter)
+
+ logger = logging.getLogger('example')
+ logger.addHandler(handler)
+ logger.setLevel('TRACE')
+
+ logger.log(5, 'a message using a custom level')
+
+
+if __name__ == '__main__':
+ main()
Binary files old/colorlog-2.10.0/doc/example.png and
new/colorlog-4.0.0/doc/example.png differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/doc/example.py
new/colorlog-4.0.0/doc/example.py
--- old/colorlog-2.10.0/doc/example.py 1970-01-01 01:00:00.000000000 +0100
+++ new/colorlog-4.0.0/doc/example.py 2018-12-14 17:05:48.000000000 +0100
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""python-colorlog example."""
+
+import logging
+from colorlog import ColoredFormatter
+
+
+def setup_logger():
+ """Return a logger with a default 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',
+ }
+ )
+
+ logger = logging.getLogger('example')
+ handler = logging.StreamHandler()
+ handler.setFormatter(formatter)
+ logger.addHandler(handler)
+ logger.setLevel(logging.DEBUG)
+
+ return logger
+
+
+def main():
+ """Create and use a logger."""
+ logger = setup_logger()
+
+ logger.debug('a debug message')
+ logger.info('an info message')
+ logger.warning('a warning message')
+ logger.error('an error message')
+ logger.critical('a critical message')
+
+
+if __name__ == '__main__':
+ main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/setup.cfg
new/colorlog-4.0.0/setup.cfg
--- old/colorlog-2.10.0/setup.cfg 2016-11-23 18:51:00.000000000 +0100
+++ new/colorlog-4.0.0/setup.cfg 2018-12-14 17:33:54.000000000 +0100
@@ -1,8 +1,14 @@
[bdist_wheel]
universal = 1
+[tool:pytest]
+addopts = -p no:logging
+
+[flake8]
+exclude = colorlog/tests
+ignore = D203
+
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-2.10.0/setup.py new/colorlog-4.0.0/setup.py
--- old/colorlog-2.10.0/setup.py 2016-11-23 18:50:47.000000000 +0100
+++ new/colorlog-4.0.0/setup.py 2018-12-14 17:26:27.000000000 +0100
@@ -2,10 +2,11 @@
setup(
name='colorlog',
- version='2.10.0',
+ version='4.0.0',
description='Log formatting with colors!',
long_description=open('README.md').read(),
+ long_description_content_type='text/markdown',
author='Sam Clements',
author_email='[email protected]',