Skip to content

Commit

Permalink
Disable logging propagation, use current stderr as output
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 uqfoundation#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 authored Aug 11, 2022
1 parent 8034b88 commit e36aee2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dill/logger.py
Original file line number Diff line number Diff line change
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 e36aee2

Please sign in to comment.