空中刹车抛出错误"pybrake-ERROR-strconv.ParseInt:解析"None":无效语法"; [英] Airbrake throwing error "pybrake - ERROR - strconv.ParseInt: parsing "None": invalid syntax"

查看:750
本文介绍了空中刹车抛出错误"pybrake-ERROR-strconv.ParseInt:解析"None":无效语法";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 https://https://github.com/airbrake/pybrake#django-integration"rel =" nofollow noreferrer> https中描述的步骤在Django项目中使用Airbrake logger. ://github.com/airbrake/pybrake#django-integration .

我已经这样配置了LOGGING设置:

I've configured my LOGGING setting like so:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'airbrake': {
            'level': 'ERROR',
            'class': 'pybrake.LoggingHandler',
        }
    },
    'loggers': {
        'lucy_web': {
            'handlers': ['airbrake'],
            'level': 'ERROR',
            'propagate': True,
        }
    }
}

然后,在lucy_web层次结构中名为lucy_web/lib/session_recommendation.py的特定文件中,我具有以下测试功能:

Then, in a particular file in the lucy_web hierarchy called lucy_web/lib/session_recommendation.py, I have the following test function:

import logging

logger = logging.getLogger(__name__)

def log_something():
    logger.error("Logging something...")

但是,如果我尝试从Django shell调用此函数,则pybrake本身会记录错误:

However, if I try to call this function from the Django shell, pybrake itself logs an error:

strconv.ParseInt:解析为"None":无效语法

strconv.ParseInt: parsing "None": invalid syntax

这是完整的命令序列:

(venv) Kurts-MacBook-Pro-2:lucy-web kurtpeek$ python manage.py shell
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from lucy_web.lib.session_recommendation import *

In [2]: log_something()

In [3]: 2018-05-30 17:25:32,201 - pybrake - ERROR - strconv.ParseInt: parsing "None": invalid syntax

它会出现在 https://golang.org/pkg/strconv/#ParseInt strconv.ParseInt实际上是Go语言的内置函数,因此我不明白为什么pybrake(这是一个Python软件包)会引发此错误或如何调试它.谁能解释这个错误?

It would appear from https://golang.org/pkg/strconv/#ParseInt that strconv.ParseInt is actually a built-in function of the Go language, so I don't understand why pybrake, which is a Python package, is throwing this error, or how to debug it. Can anyone explain this error?

推荐答案

似乎空中刹车服务器本身是用Go语言编写的.

It seems airbrake server itself is written in Go.

这可以从以下事实推断出来:

This can be inferred from the following facts:

  • 在他们的关于"页面( https://airbrake.io/about )列出他们的成员之一作为他们的"Lead Go开发人员",并说他们从1.0之前就开始使用Go".在他们的CTO描述中,他们还说他喜欢用Go入侵家".

  • In their "About" page (https://airbrake.io/about) they list one of their members as their "Lead Go developer" and say they've been "using Go since before 1.0". Also in their CTO description they say he likes "hacking his home with Go".

您正在从Python中获取strconv.ParseInt(Go)错误

You are getting a strconv.ParseInt (Go) error from Python

有报告称,使用Ruby客户端报告空中刹车错误也得到strconv.ParseInt( https://github.com/airbrake/airbrake/issues/502 )

There is a report of getting also a strconv.ParseInt from using a Ruby client to report airbrake errors (https://github.com/airbrake/airbrake/issues/502)

因此,对该错误的解释是,Python客户端在发送报告并记录此日志时正在从服务器获取此错误.

So explanation for the error would be that the Python client is getting this error from the server when sending the report, and logging this.

关于调试方法,我想说最好的方法是捕获客户端发送到服务器的请求.

As for how to debug this, I'd say the best way would be to capture the request that the client is sending to the server.

例如,您可以通过修改此处的代码以指向您自己的服务器(而不是airbrake的服务器)并记录请求来做到这一点:

You can do this for example by modifying the code here to point to your own server instead of airbrake's and log the requests:

https://github.com/airbrake/pybrake /blob/master/pybrake/notifier.py#L41

或者以某种方式捕获HTTP流量.

Or capture the HTTP traffic somehow.

您可能会看到JSON/XML/HTTP表单数据,其中将在属性上附加一个无"值,该值应改为数字,这将在服务器端引发此错误.

You'll probably see a JSON/XML/HTTP Form Data in which there will be a "None" value attached to a property that should instead be a number, which would then raise this error server-side.

这篇关于空中刹车抛出错误"pybrake-ERROR-strconv.ParseInt:解析"None":无效语法";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆