-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Support For Automatically Generating Breadcrumbs With Pino #4192
Comments
We probably need to build an integration for |
I'm trying to do some work on this. I've looked at the |
@Lilja that is importing the util node standard library: https://nodejs.org/api/util.html |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Until an official integration exists, here's a simple bridge between pino and the console log methods: import pino from 'pino'
import { Writable } from 'node:stream'
// By default, pino uses the `process.stdout` stream, which is not instrumented
// by Sentry. Sentry does instrument the methods on the `console` object, so we
// set up these streams to use the `console` object instead of `process.stdout`.
// This way, pino logs will be sent to Sentry.
function createConsoleStream(level: 'info' | 'warn' | 'error') {
return new Writable({
write(chunk: Buffer, _encoding, callback) {
// Both pino and the console methods add a trailing newline, so we slice
// off one character to avoid double newlines in the logs.
const msg = chunk.toString().slice(0, -1)
console[level](msg)
callback()
},
})
}
const consoleInfoStream = createConsoleStream('info')
const consoleWarnStream = createConsoleStream('warn')
const consoleErrorStream = createConsoleStream('error')
export const logger = pino(
{
level: 'info',
},
pino.multistream(
[
{ stream: consoleInfoStream },
{ level: 'warn', stream: consoleWarnStream },
{ level: 'error', stream: consoleErrorStream },
{ level: 'fatal', stream: consoleErrorStream },
],
{ dedupe: true }
)
)
Other log levels (if the |
Customer asking - wrote in with the following snippet for @sentry/node:
Breadcrumbs from logging currently only support the 'console' module.
The text was updated successfully, but these errors were encountered: