Changelogs » Coloredlogs

PyUp Safety actively tracks 382,903 Python packages for vulnerabilities and notifies you when to upgrade.



  Bug fix: Restore :class:`.StandardErrorHandler` functionality
  The :class:`.StandardErrorHandler` class is responsible for dynamically
  resolving (looking up the value of) sys.stderr for each logged message instead
  of once when :func:`coloredlogs.install()` is called.
  This was unintentionally broken by changes in `release 14.1`_.
  .. _Release 15.0.1:


  Don't enable system logging on MacOS and Windows anymore.
  This is backwards incompatible (which is why I'm bumping the major version
  number) however the old behavior has been reported to be rather problematic
  (see :func:`~coloredlogs.syslog.is_syslog_supported()` for details) so this
  seems like the best choice.
  .. _Release 15.0:


  Merged pull request `89`_ which enhances :func:`coloredlogs.install()` to
  preserve the filters on handlers that are replaced by :pypi:`coloredlogs`.
  .. _Release 14.3:
  .. _89:


  Honor the ``$NO_COLOR`` environment variable as suggested in issue `88`_.
  .. _Release 14.2:
  .. _88:


  **Bug fixes:**
  - Don't allow interactive terminal detection to disable colored text when
  colored text is being forced by the caller (reported in issue `84`_).
  - Automatically disable colored text when logging output is being redirected to
  a file in such a way that it actually works 😬 (reported in issue `100`_).
  **Other changes:**
  - Start testing on PyPy 3 (because why not?)
  .. _Release 14.1:
  .. _84:
  .. _100:


  Integrate native Windows 10 support for ANSI escape sequences (`71`_, `72`_).
  Native support for ANSI escape sequences was added to Windows 10 after its
  initial release, specifically in release 10.0.14393. I've now updated
  :pypi:`coloredlogs` and :pypi:`humanfriendly` to detect and enable this "new"
  native support.
  Windows 10 seems to comprise the majority of Windows installations worldwide so
  in the interest of "looking forward" I've decided to drop the :pypi:`colorama`
  requirement, given that it has now become a minority use case.
  Hopefully most existing users will not experience any regression because they
  previously installed :pypi:`colorama` already, and when available it will still
  be used. However new installations on older Windows systems now require users
  to install :pypi:`colorama` separately. This has been documented in the readme
  in an attempt to minimize resulting confusion.
  PS. In case anyone is wondering: I decided that giving a major Windows support
  update in :pypi:`coloredlogs` the version 13.0 was asking for trouble, so I
  decided not to do that 😇.
  .. _Release 14.0:
  .. _71:
  .. _72:


  Two backwards incompatible changes prompted another major version bump:
  - Merged pull request `80`_ that drops support for Python 3.4 which
  has gone end-of-life and now represents less than 1% of PyPI downloads.
  - Improved compatibility with the Python standard library by changing
  the order of positional arguments received by the initializer of the
  :class:`~coloredlogs.ColoredFormatter` class (as suggested in `64`_
  and `75`_).
  .. _Release 12.0:
  .. _80:
  .. _64:
  .. _75:


  - Add support for the ``%(username)s`` field (requested in `76`_) and properly
  document supported custom fields.
  - Consistently use ``console`` highlighting in documentation.
  - Fix a broken link in the readme.
  .. _Release 11.3:
  .. _76:


  Merge pull request `79`_ which adds support for Python 3.8.
  .. _Release 11.2:
  .. _79:


  Starting with the previous release I've resolved to try and tackle the large
  number of open issues after an unplanned hiatus from the development and
  maintenance of my open source projects, so here are some more bug fixes:
  - Fix support for custom log record factories and add a test to avoid
  regressions (`47`_, `59`_).
  - Change ``make screenshots`` to be Python 3 compatible and document
  additional requirements (`65`_).
  .. _Release 11.1:
  .. _59:
  .. _65:


  This is a maintenance release that drops Python 2.6 support, adds Python 3.7
  support and merges quite a few minor pull requests. The major version number
  was bumped because of the compatibility changes.
  **Merged pull requests:**
  - `58`_: Don't import :mod:`coloredlogs` if ``$COLOREDLOGS_AUTO_INSTALL`` is
  set but empty.
  - `60`_: Fix :pypi:`flake8` messages to help stabilize Travis CI builds.
  - `61`_: Drop support for Python 2.6 to help stabilize Travis CI builds.
  - `62`_: Use SVG badge in README for consistency.
  - `69`_: Handle negative-offset timezones in tests.
  - `70`_: Use :func:`subprocess.check_call()` in the test suite to ensure that
  external commands succeed.
  - `74`_: Fix :exc:`~exceptions.TypeError` on MacOS on Python 3 in the
  :mod:`~coloredlogs.converter` module.
  **Other changes:**
  - Start testing on Python 3.7 (and document compatibility).
  - Workaround Python 3.7 regression in test suite.
  - Update ``Makefile`` to use Python 3 for local development.
  - Merge MacOS on Travis CI fixes from :pypi:`humanfriendly`.
  .. _Release 11.0:
  .. _58:
  .. _60:
  .. _61:
  .. _62:
  .. _69:
  .. _70:
  .. _74:


  Proper format string parsing, support for ``style='{'`` (`11`_, `17`_, `52`_).
  Until now coloredlogs has required differently colored fields in logging format
  strings to be delimited by whitespace, leading to various issues:
  - Back in December 2015 issue `11`_ was reported by someone who had expected
  to be able to style fields without whitespace in between differently.
  - Until `52`_ was merged (released as 9.2 in April 2018) any whitespace would
  be collapsed to a single space, simply as a side effect of splitting on
  - This implementation was so naive that it didn't support whitespace as a
  padding character in ``%()`` formatting directives, because it wasn't able to
  distinguish formatting directives from surrounding text.
  In order to properly fix `11`_ I'm now introducing a very different approach
  that does distinguish formatting directives from their surrounding text, which
  means whitespace is no longer required. However in order to reduce the
  conceptual incompatibilities between the old versus new approach whitespace is
  still significant, as follows:
  1. First the logging format string is separated into formatting directives
  versus surrounding text (which means whitespace used as a padding character
  in a ``%()`` formatting directive is considered to be part of the formatting
  directive, as it should).
  2. Then formatting directives and surrounding text are grouped based on
  whitespace delimiters (in the surrounding text).
  3. For each group styling is selected as follows:
  1. If the group contains a single formatting directive that has a style
  defined then the whole group is styled accordingly. This is the behavior
  which provides (some level of) conceptual backwards compatibility.
  2. If the group contains multiple formatting directives that have styles
  defined then each formatting directive is styled individually and
  surrounding text isn't styled (this behavior is backwards incompatible
  but arguably an improvement over the old behavior).
  While I was working on the improved format string parsing I figured it was
  easiest to include support for ``style='{'`` (requested in `17`_) from the
  start in the new implementation, given that I was redoing the affected code
  .. _Release 10.0:
  .. _11:
  .. _17:


  Bug fix: Restore MacOS compatibility after publishing release 9.3.
  The following build failure became apparent to me just minutes after
  publishing release 9.3 so I decided to change the implementation:
  .. _Release 9.3.1:


  Enable flexible millisecond formatting using the ``%f`` directive (`45`_).
  .. _Release 9.3:
  .. _45:


  - Merged pull request `47`_: Switch to ``logging.getLogRecordFactory()``. In
  the merge commit I added a small performance enhancement by checking for the
  existence of ``logging.getLogRecordFactory()`` just once, when a
  ``ColoredFormatter`` object is instantiated.
  - Merged pull request `52`_: Don't change whitespace in format strings. In the
  merge commit I promoted the inline function to an instance method so that it
  can be reused by sub classes of ``ColoredFormatter``.
  .. _Release 9.2:
  .. _47:
  .. _52:


  - Added ``license`` key to ```` script (`53`_).
  - Added this changelog (requested in `55`_).
  .. _Release 9.1:
  .. _53:
  .. _55:


  Added support for background colors and 256 color mode (`35`_).
  Most of the changes required for this were actually implemented in the
  humanfriendly_ package (see issue `35`_). The changes in coloredlogs
  are mostly related to the ANSI to HTML conversion.
  One unrelated change was made, that was to use faint green for the ``SPAM`` log
  level (to distinguish it from ``DEBUG``).
  New features in ANSI to HTML conversion:
  - Support for bright and faint colors.
  - Support for underlined, strike-through and inverse text styles.
  Bug fixes in ANSI to HTML conversion:
  - The scheme of URLs is no longer stripped from visible output.
  - Support for ``\x1b[m`` as a short hand for ``\x1b[0m`` (I only learned about
  this today when I didn't understand the empty ANSI escape sequence at the end
  of each line emitted by ``hg log``).
  - Ensure that the pattern for URLs doesn't capture ANSI sequences.
  - Documenting how it all works. This will follow in the next commit
  which is going to be a rather big one (hence why I see some value
  in keeping it separate from the implementation changes).
  Miscellaneous changes:
  - Add installation instructions to readme.
  - Improve screenshots in documentation.
  - Automate taking of screen shots :-).
  .. _Release 9.0:
  .. _35:
  .. _humanfriendly:


  Set the default date format in a new ``formatTime()`` method (`42`_).
  I decided to bump the major version number because this change is technically
  backwards incompatible, even though it concerns a minor detail (``datefmt``
  being set to its default value in the initializer). Then again, this change
  does improve compatibility with the behavior of the ``logging.Formatter`` class
  in Python's standard library, so there's that :-).
  .. _Release 8.0:
  .. _42:


  Bug fix for ``coloredlogs --demo`` so that it always displays the ``DEBUG`` message (`41`_).
  .. _Release 7.3.3:
  .. _41:


  Bug fixes and improvements to ANSI to HTML conversion:
  - Make sure that conversion of empty input produces no output.
  - Strip bogus ``^D`` from output captured on MacOS.
  - Increase test coverage on MacOS via Travis CI.
  .. _Release 7.3.2:


  Bug fix for ``get_install_requires()`` in ```` script (fixes `43`_).
  .. _Release 7.3.1:
  .. _43:


  Added support for the ``SUCCESS`` log level (related to `27`_ and `verboselogs
  issue 4 <>`_).
  .. _Release 7.3:
  .. _27:


  Merged pull requests `34`_, `37`_ and `38`_:
  - Include the files needed to generate the Sphinx documentation in source distributions published to PyPI (`34`_).
  - Improve documentation by removing usage of deprecated ``logger.warn()`` function (`37`_).
  - Improve documentation by using module ``__name__`` variable for logger name (`38`_).
  - Also fixed the test suite after verboselogs 1.7 was released.
  .. _Release 7.2:
  .. _34:
  .. _37:
  .. _38:


  Make it easy to output milliseconds and improve documentation on this (`16`_).
  .. _Release 7.1:
  .. _16:


  Try to improve robustness during garbage collection (related to `33`_).
  .. _Release 7.0.1:
  .. _33:


  This release improves the robustness of ANSI to HTML conversion:
  - Don't break ANSI to HTML conversion on output encoding errors.
  - Gracefully handle unsupported colors in converter module.
  - Make it even easier to integrate with ``cron``.
  - Improved the HTML encoding of whitespace.
  - Wrap generated HTML in ``<code>`` by default.
  - Reduced the size of generated HTML (really CSS).
  - Reduced internal duplication of constants.
  .. _Release 7.0:


  Mention ``colorama.init()`` in the documentation (fixes `25`_).
  .. _Release 6.4:
  .. _25:


  Bug fix: Avoid ``copy.copy()`` deadlocks (fixes `29`_).
  This was a rather obscure issue and I expect this not to to affect most users,
  but the reported breakage was definitely not intended, so it was a bug I wanted
  to fix.
  .. _Release 6.3:
  .. _29:


  Enable runtime patching of ``sys.stderr`` (related to `30`_ and `31`_).
  .. _Release 6.2:
  .. _30:
  .. _31:


  - Bug fix: Adjust logger level in ``set_level()``, ``increase_verbosity()``, etc. (this is a follow up to release 6.0).
  - Bug fix: Never enable system logging on Windows.
  - Increase test coverage (using mocking).
  - Document Python 3.6 support.
  .. _Release 6.1:


  Two backwards incompatible changes were made:
  - Changed log level handling in ``coloredlogs.install()``.
  - Changed the default system logging level from ``DEBUG`` to ``INFO``. To make
  it easier to restore the old behavior, ``coloredlogs.install(syslog='debug')``
  is now supported.
  The old and problematic behavior was as follows:
  - ``coloredlogs.install()`` would unconditionally change the log level of the
  root logger to ``logging.NOTSET`` (changing it from the root logger's default
  level ``logging.WARNING``) and the log levels of handler(s) would control
  which log messages were actually emitted.
  - ``enable_system_logging()`` would never change the root logger's log level,
  which meant that when ``enable_system_logging()`` was used in isolation from
  ``install()`` the default log level would implicitly be set to
  ``logging.WARNING`` (the default log level of the root logger).
  Over the years I've gotten a lot of feedback about the log level handling in
  the coloredlogs package, it was clearly the number one cause of confusion for
  users. Here are some examples:
  My hope is that with the changes I've made in the past days, the experience for
  new users will be more 'Do What I Mean' and less 'What The Fuck is Going On
  Here?!' :-). Of course only time (and feedback, or lack thereof) will tell
  whether I've succeeded.
  .. _Release 6.0:


  Merged pull request `19`_: Automatically call ``coloredlogs.install()`` if
  While merging this pull request and writing tests for it I changed
  the implementation quite a bit from the original pull request:
  - The environment variable was renamed from ``COLOREDLOGS_AUTOUSE`` to
  ``COLOREDLOGS_AUTO_INSTALL`` (in order to make it consistent with the other
  environment variables) and added to the documentation.
  - The ``coloredlogs.pth`` file was changed in order to reduce the amount of
  code required inside the ``*.pth`` file as much as possible and create room
  to grow this feature if required, by extending ``auto_install()``. I
  seriously dislike writing out complex code in a single line, especially when
  dealing with Python code :-).
  - The ``coloredlogs.pth`` file has been added to ```` to make sure
  that ``python sdist`` copies the ``*.pth`` file into the source
  distribution archives published to PyPI.
  - The ```` script was changed to figure out the location of the
  ``lib/pythonX.Y/site-packages`` directory using distutils instead of 'hard
  coding' the site-packages name (which I dislike for various reasons).
  - The ```` script was changed to preserve compatibility with universal
  wheel distributions using what looks like an undocumented hack found through
  trial and error (the other hacks I found were much worse :-). I ran into this
  incompatibility when running the tests under ``tox``, which runs ``pip
  install`` under the hood, which in turn runs ``python bdist_wheel``
  under the hood to enable wheel caching.
  .. _Release 5.2:
  .. _19:


  - Starting from this release wheel distributions are published to PyPI.
  - Refactored makefile and setup script (checkers, docs, wheels, twine, etc).
  - Replaced ```` with ```` everywhere.
  .. _Release 5.1.1:


  - Bug fix: Enable command capturing on MacOS (fixes `12`_).
  - Add styles for the ``SPAM`` and ``NOTICE`` levels added by my verboselogs_ package.
  - Set up automated MacOS tests on Travis CI.
  - Documented Python 3.5 support.
  .. _Release 5.1:
  .. _12:


  - Remove ``ColoredStreamHandler`` and related functionality, thereby breaking backwards compatibility.
  - Remove Vim syntax script (impossible given user defined log formats :-).
  - Improve test coverage.
  .. _Release 5.0:


  Enable reconfiguration (also: get rid of global root handler).
  .. _Release 4.0:


  - Bug fix: Never install duplicate syslog handlers.
  - Added ``walk_propagation_tree()`` function (not useful in isolation :-).
  - Added ``find_handler()`` function (still not very useful in isolation).
  .. _Release 3.5:


  Make it very easy to enable system logging.
  .. _Release 3.4:


  Easy to use UNIX system logging?! I know this is unrelated to the name of this
  project - refer to the added documentation for more on that :-).
  .. _Release 3.3:


  - Enable ``%(programname)s`` based on ``sys.argv[0]``.
  - Increase test coverage.
  .. _Release 3.2:


  Bug fix: Don't use bold font on Windows (follow up to previous change).
  .. _Release 3.1.4:


  Bug fix: Don't use bold font on Windows (not supported). For future reference,
  I found this issue here:
  .. _Release 3.1.3:


  Bug fix for log format colorization (fixes `9`_).
  Rationale: I'm not validating the format, I just want to extract the referenced
  field names, so looking for ``%(..)`` without a trailing type specifier (and
  optional modifiers) is fine here.
  .. _Release 3.1.2:
  .. _9:


  Fixed broken Colorama reference in ``README.rst`` because it breaks the reStructuredText rendering on PyPI.
  .. _Release 3.1.1:


  Depend on and use Colorama on Windows (as suggested in `2`_). I can't actually
  test this because I don't have access to a Windows system, but I guess some day
  someone will complain if this doesn't work as intended ;-).
  .. _Release 3.1:
  .. _2:


  Major rewrite: Added ``ColoredFormatter``, deprecated ``ColoredStreamHandler``.
  - Fixed `2`_ by switching from ``connected_to_terminal()`` to
  ``terminal_supports_colors()`` (the latter understands enough about Windows
  to know it doesn't support ANSI escape sequences).
  - Fixed `6`_ by adding support for user defined formats (even using a custom
  filter to enable the use of ``%(hostname)s`` :-).
  - Fixed `7`_ by adding support for user defined formats and making
  ``coloredlogs.install()`` an almost equivalent of ``logging.basicConfig()``.
  This rewrite mostly resolves `pip-accel issue 59
  <>`_. Basically all that's
  missing is a configuration option in pip-accel to make it easier to customize
  the log format, although that can now be done by setting
  .. _Release 3.0:
  .. _2:
  .. _6:
  .. _7:


  - Backwards incompatible: Change ``ansi2html`` to ``coloredlogs --convert`` (see `8`_).
  - Implement and enforce PEP-8 and PEP-257 compliance.
  - Change Read the Docs links to use HTTPS.
  - Move ad-hoc coverage configuration from ``Makefile`` to ``.coveragerc``.
  .. _Release 2.0:
  .. _8:


  - Bug fix for obscure ``UnicodeDecodeError`` in ```` (only on Python 3).
  - Document PyPy as a supported (tested) Python implementation.
  .. _Release 1.0.1:


  - Move ``coloredlogs.ansi_text()`` to ``humanfriendly.ansi_wrap()``.
  - Update ```` to add trove classifiers and stop importing ``__version__``.
  - Start linking to Read the Docs as the project homepage.
  .. _Release 1.0:


  - Merged pull request `5`_ which makes the severity to color mapping configurable.
  - Added support for bold / faint / underline / inverse / strike through text
  styles. This extends the changes in pull request `5`_ into a generic
  severity ↔ color / style mapping and adds support for five text styles.
  - Added a coverage badge to the readme.
  .. _Release 0.8:
  .. _5:


  Bug fix: Restore Python 3.4 compatibility.
  .. _Release 0.7.1:


  - First stab at a proper test suite (already >= 90% coverage)
  - Prepare to publish documentation on Read the Docs.
  .. _Release 0.7:


  Added ``decrease_verbosity()`` function (and simplify ``increase_verbosity()``).
  .. _Release 0.6:


  - Merge pull request `4`_ adding Python 3 compatibility.
  - Start using Travis CI (so I don't accidentally drop Python 3 compatibility).
  - Document supported Python versions (2.6, 2.7 & 3.4).
  - Move demo code to separate ``coloredlogs.demo`` module.
  .. _Release 0.5:
  .. _4:


  Make the ``ansi2html`` command a bit more user friendly.
  .. _Release 0.4.9:


  Make it possible to use ``/etc/debian_chroot`` instead of ``socket.gethostname()``.
  .. _Release 0.4.8:


  Added ``is_verbose()`` function (another easy shortcut :-).
  .. _Release 0.4.7:


  Added ``increase_verbosity()`` function (just an easy shortcut).
  .. _Release 0.4.6:


  ``ColoredStreamHandler`` now supports filtering on log level.
  .. _Release 0.4.5:


  Bug fix: Protect against ``sys.stderr.isatty()`` not being defined.
  .. _Release 0.4.4:


  Change: Show the logger name by default.
  .. _Release 0.4.3:


  Added ``coloredlogs.install()`` function.
  .. _Release 0.4.2:


  Bug fix for ``ansi2html``: Don't leave ``typescript`` files behind.
  .. _Release 0.4.1:


  Added ``ansi2html`` program to convert colored text to HTML.
  .. _Release 0.4:


  Bug fix: Support Unicode format strings (issue `3`_).
  .. _Release 0.3.1:
  .. _3:


  Merge pull request `1`_: Refactor timestamp and name formatting into their own
  methods so callers can override the format. I made the following significant
  changes during merging:
  - Added docstrings & mention subclassing in ````
  - Don't call ``os.getpid()`` when the result won't be used.
  - Don't call ``render_*()`` methods when results won't be used.
  .. _Release 0.3:
  .. _1:


  - Change text styles (seems like an improvement to me)
  - Integration with my just released verboselogs_ module.
  - Improve the readme (with screenshots).
  - Add PyPI link to ````.
  - Add URL to ````.
  - Vim syntax mode for colored logs!
  .. _Release 0.2:
  .. _verboselogs: