[openstack-dev] [oslo] Log spool in the context

Alexis Lee lxsli at hpe.com
Wed May 25 15:24:59 UTC 2016


Doug Hellmann said on Wed, May 25, 2016 at 11:06:35AM -0400:
> Excerpts from Alexis Lee's message of 2016-05-25 13:46:05 +0100:
> >   def some_method(ctx):
> >       log = tools.get_api_logger(ctx) or LOG
> 
> That "or" statement in some_method() seems to imply though that
> when spool logging is on, messages would *only* go through the
> spooling logger. Is that what we want? Even for info messages?

The global logger (LOG) is still accessible so if you definitely want a
message in the main log, you can use that instead. I'll use "reqlog"
instead of "log" in future to make the two more quickly distinguishable.
EG a "warning, disk running out of space" may be discovered during
request processing but isn't tied to that request, so it makes more
sense to send that to the main log.

If we want a message to go to both loggers, without going to the global
logger twice, we can do:

    if reqlog != LOG:
        reqlog.info("...")
    LOG.info("...")


Alexis (lxsli)
-- 
Nova developer, Hewlett-Packard Limited.
Registered Office: Cain Road, Bracknell, Berkshire RG12 1HN.
Registered Number: 00690597 England
VAT number: GB 314 1496 79



More information about the OpenStack-dev mailing list