mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 08:56:04 -04:00
Move logging utilities out of the side drawer of util/ and into logging/ (#5606)
This commit is contained in:
parent
cb8d568cf9
commit
463b072b12
98 changed files with 249 additions and 233 deletions
|
@ -21,10 +21,14 @@ import attr
|
|||
|
||||
from twisted.internet import defer, task
|
||||
|
||||
from synapse.util.logcontext import PreserveLoggingContext
|
||||
from synapse.logging import context, formatter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Compatibility alias, for existing logconfigs.
|
||||
logcontext = context
|
||||
logformatter = formatter
|
||||
|
||||
|
||||
def unwrapFirstError(failure):
|
||||
# defer.gatherResults and DeferredLists wrap failures.
|
||||
|
@ -46,7 +50,7 @@ class Clock(object):
|
|||
@defer.inlineCallbacks
|
||||
def sleep(self, seconds):
|
||||
d = defer.Deferred()
|
||||
with PreserveLoggingContext():
|
||||
with context.PreserveLoggingContext():
|
||||
self._reactor.callLater(seconds, d.callback, seconds)
|
||||
res = yield d
|
||||
defer.returnValue(res)
|
||||
|
@ -91,10 +95,10 @@ class Clock(object):
|
|||
"""
|
||||
|
||||
def wrapped_callback(*args, **kwargs):
|
||||
with PreserveLoggingContext():
|
||||
with context.PreserveLoggingContext():
|
||||
callback(*args, **kwargs)
|
||||
|
||||
with PreserveLoggingContext():
|
||||
with context.PreserveLoggingContext():
|
||||
return self._reactor.callLater(delay, wrapped_callback, *args, **kwargs)
|
||||
|
||||
def cancel_call_later(self, timer, ignore_errs=False):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue