The logger in the project sets the basic configuration for the root logger and if a user intends to use his own logger there might be issues (related to the way the config inheritence works in the logging module):
adding a logger handler makes the logs double up with the root loggers logs from the jupyter_black setup
the basicConfig is already set up by jupyter_black (if imported first in the user's project) so the user cannot setup his own logger that way
I propose to add a simple flag to the load function that disables the logger for the convenience of the user:
def load(
...
disable_logger: bool = False,
...) -> None:
if disable_logger:
rootLogger = logging.getLogger()
for handler in rootLogger.handlers:
rootLogger.removeHandler(handler)
As a user trying to use my logger with a custom handler I tried:
changing the verbosity flag up to logging.CRITICAL
swaping the order of the imports
using the root logger directly
The one thing that I found that works is the snippet i presented above and I think it would reasonable to take the onus of disarming the root logger off the user and enable this in the jupyter_black setup itself since the logs from the formatter are something a user interested in detailed logging might want to have an easier control over.
Please make sure you've taken these steps before submitting a new issue:
[x] Include the Python and jupyter-black version in your issue
[x] Ensure you're running a supported version of Python
[ ] Run jupyter-black in debug mode if applicable and include
relevant output
[x] Search the existing (including closed) issues
[x] Please use codeblocks for any code, config, program output, etc.
My Issue
The logger in the project sets the basic configuration for the root logger and if a user intends to use his own logger there might be issues (related to the way the config inheritence works in the
logging
module):jupyter_black
setupbasicConfig
is already set up byjupyter_black
(if imported first in the user's project) so the user cannot setup his own logger that wayI propose to add a simple flag to the load function that disables the logger for the convenience of the user:
WHYT
As a user trying to use my logger with a custom handler I tried:
verbosity
flag up tologging.CRITICAL
The one thing that I found that works is the snippet i presented above and I think it would reasonable to take the onus of disarming the root logger off the user and enable this in the
jupyter_black
setup itself since the logs from the formatter are something a user interested in detailed logging might want to have an easier control over.Please make sure you've taken these steps before submitting a new issue: