Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-colorlog for openSUSE:Factory
checked in at 2026-09-28 10:44:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-colorlog (Old)
and /work/SRC/openSUSE:Factory/.python-colorlog.new.383539 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-colorlog"
Mon Sep 28 10:44:21 2026 rev:16 rq:1380725 version:6.12.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-colorlog/python-colorlog.changes
2025-10-17 20:14:48.000271828 +0200
+++
/work/SRC/openSUSE:Factory/.python-colorlog.new.383539/python-colorlog.changes
2026-09-28 10:44:33.660197431 +0200
@@ -1,0 +2,8 @@
+Fri Sep 25 20:32:52 UTC 2026 - Dirk Müller <[email protected]>
+
+- update to 6.12.0:
+ * Fix LevelFormatter KeyError on unlisted or custom log levels
+- update to 6.11.0:
+ * Update README and examples to reflect current API
+
+-------------------------------------------------------------------
Old:
----
colorlog-6.10.1.tar.gz
New:
----
colorlog-6.12.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-colorlog.spec ++++++
--- /var/tmp/diff_new_pack.NGdx3n/_old 2026-09-28 10:44:34.392228100 +0200
+++ /var/tmp/diff_new_pack.NGdx3n/_new 2026-09-28 10:44:34.394228184 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-colorlog
#
-# Copyright (c) 2025 SUSE LLC and contributors
+# Copyright (c) 2026 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
%{?sle15_python_module_pythons}
Name: python-colorlog
-Version: 6.10.1
+Version: 6.12.0
Release: 0
Summary: Log formatting with colors
License: MIT
++++++ colorlog-6.10.1.tar.gz -> colorlog-6.12.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-6.10.1/PKG-INFO new/colorlog-6.12.0/PKG-INFO
--- old/colorlog-6.10.1/PKG-INFO 2025-10-16 18:14:00.762482200 +0200
+++ new/colorlog-6.12.0/PKG-INFO 2026-07-23 15:40:22.028151800 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: colorlog
-Version: 6.10.1
+Version: 6.12.0
Summary: Add colours to the output of Python's logging module.
Home-page: https://github.com/borntyping/python-colorlog
Author: Sam Clements
@@ -52,20 +52,20 @@
Add colours to the output of Python's `logging` module.
-* [Source on GitHub](https://github.com/borntyping/python-colorlog)
-* [Packages on PyPI](https://pypi.org/pypi/colorlog/)
+- [Source on GitHub](https://github.com/borntyping/python-colorlog)
+- [Package on PyPI](https://pypi.org/pypi/colorlog/)
## Status
-colorlog currently requires Python 3.6 or higher. Older versions (below 5.x.x)
+colorlog currently requires Python 3.6 or higher. Older versions (below 5.x.x)
support Python 2.6 and above.
-* colorlog 6.x requires Python 3.6 or higher.
-* colorlog 5.x is an interim version that will warn Python 2 users to
downgrade.
-* colorlog 4.x is the final version supporting Python 2.
+- colorlog 6.x requires Python 3.6 or higher.
+- colorlog 5.x is an interim version that will warn Python 2 users to
downgrade.
+- colorlog 4.x is the final version supporting Python 2.
-[colorama] is included as a required dependency and initialised when using
-colorlog on Windows.
+[colorama] is included as a dependency on Windows, where it is automatically
+initialised to support colored output.
This library is over a decade old and supported a wide set of Python versions
for most of its life, which has made it a difficult library to add new features
@@ -83,9 +83,9 @@
pip install colorlog
```
-Several Linux distributions provide official packages ([Debian], [Arch],
[Fedora],
-[Gentoo], [OpenSuse] and [Ubuntu]), and others have user provided packages
-([BSD ports], [Conda]).
+Several Linux distributions provide official packages ([Debian], [Arch],
+[Fedora], [Gentoo], [OpenSuse] and [Ubuntu]), and others have user provided
+packages ([BSD ports], [Conda]).
## Usage
@@ -93,27 +93,46 @@
import colorlog
handler = colorlog.StreamHandler()
-handler.setFormatter(colorlog.ColoredFormatter(
- '%(log_color)s%(levelname)s:%(name)s:%(message)s'))
+handler.setFormatter(colorlog.ColoredFormatter())
logger = colorlog.getLogger('example')
logger.addHandler(handler)
```
-The `ColoredFormatter` class takes several arguments:
+### Arguments
-- `format`: The format string used to output the message (required).
-- `datefmt`: An optional date format passed to the base class. See
[`logging.Formatter`][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`][Formatter].
+`ColoredFormatter` extends [`logging.Formatter`][formatter] and accepts the
+following arguments:
+
+- `fmt` *(default=`None`)*: A format string used to output the message. If
+ `None`, a default format string is selected based on `style` (e.g.
+ `%(log_color)s%(levelname)s:%(name)s:%(message)s` for `%` style).
+- `datefmt`, `style`, `validate`, `defaults`: see
+ [`logging.Formatter`][formatter].
+- `reset` *(default=`True`)*: Implicitly adds a color reset code to the
+ message output, unless the output already ends with one.
+- `log_colors` *(default=`None`)*: A mapping of record level names to color
+ names. If `None`, `colorlog.default_log_colors` is used.
+- `secondary_log_colors` *(default=`None`)*: A mapping of names to `log_colors`
+ style mappings, defining additional colors that can be used in format
strings.
+ If `None`, an empty mapping is used.
+- `stream` *(default=`None`)*: The stream being written to (e.g. `sys.stderr`).
+ Used to detect whether the output is a TTY. Colors are disabled automatically
+ on non-TTY streams unless `force_color` is set.
+- `no_color` *(default=`False`)*: Disable color output. Can also be set via the
+ `NO_COLOR` environment variable.
+- `force_color` *(default=`False`)*: Force color output even on non-TTY
streams.
+ Takes precedence over `no_color`. Can also be set via the `FORCE_COLOR`
+ environment variable.
+
+### Color escape 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.
-- `<name>_log_color`: Return another color based on the records level if the
formatter has secondary colors configured (see `secondary_log_colors` below).
+- `<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
@@ -123,7 +142,8 @@
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.
+- `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).
@@ -133,7 +153,7 @@
- `red`
- `green`
- `yellow`
-- `blue`,
+- `blue`
- `purple`
- `cyan`
- `white`
@@ -150,32 +170,33 @@
- `light_cyan`
- `light_white`
+In addition to pre-defined color names, you can use integers from 0 to 255 for
+256-color support (e.g. `fg_196`, `bg_42`).
+
## Examples

-The following code creates a `ColoredFormatter` for use in a logging setup,
-using the default values for each argument.
+The following snippet creates a `ColoredFormatter` for use in a logging setup,
+with a custom format string and log colors:
```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='%'
+ "DEBUG": "cyan",
+ "INFO": "green",
+ "WARNING": "yellow",
+ "ERROR": "red",
+ "CRITICAL": "red,bg_white",
+ }
)
```
+*See `docs/example.py` for full example script.*
+
### Using `secondary_log_colors`
Secondary log colors are a way to have more than one color that is selected
@@ -194,14 +215,14 @@
"%(log_color)s%(levelname)-8s%(reset)s
%(message_log_color)s%(message)s",
secondary_log_colors={
'message': {
- 'ERROR': 'red',
+ 'ERROR': 'red',
'CRITICAL': 'red'
}
}
)
```
-### With [`dictConfig`][dictConfig]
+### With [`dictConfig`][dictconfig]
```python
logging.config.dictConfig({
@@ -216,7 +237,7 @@
A full example dictionary can be found in `tests/test_colorlog.py`.
-### With [`fileConfig`][fileConfig]
+### With [`fileConfig`][fileconfig]
```ini
...
@@ -238,7 +259,7 @@
### With custom log levels
ColoredFormatter will work with custom log levels added with
-[`logging.addLevelName`][addLevelName]:
+[`logging.addLevelName`][addlevelname]:
```python
import logging, colorlog
@@ -299,23 +320,22 @@
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
-[addLevelName]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
-[Formatter]: http://docs.python.org/3/library/logging.html#logging.Formatter
-[tox]: http://tox.readthedocs.org/
-[Arch]: https://archlinux.org/packages/extra/any/python-colorlog/
-[BSD ports]: https://www.freshports.org/devel/py-colorlog/
+[addlevelname]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
+[arch]: https://archlinux.org/packages/extra/any/python-colorlog/
+[bsd ports]: https://www.freshports.org/devel/py-colorlog/
[colorama]: https://pypi.python.org/pypi/colorama
-[Conda]: https://anaconda.org/conda-forge/colorlog
-[Debian]:
[https://packages.debian.org/buster/python3-colorlog](https://packages.debian.org/buster/python3-colorlog)
-[Errbot]: http://errbot.io/
-[Fedora]: https://src.fedoraproject.org/rpms/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]: https://github.com/serge-sans-paille/pythran
-[Ubuntu]: https://launchpad.net/python-colorlog
-[zenlog]: https://github.com/ManufacturaInd/python-zenlog
-[structlog]: https://www.structlog.org/en/stable/
-[jsonlog]: https://github.com/borntyping/jsonlog
+[conda]: https://anaconda.org/conda-forge/colorlog
+[debian]: https://packages.debian.org/trixie/python3-colorlog
[dependents]:
https://github.com/borntyping/python-colorlog/network/dependents?package_id=UGFja2FnZS01MDk3NDcyMQ%3D%3D
+[dictconfig]:
http://docs.python.org/3/library/logging.config.html#logging.config.dictConfig
+[errbot]: http://errbot.io/
+[fedora]: https://src.fedoraproject.org/rpms/python-colorlog
+[fileconfig]:
http://docs.python.org/3/library/logging.config.html#logging.config.fileConfig
+[formatter]: http://docs.python.org/3/library/logging.html#logging.Formatter
+[gentoo]: https://packages.gentoo.org/packages/dev-python/colorlog
+[jsonlog]: https://github.com/borntyping/jsonlog
+[opensuse]:
http://rpm.pbone.net/index.php3?stat=3&search=python-colorlog&srodzaj=3
+[pythran]: https://github.com/serge-sans-paille/pythran
+[structlog]: https://www.structlog.org/en/stable/
+[ubuntu]: https://launchpad.net/python-colorlog
+[zenlog]: https://github.com/ManufacturaInd/python-zenlog
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-6.10.1/README.md
new/colorlog-6.12.0/README.md
--- old/colorlog-6.10.1/README.md 2025-10-16 18:13:47.000000000 +0200
+++ new/colorlog-6.12.0/README.md 2026-07-23 15:40:18.000000000 +0200
@@ -5,20 +5,20 @@
Add colours to the output of Python's `logging` module.
-* [Source on GitHub](https://github.com/borntyping/python-colorlog)
-* [Packages on PyPI](https://pypi.org/pypi/colorlog/)
+- [Source on GitHub](https://github.com/borntyping/python-colorlog)
+- [Package on PyPI](https://pypi.org/pypi/colorlog/)
## Status
-colorlog currently requires Python 3.6 or higher. Older versions (below 5.x.x)
+colorlog currently requires Python 3.6 or higher. Older versions (below 5.x.x)
support Python 2.6 and above.
-* colorlog 6.x requires Python 3.6 or higher.
-* colorlog 5.x is an interim version that will warn Python 2 users to
downgrade.
-* colorlog 4.x is the final version supporting Python 2.
+- colorlog 6.x requires Python 3.6 or higher.
+- colorlog 5.x is an interim version that will warn Python 2 users to
downgrade.
+- colorlog 4.x is the final version supporting Python 2.
-[colorama] is included as a required dependency and initialised when using
-colorlog on Windows.
+[colorama] is included as a dependency on Windows, where it is automatically
+initialised to support colored output.
This library is over a decade old and supported a wide set of Python versions
for most of its life, which has made it a difficult library to add new features
@@ -36,9 +36,9 @@
pip install colorlog
```
-Several Linux distributions provide official packages ([Debian], [Arch],
[Fedora],
-[Gentoo], [OpenSuse] and [Ubuntu]), and others have user provided packages
-([BSD ports], [Conda]).
+Several Linux distributions provide official packages ([Debian], [Arch],
+[Fedora], [Gentoo], [OpenSuse] and [Ubuntu]), and others have user provided
+packages ([BSD ports], [Conda]).
## Usage
@@ -46,27 +46,46 @@
import colorlog
handler = colorlog.StreamHandler()
-handler.setFormatter(colorlog.ColoredFormatter(
- '%(log_color)s%(levelname)s:%(name)s:%(message)s'))
+handler.setFormatter(colorlog.ColoredFormatter())
logger = colorlog.getLogger('example')
logger.addHandler(handler)
```
-The `ColoredFormatter` class takes several arguments:
+### Arguments
-- `format`: The format string used to output the message (required).
-- `datefmt`: An optional date format passed to the base class. See
[`logging.Formatter`][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`][Formatter].
+`ColoredFormatter` extends [`logging.Formatter`][formatter] and accepts the
+following arguments:
+
+- `fmt` *(default=`None`)*: A format string used to output the message. If
+ `None`, a default format string is selected based on `style` (e.g.
+ `%(log_color)s%(levelname)s:%(name)s:%(message)s` for `%` style).
+- `datefmt`, `style`, `validate`, `defaults`: see
+ [`logging.Formatter`][formatter].
+- `reset` *(default=`True`)*: Implicitly adds a color reset code to the
+ message output, unless the output already ends with one.
+- `log_colors` *(default=`None`)*: A mapping of record level names to color
+ names. If `None`, `colorlog.default_log_colors` is used.
+- `secondary_log_colors` *(default=`None`)*: A mapping of names to `log_colors`
+ style mappings, defining additional colors that can be used in format
strings.
+ If `None`, an empty mapping is used.
+- `stream` *(default=`None`)*: The stream being written to (e.g. `sys.stderr`).
+ Used to detect whether the output is a TTY. Colors are disabled automatically
+ on non-TTY streams unless `force_color` is set.
+- `no_color` *(default=`False`)*: Disable color output. Can also be set via the
+ `NO_COLOR` environment variable.
+- `force_color` *(default=`False`)*: Force color output even on non-TTY
streams.
+ Takes precedence over `no_color`. Can also be set via the `FORCE_COLOR`
+ environment variable.
+
+### Color escape 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.
-- `<name>_log_color`: Return another color based on the records level if the
formatter has secondary colors configured (see `secondary_log_colors` below).
+- `<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
@@ -76,7 +95,8 @@
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.
+- `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).
@@ -86,7 +106,7 @@
- `red`
- `green`
- `yellow`
-- `blue`,
+- `blue`
- `purple`
- `cyan`
- `white`
@@ -103,32 +123,33 @@
- `light_cyan`
- `light_white`
+In addition to pre-defined color names, you can use integers from 0 to 255 for
+256-color support (e.g. `fg_196`, `bg_42`).
+
## Examples

-The following code creates a `ColoredFormatter` for use in a logging setup,
-using the default values for each argument.
+The following snippet creates a `ColoredFormatter` for use in a logging setup,
+with a custom format string and log colors:
```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='%'
+ "DEBUG": "cyan",
+ "INFO": "green",
+ "WARNING": "yellow",
+ "ERROR": "red",
+ "CRITICAL": "red,bg_white",
+ }
)
```
+*See `docs/example.py` for full example script.*
+
### Using `secondary_log_colors`
Secondary log colors are a way to have more than one color that is selected
@@ -147,14 +168,14 @@
"%(log_color)s%(levelname)-8s%(reset)s
%(message_log_color)s%(message)s",
secondary_log_colors={
'message': {
- 'ERROR': 'red',
+ 'ERROR': 'red',
'CRITICAL': 'red'
}
}
)
```
-### With [`dictConfig`][dictConfig]
+### With [`dictConfig`][dictconfig]
```python
logging.config.dictConfig({
@@ -169,7 +190,7 @@
A full example dictionary can be found in `tests/test_colorlog.py`.
-### With [`fileConfig`][fileConfig]
+### With [`fileConfig`][fileconfig]
```ini
...
@@ -191,7 +212,7 @@
### With custom log levels
ColoredFormatter will work with custom log levels added with
-[`logging.addLevelName`][addLevelName]:
+[`logging.addLevelName`][addlevelname]:
```python
import logging, colorlog
@@ -252,23 +273,22 @@
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
-[addLevelName]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
-[Formatter]: http://docs.python.org/3/library/logging.html#logging.Formatter
-[tox]: http://tox.readthedocs.org/
-[Arch]: https://archlinux.org/packages/extra/any/python-colorlog/
-[BSD ports]: https://www.freshports.org/devel/py-colorlog/
+[addlevelname]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
+[arch]: https://archlinux.org/packages/extra/any/python-colorlog/
+[bsd ports]: https://www.freshports.org/devel/py-colorlog/
[colorama]: https://pypi.python.org/pypi/colorama
-[Conda]: https://anaconda.org/conda-forge/colorlog
-[Debian]:
[https://packages.debian.org/buster/python3-colorlog](https://packages.debian.org/buster/python3-colorlog)
-[Errbot]: http://errbot.io/
-[Fedora]: https://src.fedoraproject.org/rpms/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]: https://github.com/serge-sans-paille/pythran
-[Ubuntu]: https://launchpad.net/python-colorlog
-[zenlog]: https://github.com/ManufacturaInd/python-zenlog
-[structlog]: https://www.structlog.org/en/stable/
-[jsonlog]: https://github.com/borntyping/jsonlog
+[conda]: https://anaconda.org/conda-forge/colorlog
+[debian]: https://packages.debian.org/trixie/python3-colorlog
[dependents]:
https://github.com/borntyping/python-colorlog/network/dependents?package_id=UGFja2FnZS01MDk3NDcyMQ%3D%3D
+[dictconfig]:
http://docs.python.org/3/library/logging.config.html#logging.config.dictConfig
+[errbot]: http://errbot.io/
+[fedora]: https://src.fedoraproject.org/rpms/python-colorlog
+[fileconfig]:
http://docs.python.org/3/library/logging.config.html#logging.config.fileConfig
+[formatter]: http://docs.python.org/3/library/logging.html#logging.Formatter
+[gentoo]: https://packages.gentoo.org/packages/dev-python/colorlog
+[jsonlog]: https://github.com/borntyping/jsonlog
+[opensuse]:
http://rpm.pbone.net/index.php3?stat=3&search=python-colorlog&srodzaj=3
+[pythran]: https://github.com/serge-sans-paille/pythran
+[structlog]: https://www.structlog.org/en/stable/
+[ubuntu]: https://launchpad.net/python-colorlog
+[zenlog]: https://github.com/ManufacturaInd/python-zenlog
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-6.10.1/colorlog/formatter.py
new/colorlog-6.12.0/colorlog/formatter.py
--- old/colorlog-6.10.1/colorlog/formatter.py 2025-10-16 18:13:47.000000000
+0200
+++ new/colorlog-6.12.0/colorlog/formatter.py 2026-07-23 15:40:18.000000000
+0200
@@ -212,6 +212,12 @@
- fmt (dict):
A mapping of log levels (represented as strings, e.g. 'WARNING') to
format strings. (*New in version 2.7.0)
+
+ Levels that are not present in the mapping fall back to a default
+ formatter, so records logged at custom or unlisted levels are
+ formatted rather than raising a ``KeyError``. To customise the
+ fallback, provide a format string under the special ``"DEFAULT"``
+ key; otherwise the default format for the chosen ``style`` is used.
(All other parameters are the same as in colorlog.ColoredFormatter)
Example:
@@ -229,9 +235,15 @@
self.formatters = {
level: ColoredFormatter(fmt=f, **kwargs) for level, f in
fmt.items()
}
+ # Used for any level not present in ``fmt``. An explicit "DEFAULT"
entry
+ # takes precedence; otherwise fall back to the default format string.
+ self.default_formatter = self.formatters.get(
+ "DEFAULT", ColoredFormatter(**kwargs)
+ )
def format(self, record: logging.LogRecord) -> str:
- return self.formatters[record.levelname].format(record)
+ formatter = self.formatters.get(record.levelname,
self.default_formatter)
+ return formatter.format(record)
# Provided for backwards compatibility. The features provided by this subclass
are now
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-6.10.1/colorlog/tests/test_colorlog.py
new/colorlog-6.12.0/colorlog/tests/test_colorlog.py
--- old/colorlog-6.10.1/colorlog/tests/test_colorlog.py 2025-10-16
18:13:47.000000000 +0200
+++ new/colorlog-6.12.0/colorlog/tests/test_colorlog.py 2026-07-23
15:40:18.000000000 +0200
@@ -1,5 +1,6 @@
"""Test the colorlog.colorlog module."""
+import logging
import sys
import unittest.mock
@@ -100,6 +101,29 @@
},
)
+ def test_unlisted_level_uses_default(self):
+ """A level missing from fmt must not raise; it uses the fallback."""
+ logging.addLevelName(25, "NOTICE")
+ formatter = colorlog.LevelFormatter(fmt={"INFO": "%(message)s"})
+ record = logging.LogRecord(
+ "test", 25, "path", 1, "a notice message", None, None
+ )
+ assert "a notice message" in formatter.format(record)
+
+ def test_explicit_default_key(self):
+ """A 'DEFAULT' entry overrides the fallback format for unlisted
levels."""
+ logging.addLevelName(25, "NOTICE")
+ formatter = colorlog.LevelFormatter(
+ fmt={
+ "INFO": "%(message)s",
+ "DEFAULT": "DEFAULT: %(message)s",
+ }
+ )
+ record = logging.LogRecord(
+ "test", 25, "path", 1, "a notice message", None, None
+ )
+ assert "DEFAULT: a notice message" in formatter.format(record)
+
def test_ttycolorlog(create_and_test_logger, monkeypatch):
monkeypatch.setattr(sys.stderr, "isatty", lambda: True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-6.10.1/colorlog.egg-info/PKG-INFO
new/colorlog-6.12.0/colorlog.egg-info/PKG-INFO
--- old/colorlog-6.10.1/colorlog.egg-info/PKG-INFO 2025-10-16
18:14:00.000000000 +0200
+++ new/colorlog-6.12.0/colorlog.egg-info/PKG-INFO 2026-07-23
15:40:22.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: colorlog
-Version: 6.10.1
+Version: 6.12.0
Summary: Add colours to the output of Python's logging module.
Home-page: https://github.com/borntyping/python-colorlog
Author: Sam Clements
@@ -52,20 +52,20 @@
Add colours to the output of Python's `logging` module.
-* [Source on GitHub](https://github.com/borntyping/python-colorlog)
-* [Packages on PyPI](https://pypi.org/pypi/colorlog/)
+- [Source on GitHub](https://github.com/borntyping/python-colorlog)
+- [Package on PyPI](https://pypi.org/pypi/colorlog/)
## Status
-colorlog currently requires Python 3.6 or higher. Older versions (below 5.x.x)
+colorlog currently requires Python 3.6 or higher. Older versions (below 5.x.x)
support Python 2.6 and above.
-* colorlog 6.x requires Python 3.6 or higher.
-* colorlog 5.x is an interim version that will warn Python 2 users to
downgrade.
-* colorlog 4.x is the final version supporting Python 2.
+- colorlog 6.x requires Python 3.6 or higher.
+- colorlog 5.x is an interim version that will warn Python 2 users to
downgrade.
+- colorlog 4.x is the final version supporting Python 2.
-[colorama] is included as a required dependency and initialised when using
-colorlog on Windows.
+[colorama] is included as a dependency on Windows, where it is automatically
+initialised to support colored output.
This library is over a decade old and supported a wide set of Python versions
for most of its life, which has made it a difficult library to add new features
@@ -83,9 +83,9 @@
pip install colorlog
```
-Several Linux distributions provide official packages ([Debian], [Arch],
[Fedora],
-[Gentoo], [OpenSuse] and [Ubuntu]), and others have user provided packages
-([BSD ports], [Conda]).
+Several Linux distributions provide official packages ([Debian], [Arch],
+[Fedora], [Gentoo], [OpenSuse] and [Ubuntu]), and others have user provided
+packages ([BSD ports], [Conda]).
## Usage
@@ -93,27 +93,46 @@
import colorlog
handler = colorlog.StreamHandler()
-handler.setFormatter(colorlog.ColoredFormatter(
- '%(log_color)s%(levelname)s:%(name)s:%(message)s'))
+handler.setFormatter(colorlog.ColoredFormatter())
logger = colorlog.getLogger('example')
logger.addHandler(handler)
```
-The `ColoredFormatter` class takes several arguments:
+### Arguments
-- `format`: The format string used to output the message (required).
-- `datefmt`: An optional date format passed to the base class. See
[`logging.Formatter`][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`][Formatter].
+`ColoredFormatter` extends [`logging.Formatter`][formatter] and accepts the
+following arguments:
+
+- `fmt` *(default=`None`)*: A format string used to output the message. If
+ `None`, a default format string is selected based on `style` (e.g.
+ `%(log_color)s%(levelname)s:%(name)s:%(message)s` for `%` style).
+- `datefmt`, `style`, `validate`, `defaults`: see
+ [`logging.Formatter`][formatter].
+- `reset` *(default=`True`)*: Implicitly adds a color reset code to the
+ message output, unless the output already ends with one.
+- `log_colors` *(default=`None`)*: A mapping of record level names to color
+ names. If `None`, `colorlog.default_log_colors` is used.
+- `secondary_log_colors` *(default=`None`)*: A mapping of names to `log_colors`
+ style mappings, defining additional colors that can be used in format
strings.
+ If `None`, an empty mapping is used.
+- `stream` *(default=`None`)*: The stream being written to (e.g. `sys.stderr`).
+ Used to detect whether the output is a TTY. Colors are disabled automatically
+ on non-TTY streams unless `force_color` is set.
+- `no_color` *(default=`False`)*: Disable color output. Can also be set via the
+ `NO_COLOR` environment variable.
+- `force_color` *(default=`False`)*: Force color output even on non-TTY
streams.
+ Takes precedence over `no_color`. Can also be set via the `FORCE_COLOR`
+ environment variable.
+
+### Color escape 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.
-- `<name>_log_color`: Return another color based on the records level if the
formatter has secondary colors configured (see `secondary_log_colors` below).
+- `<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
@@ -123,7 +142,8 @@
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.
+- `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).
@@ -133,7 +153,7 @@
- `red`
- `green`
- `yellow`
-- `blue`,
+- `blue`
- `purple`
- `cyan`
- `white`
@@ -150,32 +170,33 @@
- `light_cyan`
- `light_white`
+In addition to pre-defined color names, you can use integers from 0 to 255 for
+256-color support (e.g. `fg_196`, `bg_42`).
+
## Examples

-The following code creates a `ColoredFormatter` for use in a logging setup,
-using the default values for each argument.
+The following snippet creates a `ColoredFormatter` for use in a logging setup,
+with a custom format string and log colors:
```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='%'
+ "DEBUG": "cyan",
+ "INFO": "green",
+ "WARNING": "yellow",
+ "ERROR": "red",
+ "CRITICAL": "red,bg_white",
+ }
)
```
+*See `docs/example.py` for full example script.*
+
### Using `secondary_log_colors`
Secondary log colors are a way to have more than one color that is selected
@@ -194,14 +215,14 @@
"%(log_color)s%(levelname)-8s%(reset)s
%(message_log_color)s%(message)s",
secondary_log_colors={
'message': {
- 'ERROR': 'red',
+ 'ERROR': 'red',
'CRITICAL': 'red'
}
}
)
```
-### With [`dictConfig`][dictConfig]
+### With [`dictConfig`][dictconfig]
```python
logging.config.dictConfig({
@@ -216,7 +237,7 @@
A full example dictionary can be found in `tests/test_colorlog.py`.
-### With [`fileConfig`][fileConfig]
+### With [`fileConfig`][fileconfig]
```ini
...
@@ -238,7 +259,7 @@
### With custom log levels
ColoredFormatter will work with custom log levels added with
-[`logging.addLevelName`][addLevelName]:
+[`logging.addLevelName`][addlevelname]:
```python
import logging, colorlog
@@ -299,23 +320,22 @@
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
-[addLevelName]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
-[Formatter]: http://docs.python.org/3/library/logging.html#logging.Formatter
-[tox]: http://tox.readthedocs.org/
-[Arch]: https://archlinux.org/packages/extra/any/python-colorlog/
-[BSD ports]: https://www.freshports.org/devel/py-colorlog/
+[addlevelname]:
https://docs.python.org/3/library/logging.html#logging.addLevelName
+[arch]: https://archlinux.org/packages/extra/any/python-colorlog/
+[bsd ports]: https://www.freshports.org/devel/py-colorlog/
[colorama]: https://pypi.python.org/pypi/colorama
-[Conda]: https://anaconda.org/conda-forge/colorlog
-[Debian]:
[https://packages.debian.org/buster/python3-colorlog](https://packages.debian.org/buster/python3-colorlog)
-[Errbot]: http://errbot.io/
-[Fedora]: https://src.fedoraproject.org/rpms/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]: https://github.com/serge-sans-paille/pythran
-[Ubuntu]: https://launchpad.net/python-colorlog
-[zenlog]: https://github.com/ManufacturaInd/python-zenlog
-[structlog]: https://www.structlog.org/en/stable/
-[jsonlog]: https://github.com/borntyping/jsonlog
+[conda]: https://anaconda.org/conda-forge/colorlog
+[debian]: https://packages.debian.org/trixie/python3-colorlog
[dependents]:
https://github.com/borntyping/python-colorlog/network/dependents?package_id=UGFja2FnZS01MDk3NDcyMQ%3D%3D
+[dictconfig]:
http://docs.python.org/3/library/logging.config.html#logging.config.dictConfig
+[errbot]: http://errbot.io/
+[fedora]: https://src.fedoraproject.org/rpms/python-colorlog
+[fileconfig]:
http://docs.python.org/3/library/logging.config.html#logging.config.fileConfig
+[formatter]: http://docs.python.org/3/library/logging.html#logging.Formatter
+[gentoo]: https://packages.gentoo.org/packages/dev-python/colorlog
+[jsonlog]: https://github.com/borntyping/jsonlog
+[opensuse]:
http://rpm.pbone.net/index.php3?stat=3&search=python-colorlog&srodzaj=3
+[pythran]: https://github.com/serge-sans-paille/pythran
+[structlog]: https://www.structlog.org/en/stable/
+[ubuntu]: https://launchpad.net/python-colorlog
+[zenlog]: https://github.com/ManufacturaInd/python-zenlog
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/colorlog-6.10.1/setup.py new/colorlog-6.12.0/setup.py
--- old/colorlog-6.10.1/setup.py 2025-10-16 18:13:47.000000000 +0200
+++ new/colorlog-6.12.0/setup.py 2026-07-23 15:40:18.000000000 +0200
@@ -2,7 +2,7 @@
setup(
name="colorlog",
- version="6.10.1",
+ version="6.12.0",
description="Add colours to the output of Python's logging module.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",