[openstack-dev] [oslo] Log spool in the context
Alexis Lee
lxsli at hpe.com
Tue May 24 08:34:36 UTC 2016
Hi,
I have a spec: https://review.openstack.org/227766
and implementation: https://review.openstack.org/316162
for adding a spooling logger to oslo.log. Neither is merged yet, reviews
welcome.
Looking at how I'd actually integrate this into Nova, most classes do:
LOG = logging.getLogger(__name__)
which is the recommended means of getting a logger. I need to get
certain code paths to use a different logger (if spooling is turned on).
This means I need to pass it around. If I modify method signatures I'm
bound to break back-compat for something.
Option 1: use a metaclass to register each SpoolManager as a singleton,
IE every call to SpoolManager('api') will return the same manager. I can
then do something like:
log = LOG
if CONF.spool_api:
log = SpoolManager('api').get_spool(context.request_id)
in every method.
Option 2: Put the logger on the context. We're already passing this
everywhere so it'd be awful convenient.
log = context.log or LOG
Option 3: ???
I like option 2, any objections to extending oslo.context like this?
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