Skip to content

Commit

Permalink
Fixed problem when handler is None
Browse files Browse the repository at this point in the history
  • Loading branch information
eblis committed Apr 27, 2020
1 parent 726c4b1 commit 95e6c76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions coloredlogs/__init__.py
Expand Up @@ -434,11 +434,12 @@ def install(level=None, **kw):
use_colors = terminal_supports_colors(stream)
# Create a stream handler.
# preserve any filters the current handler might have
preserved_filters = handler.filters
preserved_filters = handler.filters if handler else None
handler = logging.StreamHandler(stream) if stream else StandardErrorHandler()
handler.setLevel(level)
# and add them back to the new handler
handler.filters = preserved_filters
if preserved_filters:
handler.filters = preserved_filters
# Prepare the arguments to the formatter, allowing the caller to
# customize the values of `fmt', `datefmt' and `style' as desired.
formatter_options = dict(fmt=kw.get('fmt'), datefmt=kw.get('datefmt'))
Expand Down

0 comments on commit 95e6c76

Please sign in to comment.