[IMP] logging of rpc calls and cron jobs
lp bug: https://launchpad.net/bugs/781190 fixed bzr revid: jba@openerp.com-20110511160707-lsf87msknw7rngus
This commit is contained in:
parent
20dbc6e4a4
commit
1ab0987803
|
@ -20,6 +20,10 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
import logging
|
||||||
|
from pprint import pformat
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
import netsvc
|
import netsvc
|
||||||
|
@ -91,10 +95,13 @@ class ir_cron(osv.osv, netsvc.Agent):
|
||||||
if m and hasattr(m, func):
|
if m and hasattr(m, func):
|
||||||
f = getattr(m, func)
|
f = getattr(m, func)
|
||||||
try:
|
try:
|
||||||
|
depth=(None if self._logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1)
|
||||||
|
netsvc.log('cron', (cr.dbname,uid,'*',model,func)+tuple(args), channel=logging.DEBUG, depth=(None if self._logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1), fn='object.execute')
|
||||||
f(cr, uid, *args)
|
f(cr, uid, *args)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
cr.rollback()
|
cr.rollback()
|
||||||
self._logger.exception("Job call of self.pool.get('%s').%s(cr, uid, *%r) failed" % (model, func, args))
|
logger=logging.getLogger('cron')
|
||||||
|
logger.exception("Job call of self.pool.get('%s').%s(cr, uid, *%r) failed" % (model, func, args))
|
||||||
|
|
||||||
|
|
||||||
def _poolJobs(self, db_name, check=False):
|
def _poolJobs(self, db_name, check=False):
|
||||||
|
|
|
@ -393,19 +393,21 @@ def replace_request_password(args):
|
||||||
args[2] = '*'
|
args[2] = '*'
|
||||||
return args
|
return args
|
||||||
|
|
||||||
class OpenERPDispatcher:
|
def log(title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
|
||||||
def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None):
|
logger = logging.getLogger(title)
|
||||||
logger = logging.getLogger(title)
|
if logger.isEnabledFor(channel):
|
||||||
if logger.isEnabledFor(channel):
|
indent=0
|
||||||
for line in pformat(msg, depth=depth).split('\n'):
|
for line in (fn+pformat(msg, depth=depth)).split('\n'):
|
||||||
logger.log(channel, line)
|
logger.log(channel, ' '*indent+line)
|
||||||
|
indent=len(fn)
|
||||||
|
|
||||||
|
class OpenERPDispatcher:
|
||||||
|
def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
|
||||||
|
log(title, msg, channel=channel, depth=depth, fn=fn)
|
||||||
def dispatch(self, service_name, method, params):
|
def dispatch(self, service_name, method, params):
|
||||||
try:
|
try:
|
||||||
logger = logging.getLogger('result')
|
logger = logging.getLogger('result')
|
||||||
self.log('service', service_name)
|
self.log('service', tuple(replace_request_password(params)), depth=(None if logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1), fn='%s.%s'%(service_name,method))
|
||||||
self.log('method', method)
|
|
||||||
self.log('params', replace_request_password(params), depth=(None if logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1))
|
|
||||||
auth = getattr(self, 'auth_provider', None)
|
auth = getattr(self, 'auth_provider', None)
|
||||||
result = ExportService.getService(service_name).dispatch(method, auth, params)
|
result = ExportService.getService(service_name).dispatch(method, auth, params)
|
||||||
self.log('result', result, channel=logging.DEBUG_RPC_ANSWER)
|
self.log('result', result, channel=logging.DEBUG_RPC_ANSWER)
|
||||||
|
|
Loading…
Reference in New Issue