Code review comment for lp:~vishvananda/nova/log-fix

Revision history for this message
Vish Ishaya (vishvananda) wrote :

The main issue is that how logging is configured is heavily dependent on flags. There are a number of ways to get into our code:
a) nova-* bin files
b) tests through nose
c) external code importing files

We can do all configuration without the initialized flag if we do something like
import sys
from nova import flags
flags.FLAGS(sys.argv)
from nova import log as logging

at the top of every file that may be run from the command line. I find this ugly and fragile. If someone tries to use our code and fails to do these commands, logging will break. Also the flags are modified in various places, including tests, and nova-api after loading the paste.deploy conf.

An alternative to the initialized attribute is to cache the values of the relevant logging flags, and just check them for changes each time we log. I'm a little concerned about the performance of this option, especially for the default_log_levels flag which is a list and potentially expensive to check for changes every time we want to write a log message.

Perhaps the best option would be to put a logging_setup() in the end of flags.call(), so it will reset the logging conf after loading flags.

« Back to merge proposal