Introduce 'debug2' loglevel, use it for SQL
Sometimes we want to debug SQL, not always though. bzr revid: p_christ@hol.gr-20090814160111-fhw1j4jmx94t2hjv
This commit is contained in:
parent
00d15e79fe
commit
e571324ab3
|
@ -78,13 +78,15 @@ def service_exist(name):
|
||||||
LOG_NOTSET = 'notset'
|
LOG_NOTSET = 'notset'
|
||||||
LOG_DEBUG_RPC = 'debug_rpc'
|
LOG_DEBUG_RPC = 'debug_rpc'
|
||||||
LOG_DEBUG = 'debug'
|
LOG_DEBUG = 'debug'
|
||||||
|
LOG_DEBUG2 = 'debug2'
|
||||||
LOG_INFO = 'info'
|
LOG_INFO = 'info'
|
||||||
LOG_WARNING = 'warn'
|
LOG_WARNING = 'warn'
|
||||||
LOG_ERROR = 'error'
|
LOG_ERROR = 'error'
|
||||||
LOG_CRITICAL = 'critical'
|
LOG_CRITICAL = 'critical'
|
||||||
|
|
||||||
# add new log level below DEBUG
|
# 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():
|
def init_logger():
|
||||||
import os
|
import os
|
||||||
|
@ -144,6 +146,7 @@ def init_logger():
|
||||||
|
|
||||||
mapping = {
|
mapping = {
|
||||||
'DEBUG_RPC': ('blue', 'white'),
|
'DEBUG_RPC': ('blue', 'white'),
|
||||||
|
'DEBUG2': ('green', 'white'),
|
||||||
'DEBUG': ('blue', 'default'),
|
'DEBUG': ('blue', 'default'),
|
||||||
'INFO': ('green', 'default'),
|
'INFO': ('green', 'default'),
|
||||||
'WARNING': ('yellow', 'default'),
|
'WARNING': ('yellow', 'default'),
|
||||||
|
@ -163,6 +166,10 @@ class Logger(object):
|
||||||
|
|
||||||
log = logging.getLogger(tools.ustr(name))
|
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):
|
if level == LOG_DEBUG_RPC and not hasattr(log, level):
|
||||||
fct = lambda msg, *args, **kwargs: log.log(logging.DEBUG_RPC, msg, *args, **kwargs)
|
fct = lambda msg, *args, **kwargs: log.log(logging.DEBUG_RPC, msg, *args, **kwargs)
|
||||||
setattr(log, LOG_DEBUG_RPC, fct)
|
setattr(log, LOG_DEBUG_RPC, fct)
|
||||||
|
|
|
@ -55,7 +55,7 @@ from mx import DateTime as mdt
|
||||||
re_from = re.compile('.* from "?([a-zA-Z_0-9]+)"? .*$');
|
re_from = re.compile('.* from "?([a-zA-Z_0-9]+)"? .*$');
|
||||||
re_into = re.compile('.* into "?([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 = netsvc.Logger()
|
||||||
logger.notifyChannel('sql', lvl, msg)
|
logger.notifyChannel('sql', lvl, msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue