[MERGE] slightly improved log message for cron jobs.
bzr revid: vmt@openerp.com-20110513142920-s0vw77xawgod5r13
This commit is contained in:
commit
0da15bd185
|
@ -20,6 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
import time
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import netsvc
|
||||
|
@ -91,10 +92,13 @@ class ir_cron(osv.osv, netsvc.Agent):
|
|||
if m and hasattr(m, func):
|
||||
f = getattr(m, func)
|
||||
try:
|
||||
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,22 @@ def replace_request_password(args):
|
|||
args[2] = '*'
|
||||
return args
|
||||
|
||||
class OpenERPDispatcher:
|
||||
def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None):
|
||||
logger = logging.getLogger(title)
|
||||
if logger.isEnabledFor(channel):
|
||||
for line in pformat(msg, depth=depth).split('\n'):
|
||||
logger.log(channel, line)
|
||||
def log(title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
|
||||
logger = logging.getLogger(title)
|
||||
if logger.isEnabledFor(channel):
|
||||
indent=''
|
||||
indent_after=' '*len(fn)
|
||||
for line in (fn+pformat(msg, depth=depth)).split('\n'):
|
||||
logger.log(channel, indent+line)
|
||||
indent=indent_after
|
||||
|
||||
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