Standardize logging, and add loggers for tools.
Review Request #11568 — Created April 1, 2021 and submitted
Review Bot's logging was all over the place. Some code was using the
loggingmodule, some was calling
logging.getLogger(), and some
was (rightfully) using Celery's
functions. The Celery versions are pretty important, given how much
Celery controls the environment that our code runs in, so we actually
had some logging that didn't really work before.
This change aims to standardize logging, future-proofing it at the same
time. We now have our own
that wraps Celery's
get_task_logger(). It defaults to
creating task loggers, since most operations will run within the context
of a task.
BaseToolprovides a new
loggerproperty for logging. It will
dynamically construct/retrieve a logger as needed, determining whether
that logger will be a task logger or a standard logger. This simplifies
tools even further, taking the guess work out of each implementation.
The log message formats have been altered to be a little bit nicer and
more consistent with typical log messages, and to include the logger
name (which Celery's default message format omits).
Some log levels have also been adjusted here and there, to cut down on
Unit tests pass for Python 2.7 and 3.x.
Verified that the logs on startup (for dependency checks and configuration)
were using standard loggers without task information, but that all the log
messages going through during a task run were showing task information.
I think it's more useful to have this in the method definition rather than the module. Or perhaps both.
Revision 2 (+418 -210)
Checks run (2 succeeded)