默认情况下,Sentry 具有集成,console.log
使其成为面包屑的一部分:
链接:导入名称:Sentry.Integrations.Console
我们如何使它也适用于bunyan logger,例如:
const koa = require('koa');
const app = new koa();
const bunyan = require('bunyan');
const log = bunyan.createLogger({
name: 'app',
..... other settings go here ....
});
const Sentry = require('@sentry/node');
Sentry.init({
dsn: MY_DSN_HERE,
integrations: integrations => {
// should anything be handled here & how?
return [...integrations];
},
release: 'xxxx-xx-xx'
});
app.on('error', (err) => {
Sentry.captureException(err);
});
// I am trying all to be part of sentry breadcrumbs
// but only console.log('foo'); is working
console.log('foo');
log.info('bar');
log.warn('baz');
log.debug('any');
log.error('many');
throw new Error('help!');
PS我已经尝试过bunyan-sentry-stream但没有成功@sentry/node,它只是推送条目而不是将它们视为面包屑。