Skip to content
Permalink
Browse files

Expose the root publisher as Logger.publisher.

LegacyFormatStub.__str__() should return bytes, not unicode.

git-svn-id: https://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk@11360 e27351fd-9f3e-4f54-a53b-843176b1656c
  • Loading branch information...
wsanchez committed Jun 14, 2013
1 parent 97f6146 commit 92f1d3192c054a7cf5c5fdf9ae662f6755444e8b
Showing with 12 additions and 10 deletions.
  1. +12 −10 twext/python/log.py
@@ -51,11 +51,11 @@ def oops(self, data):
# TODO List:
#
# * Expose the default log observer (TheLogPublisher)
# * Specifically, expose addObserver and removeObserver so one can register other observers
# * Check the unicode situation for sanity
# * Specifically, expose addObserver and removeObserver so one can register other observers
# * Change the default log observer to something non-legacy
# * Register a legacy observer with Twisted's logging that forwards to this module
# * Monkey patch logging in Twisted to use our LegacyLogger to sprinkle betterness everywhere
# * Register a legacy observer with Twisted's logging that forwards to this module
# * Monkey patch logging in Twisted to use our LegacyLogger to sprinkle betterness everywhere
# * Move namespace settings to Filter class
#

__all__ = [
@@ -375,7 +375,7 @@ def emit(self, level, format=None, **kwargs):
log_time = time.time(),
)

TheLogPublisher(event)
self.publisher(event)


def failure(self, format, failure=None, level=LogLevel.error, **kwargs):
@@ -640,7 +640,7 @@ def __call__(self, event):
#
class LegacyFormatStub(object):
def __str__(self):
return self.formatEvent(event)
return self.formatEvent(event).encode("utf-8")

event["format"] = prefix + "%(log_legacy)s"
event["log_legacy"] = LegacyFormatStub()
@@ -711,11 +711,13 @@ def formatWithCall(formatString, mapping):
# Default observers
# FIXME: ...
#
TheLegacyLogObserver = LegacyLogObserverWrapper(twistedLogMessage)
TheFilteredLogPublisher = LogPublisher(TheLegacyLogObserver) # Add post-filtering observers here
TheFilteringLogObserver = LogLevelFilteringLogObserverWrapper(TheFilteredLogPublisher)
TheLogPublisher = LogPublisher(TheFilteringLogObserver) # Add pre-filtering observers here
theLegacyLogObserver = LegacyLogObserverWrapper(twistedLogMessage)

theFilteredLogPublisher = LogPublisher(theLegacyLogObserver) # Add post-filtering observers here
theFilteringLogObserver = LogLevelFilteringLogObserverWrapper(theFilteredLogPublisher)
theLogPublisher = LogPublisher(theFilteringLogObserver) # Add pre-filtering observers here

Logger.publisher = theLogPublisher


######################################################################

0 comments on commit 92f1d31

Please sign in to comment.
You can’t perform that action at this time.