I'm using logzero
in a Python script which calls library code. The library code uses the standard Python logging
module.
Is there a nice way to have logging
initialised so that the output matches what I get from logzero
? I like that logzero
gives me a pre-defined, coloured format without boilerplate setup code, but dislike that logs from library code aren't caught. I'm just logging to the console, nothing fancy.
Without any boilerplate setup, the following only outputs the line from logzero
, not the one from logging
(and the same is true if logs are sent to logging
from a separate file/module).
import logzero
import logging
log = logging.getLogger(__name__)
logzero.logger.info('Hi from logzero')
log.info('Hi from logging')
I've worked around this by initialising logging
in my main script with a logging.basicConfig()
line defining a similar format to logzero
but I feel like there is a nicer way I've missed.
question from:
https://stackoverflow.com/questions/65903898/python-logzero-standard-logging 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…