[issue33897] Add a restart option to logging.basicConfig()

Vinay Sajip report at bugs.python.org
Fri Jun 22 03:39:11 EDT 2018


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

You would just clear all handlers added to the root logger before calling the existing code:

    try:
        # new code to be added, not tested
        for h in root.handlers[:]:
            root.removeHandler(h)
            h.close()
        # existing code
        if len(root.handlers) == 0:
            handlers = kwargs.pop("handlers", None)

Of course, test case, documentation etc. needs to be added as well.

Not sure if "restart" is the best name, as it implies more than we're doing here. Similarly for "reset". IMO "force" might be better as the keyword argument name. Raymond, what do you think about "force" from a pedagogical point of view?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33897>
_______________________________________


More information about the Python-bugs-list mailing list