[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 sys
|
||||
import traceback
|
||||
import logging
|
||||
from pprint import pformat
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import netsvc
|
||||
|
@ -91,10 +95,13 @@ class ir_cron(osv.osv, netsvc.Agent):
|
|||
if m and hasattr(m, func):
|
||||
f = getattr(m, func)
|
||||
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)
|
||||
except Exception, e:
|
||||
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):
|
||||
|
|
|
@ -393,19 +393,21 @@ def replace_request_password(args):
|
|||
args[2] = '*'
|
||||
return args
|
||||
|
||||
class OpenERPDispatcher:
|
||||
def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None):
|
||||
def log(title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
|
||||
logger = logging.getLogger(title)
|
||||
if logger.isEnabledFor(channel):
|
||||
for line in pformat(msg, depth=depth).split('\n'):
|
||||
logger.log(channel, line)
|
||||
indent=0
|
||||
for line in (fn+pformat(msg, depth=depth)).split('\n'):
|
||||
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):
|
||||
try:
|
||||
logger = logging.getLogger('result')
|
||||
self.log('service', service_name)
|
||||
self.log('method', method)
|
||||
self.log('params', replace_request_password(params), depth=(None if logger.isEnabledFor(logging.DEBUG_RPC_ANSWER) else 1))
|
||||
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))
|
||||
auth = getattr(self, 'auth_provider', None)
|
||||
result = ExportService.getService(service_name).dispatch(method, auth, params)
|
||||
self.log('result', result, channel=logging.DEBUG_RPC_ANSWER)
|
||||
|
|
Loading…
Reference in New Issue