Add log.get_loggers method
In the Cinder project restarting the volume service is problematic because it's not only in the control path but also in the data path of some operations, so restarting it to change log levels is really disruptive because it takes a long time to be done properly and it does not support Active-Active configurations yet. For this reason there's a specific API to change the log levels dynamically based on a given prefix [1], but this feature is accessing directly the `_loggers` dictionary which is not ideal. This patch adds a simple method called `get_loggers` that will return a copy of the internal `_loggers` dictionary so that the Cinder feature can be changed to use this instead. [1] https://review.openstack.org/445885 Change-Id: Ife33a5dd044a4565ad6a4d559ef9f0c108f260a3
This commit is contained in:
parent
51889f4832
commit
08b854f6b2
@ -416,6 +416,11 @@ def _setup_logging_from_conf(conf, project, version):
|
||||
_loggers = {}
|
||||
|
||||
|
||||
def get_loggers():
|
||||
"""Return a copy of the oslo loggers dictionary."""
|
||||
return _loggers.copy()
|
||||
|
||||
|
||||
def getLogger(name=None, project='unknown', version='unknown'):
|
||||
"""Build a logger with the given name.
|
||||
|
||||
|
@ -401,6 +401,11 @@ class LogLevelTestCase(BaseTestCase):
|
||||
l = log.getLogger('nova-trace.foo')
|
||||
self.assertEqual(log.TRACE, l.logger.getEffectiveLevel())
|
||||
|
||||
def test_get_loggers(self):
|
||||
log._loggers['sentinel_log'] = mock.sentinel.sentinel_log
|
||||
res = log.get_loggers()
|
||||
self.assertDictEqual(log._loggers, res)
|
||||
|
||||
|
||||
class JSONFormatterTestCase(LogTestBase):
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user