Fix logging configuration and harmonize loggers use
While testing kafka components inside the docker-compose environement, I noticed some logger outputs were missing (notably the journal publisher ones).
That diff fixes the logger configurations by using logging.basicConfig
in the
cli entrypoint. All loggers from swh-journal will inherit from this default
configuration.
Also, harmonize the way a logger is created: prefer to do that in class constructor instead of doing it at module level.
Migrated from D1357 (view on Phabricator)
Merge request reports
Activity
Build has FAILED
Link to build: https://jenkins.softwareheritage.org/job/DJNL/job/tox/105/ See console output for more information: https://jenkins.softwareheritage.org/job/DJNL/job/tox/105/console
Build has FAILED
Link to build: https://jenkins.softwareheritage.org/job/DJNL/job/tox/113/ See console output for more information: https://jenkins.softwareheritage.org/job/DJNL/job/tox/113/console
Build has FAILED
Link to build: https://jenkins.softwareheritage.org/job/DJNL/job/tox/114/ See console output for more information: https://jenkins.softwareheritage.org/job/DJNL/job/tox/114/console
Build has FAILED
Link to build: https://jenkins.softwareheritage.org/job/DJNL/job/tox/115/ See console output for more information: https://jenkins.softwareheritage.org/job/DJNL/job/tox/115/console
I'm fine with harmonizing all loggers to use
logging.getLogger(__name__)
, but I'm not convinced by the "object-level" logger pattern. In this specific instance it looks like it's causing issues because we're mocking a class.If a diff is touching all logging statements, we should also make sure to use
logger.debug("format string", argument1, argument2)
instead oflogger.debug("format string" % (argument1, argument2))
. This way the arguments end up in structured logging, and we don't pay the interpolation cost when the log line isn't output.Build has FAILED
Link to build: https://jenkins.softwareheritage.org/job/DJNL/job/tox/134/ See console output for more information: https://jenkins.softwareheritage.org/job/DJNL/job/tox/134/console