V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
sbmzhcn
V2EX  ›  Python

Sentry 问题

  •  
  •   sbmzhcn · 2015-08-13 20:17:22 +08:00 · 3597 次点击
    这是一个创建于 3399 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在服务器上装好了sentry客户端用一个测试代码,根据这个来的
    http://raven.readthedocs.org/en/latest/integrations/logging.html

    logger.error('There was some %s error', 'crazy')

    这样没有问题,服务器端登陆网页能看到信息被记录下来,但如果这样

    logger.error('There was some crazy error', exc_info=True)
    就会出现这样的错误:

    ```
    Top level Sentry exception caught - failed creating log record
    b'There was some crazy error'
    b'Traceback (most recent call last):\n File "C:\\Python33\\lib\\site-packages\\raven\\handlers\\logging.py", line 59, in emit\n self.format(record)\n File "C:\\Python33\\lib\\logging\\__init__.py", line 808, in format\n return fmt.format(record)\n File "C:\\Python33\\lib\\logging\\__init__.py", line 554, in format\n record.exc_text = self.formatException(record.exc_info)\n File "C:\\Python33\\lib\\logging\\__init__.py", line 504, in formatException\n traceback.print_exception(ei[0], ei[1], tb, None, sio)\n File "C:\\Python33\\lib\\traceback.py", line 156, in print_exception\n for value, tb in values:\n File "C:\\Python33\\lib\\traceback.py", line 122, in _iter_chain\n context = exc.__context__\nAttributeError: \'NoneType\' object has no attribute \'__context__\'\n'
    Sentry is attempting to send 1 pending error messages
    Waiting up to 10 seconds
    Press Ctrl-Break to quit
    ```

    请问是怎么回事
    5 条回复    2015-08-14 02:30:28 +08:00
    shellfly
        1
    shellfly  
       2015-08-13 20:43:53 +08:00
    文档上不是说了,只有当你真的是在catch一个异常的时候才用这个参数,否则应该用另一种方式来获取堆栈信息
    sbmzhcn
        2
    sbmzhcn  
    OP
       2015-08-13 22:28:16 +08:00
    @shellfly try : except 吗, 我试了还是不行
    sbmzhcn
        3
    sbmzhcn  
    OP
       2015-08-13 22:32:33 +08:00
    logger.error('Exception in method ...', exc_info=True, extra=dict(stack=True)) 这样就行了,谢了。
    lequiet
        4
    lequiet  
       2015-08-14 00:07:54 +08:00 via iPhone
    原来Logger有参数获得这个信息,学习了
    ivanlw
        5
    ivanlw  
       2015-08-14 02:30:28 +08:00 via iPhone
    Sentry是…真眼?? #dota2
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5862 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 03:10 · PVG 11:10 · LAX 19:10 · JFK 22:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.