我在Django中使用Sentry,如下所示:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
'file': {
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR, 'logs', 'django.log'),
},
},
'loggers': {
'django': {
'handlers': ['file', 'console'],
'level': 'DEBUG',
},
'django.template': {
'handlers': ['file', 'console'],
'level': 'INFO',
},
'app': {
'handlers': ['file', 'console'],
'level': 'DEBUG',
}
},
}
,并具有以下用于记录的设置:
import logging
logger = logging.getLogger(__name__)
logger.error("error!")
如果我通过代码实例化并调用记录器,则会将其发送到Sentry。
.warning
但是,现在我也想记录sentry_logging = LoggingIntegration(event_level=logging.WARNING)
sentry_sdk.init(
dsn="https://xxx@sentry.io/xxx",
integrations=[sentry_logging]
)
个呼叫。 documentation说要这样做:
LoggingIntegration
但是使用DjangoIntegration
而不是DjangoIntegration。我尝试在上面的代码中使用
var api_array = [
{id: 1, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 1, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 1, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 2, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 2, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 2, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 3, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 3, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 3, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 4, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 4, postcode: 'xxx', street: 'xxx', city: 'xxx'},
{id: 4, postcode: 'xxx', street: 'xxx', city: 'xxx'},
];
const result = api_array.reduce((acc, item) => {
acc[`group_${item.id}`] = (acc[`group_${item.id}`] || []);
acc[`group_${item.id}`].push(item);
return acc;
}, {});
console.log(result);
,但出现此错误:
TypeError: init ()获得了意外的关键字参数'event_level'
这可能吗?
答案 0 :(得分:1)
Integrations参数是一个列表。您可以传递两种集成方式:
init(
integrations=[LoggingIntegration(...), DjangoIntegration(...)]
)