We want to remove the openstack.common.log.ContextAdapter class as part of graduating oslo.log, to reduce the API footprint.
We use ContextAdapter to add request context information to log messages we output. Requiring a specially adapted logging handle limits the scope of where that context information can be added, and unnecessarily funnels all logging calls through the oslo logging modules.
The previous version of this spec suggested changing getLogger() to return a different adapter type with audit() and deprecated() methods, allowing us to keep the API as it is for now to buy time to update the callers that use the methods that would otherwise be removed. Since we are starting this work at the beginning of a cycle, I have updated the proposal to move us directly to the sort of API we want to keep.
We remove some APIs, but most of them have equivalent forms available from other libraries. There are three cases that do not.
The ContextAdapter provides an audit() method for logging at INFO+1 level. This will be removed, and the log messages updated to either use the INFO level or use the log() method with the audit level.
$ for d in ceilometer cinder glance heat ironic keystone neutron nova sahara trove swift; do echo $d; ack LOG.audit $d/$d | wc -l; done ceilometer 0 cinder 4 glance 0 heat 0 ironic 0 keystone 0 neutron 0 nova 101 sahara 0 trove 0 swift 0
The deprecated() method of the ContextAdapter is replaced with a new function in versionutils. See fix-import-cycle-log-and-versionutils.
The ContextAdapter API supports doing:
LOG.info('some message: %(named_arg)s', named_arg=val, context=context)
The standard logger methods don’t accept arbitrary keyword arguments to be part of the ‘extra’, but we have enough cases of this that we need to continue to support the pattern to avoid churn and breaking things in the other projects. We will implement a KeywordArgumentAdapter to be returned by getLogger().
Oslo libraries should not use this feature, to avoid circular dependencies between the libraries and oslo.log.
See “Impact on Existing APIs” above.
As apps that use the incubated version of oslo.log are updated, they will need to be changed to get loggers directly from the standard library module and to use versionutils for deprecated().
This change is part of stabilizing the API for oslo.log before graduation.
This work is licensed under a Creative Commons Attribution 3.0 Unported License. http://creativecommons.org/licenses/by/3.0/legalcode