core (log): twisted backend use logging methods instead of log.msg
This commit is contained in:
parent
f05724db74
commit
dc5c042fe7
1 changed files with 5 additions and 17 deletions
|
|
@ -96,7 +96,6 @@ def _configureStdLogging(logging, level=None, colors=False, force_colors=False):
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
if len(root_logger.handlers) == 0:
|
if len(root_logger.handlers) == 0:
|
||||||
hdlr = logging.StreamHandler()
|
hdlr = logging.StreamHandler()
|
||||||
|
|
@ -119,22 +118,11 @@ def configure(backend=C.LOG_BACKEND_STANDARD):
|
||||||
raise exceptions.InternalError("Logging can only be configured once")
|
raise exceptions.InternalError("Logging can only be configured once")
|
||||||
_backend = backend
|
_backend = backend
|
||||||
|
|
||||||
if backend == C.LOG_BACKEND_TWISTED:
|
if backend in (C.LOG_BACKEND_TWISTED, C.LOG_BACKEND_STANDARD):
|
||||||
from twisted.python import log
|
if backend == C.LOG_BACKEND_TWISTED:
|
||||||
import logging
|
from twisted.python import log
|
||||||
_configureStdLogging(logging, colors=True)
|
observer = log.PythonLoggingObserver()
|
||||||
def logMsg(self, msg, level):
|
observer.start()
|
||||||
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:
|
|
||||||
global getLogger
|
global getLogger
|
||||||
global debug
|
global debug
|
||||||
global info
|
global info
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue