[IMP] logging: re-added the --log-level option for backward compatibility.

bzr revid: vmt@openerp.com-20120206230215-pst29d6x0ymn2fwx
This commit is contained in:
Vo Minh Thu 2012-02-07 00:02:15 +01:00
parent 229ab5cfa4
commit 09dc03a30f
2 changed files with 28 additions and 3 deletions

View File

@ -190,8 +190,25 @@ def init_logger():
# Configure handlers
logconfig = tools.config['log_handler']
for logconfig_item in logconfig:
_logger.debug('logger level set: "%s"', logconfig_item)
if tools.config['log_level'] == 'info':
pseudo_config = []
elif tools.config['log_level'] == 'debug_rpc':
pseudo_config = ['openerp.netsvc.rpc.request:DEBUG']
elif tools.config['log_level'] == 'debug_rpc_answer':
pseudo_config = ['openerp.netsvc.rpc.request:DEBUG', 'openerp.netsvc.rpc.response:DEBUG']
elif tools.config['log_level'] == 'debug':
pseudo_config = ['openerp:DEBUG']
elif tools.config['log_level'] == 'critical':
pseudo_config = ['openerp:CRITICAL']
elif tools.config['log_level'] == 'test':
pseudo_config = ['openerp:TEST']
elif tools.config['log_level'] == 'error':
pseudo_config = ['openerp:ERROR']
elif tools.config['log_level'] == 'warn':
pseudo_config = ['openerp:WARNING']
elif tools.config['log_level'] == 'debug_sql':
pseudo_config = ['openerp.sql_db:DEBUG']
for logconfig_item in logconfig + pseudo_config:
loggername, level = logconfig_item.split(':')
level = getattr(logging, level, logging.INFO)
logger = logging.getLogger(loggername)
@ -201,6 +218,8 @@ def init_logger():
if loggername != '':
logger.propagate = False
for logconfig_item in logconfig + pseudo_config:
_logger.debug('logger level set: "%s"', logconfig_item)
# A alternative logging scheme for automated runs of the
# server intended to test it.

View File

@ -184,6 +184,12 @@ class configmanager(object):
group.add_option('--log-response', action="append_const", dest="log_handler", const="openerp.netsvc.rpc.response:DEBUG", help='shortcut for --log-handler=openerp.netsvc.rpc.response:DEBUG')
group.add_option('--log-web', action="append_const", dest="log_handler", const="openerp.addons.web.common.http:DEBUG", help='shortcut for --log-handler=openerp.addons.web.common.http:DEBUG')
group.add_option('--log-sql', action="append_const", dest="log_handler", const="openerp.sql_db:DEBUG", help='shortcut for --log-handler=openerp.sql_db:DEBUG')
# For backward-compatibility, map the old log levels to something
# quite close.
levels = ['info', 'debug_rpc', 'warn', 'test', 'critical',
'debug_sql', 'error', 'debug', 'debug_rpc_answer', 'notset']
group.add_option('--log-level', dest='log_level', type='choice', choices=levels,
my_default='info', help='specify the level of the logging. Accepted values: ' + str(levels) + ' (deprecated option).')
parser.add_option_group(group)
@ -369,7 +375,7 @@ class configmanager(object):
'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone',
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
'static_http_enable', 'static_http_document_root', 'static_http_url_prefix',
'secure_cert_file', 'secure_pkey_file', 'dbfilter', 'log_handler'
'secure_cert_file', 'secure_pkey_file', 'dbfilter', 'log_handler', 'log_level'
]
for arg in keys: