[openstack-dev] [oslo] Log spool in the context
Doug Hellmann
doug at doughellmann.com
Wed May 25 15:06:35 UTC 2016
Excerpts from Alexis Lee's message of 2016-05-25 13:46:05 +0100:
> Doug Hellmann said on Tue, May 24, 2016 at 02:53:51PM -0400:
> > Rather than forcing SpoolManager to be a singleton, maybe the thing
> > to do is build some functions for managing a singleton instance (or
> > one per type or whatever), and making that API convenient enough
> > that using the spool logger doesn't require adding a bunch of logic
> > and import_opt() calls all over the place. Since it looks like the
> > convenience function would require looking at a config option owned
> > by the application, it probably shouldn't live in oslo.log, but
> > putting it in a utility module in nova might make sense.
>
> OK, so if I understand you correctly, we'll have EG nova/tools.py
> containing something like:
>
> CONF.import_opt("spool_api")
> SPOOL_MANAGERS = {}
>
> def get_api_logger(context):
> if not CONF.spool_api:
> return None
> mgr = SPOOL_MANAGERS.setdefault('api', SpoolManager('api'))
> return mgr.get_spool(context.request_id)
>
> then in normal code:
>
> LOG = logging.getLogger(__name__)
>
> def some_method(ctx):
> log = tools.get_api_logger(ctx) or LOG
>
> That seems OK to me, I'll work on it, thank you both.
>
>
> Alexis (lxsli)
Yeah, something like that looks like what I was thinking.
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?
Doug
More information about the OpenStack-dev
mailing list