core (log): twisted backend use logging methods instead of log.msg

This commit is contained in:
Goffi 2014-04-19 16:48:26 +02:00
commit dc5c042fe7

View file

@ -96,7 +96,6 @@ def _configureStdLogging(logging, level=None, colors=False, force_colors=False):
return s
root_logger = logging.getLogger()
if len(root_logger.handlers) == 0:
hdlr = logging.StreamHandler()
@ -119,22 +118,11 @@ def configure(backend=C.LOG_BACKEND_STANDARD):
raise exceptions.InternalError("Logging can only be configured once")
_backend = backend
if backend == C.LOG_BACKEND_TWISTED:
from twisted.python import log
import logging
_configureStdLogging(logging, colors=True)
def logMsg(self, msg, level):
log.msg(msg.encode('utf-8'), logLevel=level)
Logger.logMsg = logMsg
Logger.debug = lambda self, msg: self.logMsg(msg, logging.DEBUG)
Logger.info = lambda self, msg: self.logMsg(msg, logging.INFO)
Logger.warning = lambda self, msg: self.logMsg(msg, logging.WARNING)
Logger.error = lambda self, msg: self.logMsg(msg, logging.ERROR)
Logger.critical = lambda self, msg: self.logMsg(msg, logging.CRITICAL)
observer = log.PythonLoggingObserver()
observer.start()
elif backend == C.LOG_BACKEND_STANDARD:
if backend in (C.LOG_BACKEND_TWISTED, C.LOG_BACKEND_STANDARD):
if backend == C.LOG_BACKEND_TWISTED:
from twisted.python import log
observer = log.PythonLoggingObserver()
observer.start()
global getLogger
global debug
global info