[openstack-dev] [oslo] Log spool in the context
Alexis Lee
lxsli at hpe.com
Wed May 25 12:46:05 UTC 2016
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)
--
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