2011-12-07 91 views
1

我怎樣才能將錯誤記錄到芹菜任務的django-sentry?芹菜django-sentry的日誌錯誤

我試圖嘗試:除了:塊和使用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 
+0

您可以張貼行,你要調用'create_from_exception'? –

+0

將我的任務添加到問題中 – ojii

回答

2

這個怎麼樣:

myLogger = logging.getLogger('mylogger.info') 
    myLogger.setLevel(logging.INFO) 
    myLogger.info(exc_info) 

在我的settings.py:

'loggers': { 
    'mylogger.info': { 
     'level': 'INFO', 
     'handlers': ['sentry'], 
     'propagate': False, 
     }, 
      }