diff --git a/coloredlogs/__init__.py b/coloredlogs/__init__.py index d279180..5c072d2 100644 --- a/coloredlogs/__init__.py +++ b/coloredlogs/__init__.py @@ -433,8 +433,13 @@ def install(level=None, **kw): if use_colors or use_colors is None: use_colors = terminal_supports_colors(stream) # Create a stream handler. + # preserve any filters the current handler might have + 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 + 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'))