Mercurial > libervia-backend
changeset 992:f51a1895275c
core (log): twisted backend use logging methods instead of log.msg
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Apr 2014 16:48:26 +0200 |
parents | 05e02f8b7eb4 |
children | 301b342c697a |
files | src/core/log.py |
diffstat | 1 files changed, 5 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/log.py Sat Apr 19 00:02:38 2014 +0200 +++ b/src/core/log.py Sat Apr 19 16:48:26 2014 +0200 @@ -96,7 +96,6 @@ return s - root_logger = logging.getLogger() if len(root_logger.handlers) == 0: hdlr = logging.StreamHandler() @@ -119,22 +118,11 @@ 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