diff --git a/bin/netsvc.py b/bin/netsvc.py index b60546ce054..ab8fcec4bc8 100644 --- a/bin/netsvc.py +++ b/bin/netsvc.py @@ -78,13 +78,15 @@ def service_exist(name): LOG_NOTSET = 'notset' LOG_DEBUG_RPC = 'debug_rpc' LOG_DEBUG = 'debug' +LOG_DEBUG2 = 'debug2' LOG_INFO = 'info' LOG_WARNING = 'warn' LOG_ERROR = 'error' LOG_CRITICAL = 'critical' # add new log level below DEBUG -logging.DEBUG_RPC = logging.DEBUG - 1 +logging.DEBUG2 = logging.DEBUG - 1 +logging.DEBUG_RPC = logging.DEBUG2 - 1 def init_logger(): import os @@ -144,6 +146,7 @@ def init_logger(): mapping = { 'DEBUG_RPC': ('blue', 'white'), + 'DEBUG2': ('green', 'white'), 'DEBUG': ('blue', 'default'), 'INFO': ('green', 'default'), 'WARNING': ('yellow', 'default'), @@ -163,6 +166,10 @@ class Logger(object): log = logging.getLogger(tools.ustr(name)) + if level == LOG_DEBUG2 and not hasattr(log, level): + fct = lambda msg, *args, **kwargs: log.log(logging.DEBUG2, msg, *args, **kwargs) + setattr(log, LOG_DEBUG2, fct) + if level == LOG_DEBUG_RPC and not hasattr(log, level): fct = lambda msg, *args, **kwargs: log.log(logging.DEBUG_RPC, msg, *args, **kwargs) setattr(log, LOG_DEBUG_RPC, fct) diff --git a/bin/sql_db.py b/bin/sql_db.py index edf9a2aeaec..85bd6fc88d9 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -55,7 +55,7 @@ from mx import DateTime as mdt re_from = re.compile('.* from "?([a-zA-Z_0-9]+)"? .*$'); re_into = re.compile('.* into "?([a-zA-Z_0-9]+)"? .*$'); -def log(msg, lvl=netsvc.LOG_DEBUG): +def log(msg, lvl=netsvc.LOG_DEBUG2): logger = netsvc.Logger() logger.notifyChannel('sql', lvl, msg)