[IMP] --log-rpc-xxx into --log-request and --log-response.

bzr revid: vmt@openerp.com-20120202122610-r35cxp2y5i63lczg
This commit is contained in:
Vo Minh Thu 2012-02-02 13:26:10 +01:00
parent 1ab6f8883c
commit 88d2e96317
2 changed files with 15 additions and 15 deletions

View File

@ -315,23 +315,23 @@ def dispatch_rpc(service_name, method, params):
NET-RPC) is done in a upper layer.
"""
try:
rpc_short = logging.getLogger(__name__ + '.rpc_short')
rpc_full = logging.getLogger(__name__ + '.rpc_full')
rpc_short_flag = rpc_short.isEnabledFor(logging.DEBUG)
rpc_full_flag = rpc_full.isEnabledFor(logging.DEBUG)
if rpc_short_flag or rpc_full_flag:
rpc_request = logging.getLogger(__name__ + '.rpc.request')
rpc_response = logging.getLogger(__name__ + '.rpc.response')
rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
rpc_response_flag = rpc_response.isEnabledFor(logging.DEBUG)
if rpc_request_flag or rpc_response_flag:
start_time = time.time()
if rpc_full_flag:
log(rpc_full,logging.DEBUG,'%s.%s:request '%(service_name,method), replace_request_password(params))
if rpc_request and rpc_response_flag:
log(rpc_request,logging.DEBUG,'%s.%s'%(service_name,method), replace_request_password(params))
result = ExportService.getService(service_name).dispatch(method, params)
if rpc_short_flag or rpc_full_flag:
if rpc_request_flag or rpc_response_flag:
end_time = time.time()
if rpc_full_flag:
log(rpc_full,logging.DEBUG,'%s.%s:reply time:%.3fs '%(service_name,method,end_time - start_time), result)
if rpc_response_flag:
log(rpc_response,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), result)
else:
log(rpc_short,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), replace_request_password(params), depth=1)
log(rpc_request,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), replace_request_password(params), depth=1)
return result
except openerp.exceptions.AccessError:

View File

@ -179,10 +179,10 @@ class configmanager(object):
group.add_option("--logfile", dest="logfile", help="file where the server log will be stored")
group.add_option("--no-logrotate", dest="logrotate", action="store_false", my_default=True, help="do not rotate the logfile")
group.add_option("--syslog", action="store_true", dest="syslog", my_default=False, help="Send the log to the syslog server")
group.add_option('--log-handler', action="append", default=[':INFO'], my_default=[':INFO'], metavar="PREFIX:LEVEL", help='setup an handler at LEVEL for a given PREFIX. Example: "openerp.orm:DEBUG" (default: ":INFO")')
group.add_option('--log-rpc-short', action="append_const", dest="log_handler", const="openerp.netsvc.rpc_short:DEBUG", help='shortcut for --log-handler=openerp.netsvc.rpc_short:DEBUG')
group.add_option('--log-rpc-full', action="append_const", dest="log_handler", const="openerp.netsvc.rpc_full:DEBUG", help='shortcut for --log-handler=openerp.netsvc.rpc_full:DEBUG')
group.add_option('--log-rpc-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-handler', action="append", default=[':INFO'], my_default=[':INFO'], metavar="PREFIX:LEVEL", help='setup a handler at LEVEL for a given PREFIX. An empty PREFIX indicates the root logger. This option can be repeated. Example: "openerp.orm:DEBUG" or "werkzeug:CRITICAL" (default: ":INFO")')
group.add_option('--log-request', action="append_const", dest="log_handler", const="openerp.netsvc.rpc.request:DEBUG", help='shortcut for --log-handler=openerp.netsvc.rpc.request:DEBUG')
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')
parser.add_option_group(group)