Sentry transport for winston 3.0.0
MIT License
This project aim to create a transport for winston 3.0.0 that send error to sentry.
import winston from 'winston'
import { SentryTransport } from 'winston-node-sentry'
let opts = {
level: 'info',
sentryOpts: {
dsn: 'YOUR-DSN'
}
}
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
new SentryTransport(opts)
]
})
Some default behavor is set feel free to see in code
You can pass some options to SentryTransport
{
debug: false,
level: 'info',
init: true,
sentry: NodeSentryModule,
sentryOpts: {},
sentryScope: (scope) => {}
}
Per options
variable above, here are the default options provided:
Transport related options:
name
(String) - transport's name (defaults to winston-sentry-logger
)level
(String) - transport's level of messages to log (defaults to error
)init
(Boolean) - true if transport must init sentry (defaults to true
)debug
(Boolean) - used to log each action of logger and error (defaultsfalse
)sentryScope
(Function) - default custom scope function that can be set by@node/sentry
(no default)options.sentryOps
)logger
(String) - defaults to winston-sentry-log
server_name
(String) - defaults to process.env.SENTRY_NAME
oros.hostname()
release
(String) - defaults to process.env.SENTRY_RELEASE
environment
(String) - defaults to process.env.SENTRY_ENVIRONMENT
)modules
(Object) - defaults to package.json
dependenciesextra
(Object) - no default valuefingerprint
(Array) - no default valueFor a full list of Sentry options, please visit https://docs.sentry.io/clients/node/config/.
First of all you must install package
$ yarn install
You can build source to javascript
$ yarn build
or you can generate sourceMap with it
$ yarn build:debug
When you're working on this module you can watch it
$ yarn watch
You can test if this modules works with sentry instance inside this repository
Start sentry instance
$ ./sentry/scripts/up.sh
Get sentry DSN
$ ./sentry/display-sentry-dsn.sh
Copy DSN inside test file
And execute tests
$ yarn test
This is written in typescript and use standard linter.
We use ts-lint
as linter with standard configuration, please if you submit
any pull respect lint you can check it
$ npm run lint