如何从芹菜任务中将错误记录到django- sentinel ?
我试过try: except: blocks和使用raven_client。Create_from_exception,但每次都会抛出:
Traceback (most recent call last):
File "/home/controlpanel/current/env/lib/python2.6/site-packages/celery/execute/trace.py", line 47, in trace
return cls(states.SUCCESS, retval=fun(*args, **kwargs))
File "/home/controlpanel/current/env/lib/python2.6/site-packages/celery/app/task/__init__.py", line 247, in __call__
return self.run(*args, **kwargs)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/celery/app/__init__.py", line 175, in run
return fun(*args, **kwargs)
File "/home/controlpanel/deployments/1323265958/src/deploy/tasks.py", line 60, in async_deploy_bundle
raven_client.create_from_exception(exc_info=exc_info)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/contrib/django/__init__.py", line 120, in create_from_exception
return super(DjangoClient, self).create_from_exception(exc_info, **kwargs)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/base.py", line 285, in create_from_exception
frames = varmap(shorten, get_stack_info(iter_traceback_frames(exc_traceback)))
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/stacks.py", line 128, in get_stack_info
'vars': transform(frame.f_locals.items()),
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 78, in transform
ret = type(value)(transform_rec(o) for o in value)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 78, in <genexpr>
ret = type(value)(transform_rec(o) for o in value)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 72, in <lambda>
transform_rec = lambda o: transform(o, stack + [value], context)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 78, in transform
ret = type(value)(transform_rec(o) for o in value)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 78, in <genexpr>
ret = type(value)(transform_rec(o) for o in value)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 72, in <lambda>
transform_rec = lambda o: transform(o, stack + [value], context)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/raven/utils/encoding.py", line 78, in transform
ret = type(value)(transform_rec(o) for o in value)
File "/home/controlpanel/current/env/lib/python2.6/site-packages/git/util.py", line 588, in __init__
raise ValueError("First parameter must be a string identifying the name-property. Extend the list after initialization")
ValueError: First parameter must be a string identifying the name-property. Extend the list after initialization
我的任务:
@task
def async_deploy_bundle(bundle_id):
try:
do_stuff(bundle_id)
except:
exc_info = sys.exc_info()
traceback.print_exception(*exc_info)
try:
raven_client = get_client()
raven_client.create_from_exception(exc_info=exc_info)
except:
pass
raise
这个呢:
myLogger = logging.getLogger('mylogger.info')
myLogger.setLevel(logging.INFO)
myLogger.info(exc_info)
?
In my settings.py:
'loggers': {
'mylogger.info': {
'level': 'INFO',
'handlers': ['sentry'],
'propagate': False,
},
}