Standardize logging, and add loggers for tools.

Review Request #11568 — Created April 1, 2021 and updated

chipx86
ReviewBot
release-3.0.x
reviewbot

Review Bot's logging was all over the place. Some code was using the
base logging module, some was calling logging.getLogger(), and some
was (rightfully) using Celery's get_logger() or get_task_logger()
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 reviewbot.utils.log.get_logger() function
that wraps Celery's get_logger()/get_task_logger(). It defaults to
creating task loggers, since most operations will run within the context
of a task.

BaseTool provides a enw logger property 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
unwanted noise.

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.

Summary
Standardize logging, and add loggers for tools.
Description From Last Updated

I think it's more useful to have this in the method definition rather than the module. Or perhaps both.

daviddavid
Checks run (2 succeeded)
flake8 passed.
JSHint passed.
david
  1. 
      
  2. bot/reviewbot/utils/log.py (Diff revision 1)
     
     
     

    I think it's more useful to have this in the method definition rather than the module. Or perhaps both.

  3. 
      
Loading...