py3: proxy some logger properties in LogAdapter
Seen in a (failed) py35 gate job: test-replicator ERROR: Error syncing partition: Traceback (most recent call last): File ".../swift/swift/obj/replicator.py", line 626, in update self.replication_cycle)) File ".../eventlet/tpool.py", line 129, in execute six.reraise(c, e, tb) File ".../six.py", line 693, in reraise raise value File ".../eventlet/tpool.py", line 83, in tworker rv = meth(*args, **kwargs) File ".../swift/swift/obj/diskfile.py", line 1174, in _get_hashes hashed, hashes = self.__get_hashes(*args, **kwargs) File ".../swift/swift/obj/diskfile.py", line 1237, in __get_hashes self.logger.debug('Run listdir on %s', partition_path) File "/usr/lib/python3.5/logging/__init__.py", line 1596, in debug self.log(DEBUG, msg, *args, **kwargs) File "/usr/lib/python3.5/logging/__init__.py", line 1638, in log if self.isEnabledFor(level): File "/usr/lib/python3.5/logging/__init__.py", line 1646, in isEnabledFor if self.logger.manager.disable >= level: AttributeError: 'LogAdapter' object has no attribute 'manager' Sure sounds like https://bugs.python.org/issue31457 to me. Change-Id: I2afb234d096be17bc16292b288930e2b7a715da4
This commit is contained in:
parent
0c316a134f
commit
9b6080536b
@ -1919,6 +1919,37 @@ class LogAdapter(logging.LoggerAdapter, object):
|
||||
self.server = server
|
||||
self.warn = self.warning
|
||||
|
||||
# There are a few properties needed for py35; see
|
||||
# - https://bugs.python.org/issue31457
|
||||
# - https://github.com/python/cpython/commit/1bbd482
|
||||
# - https://github.com/python/cpython/commit/0b6a118
|
||||
# - https://github.com/python/cpython/commit/ce9e625
|
||||
def _log(self, level, msg, args, exc_info=None, extra=None,
|
||||
stack_info=False):
|
||||
"""
|
||||
Low-level log implementation, proxied to allow nested logger adapters.
|
||||
"""
|
||||
return self.logger._log(
|
||||
level,
|
||||
msg,
|
||||
args,
|
||||
exc_info=exc_info,
|
||||
extra=extra,
|
||||
stack_info=stack_info,
|
||||
)
|
||||
|
||||
@property
|
||||
def manager(self):
|
||||
return self.logger.manager
|
||||
|
||||
@manager.setter
|
||||
def manager(self, value):
|
||||
self.logger.manager = value
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.logger.name
|
||||
|
||||
@property
|
||||
def txn_id(self):
|
||||
if hasattr(self._cls_thread_local, 'txn_id'):
|
||||
|
Loading…
Reference in New Issue
Block a user