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

Doug Hellmann doug at doughellmann.com
Tue May 24 17:18:44 UTC 2016

Excerpts from Alexis Lee's message of 2016-05-24 09:34:36 +0100:
> 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)

Do you need more than one? The spec talks about different types of
requests having different SpoolManagers (api and scheduler are the 2
examples given).

What happens when the context is serialized and sent across an RPC call?
Is there some representation of the logger that the messaging code can
use on the other side to reconstruct the logger?


More information about the OpenStack-dev mailing list