New submission from Govinda Totla <[email protected]>:
The logging module allows you set a custom Logger class as the default logger.
However, this breaks when we try to copy the logger which was created before
setting the logger class
```
import copy
import logging
# Some module we don't control
oldLogger = logging.getLogger("abc")
# Some module where we want to change over to custom logging
class MyLogger(logging.Logger):
pass
# Override the manager, root, etc., so everything uses our class
logging.setLoggerClass(MyLogger)
logging.root = root = MyLogger("", logging.WARNING)
logging.Logger.manager = logging.Manager(root)
newLogger = logging.getLogger("def")
# Later on this happens, which internally calls __reduce__
copy.deepcopy(oldLogger)
```
----------
components: Library (Lib)
messages: 414750
nosy: govinda18
priority: normal
severity: normal
status: open
title: Logger with a custom class breaks on copy
type: crash
versions: Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46957>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com