Skip to content

Commit

Permalink
Disable logging propagation, use current stderr as output (#541)
Browse files Browse the repository at this point in the history
1. Propagation can create duplicate messages if the root logger has stdout/stderr handlers set (as observed in #540).
2. `StreamHandler()` uses the `sys.stderr` value as of the time of handler creation, `_StderrHandler()` always use the current value of `sys.stderr`.
  • Loading branch information
leogama committed Aug 11, 2022
1 parent 8034b88 commit 1d3e8cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dill/logger.py
Expand Up @@ -209,8 +209,9 @@ def format(self, record):
return super().format(record)

logger = logging.getLogger('dill')
logger.propagate = False
adapter = TraceAdapter(logger)
stderr_handler = logging.StreamHandler()
stderr_handler = logging._StderrHandler()
adapter.addHandler(stderr_handler)

def trace(arg: Union[bool, TextIO, str, os.PathLike] = None, *, mode: str = 'a') -> NoReturn:
Expand Down

0 comments on commit 1d3e8cf

Please sign in to comment.