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 towinston-sentry-logger
)level
(String) - transport's level of messages to log (defaults toerror
)init
(Boolean) - true if transport must init sentry (defaults totrue
)debug
(Boolean) - used to log each action of logger and error (defaults tofalse
)sentryScope
(Function) - default custom scope function that can be set by winston-node-sentry when it init@node/sentry
(no default)
logger
(String) - defaults towinston-sentry-log
server_name
(String) - defaults toprocess.env.SENTRY_NAME
oros.hostname()
release
(String) - defaults toprocess.env.SENTRY_RELEASE
environment
(String) - defaults toprocess.env.SENTRY_ENVIRONMENT
)modules
(Object) - defaults topackage.json
dependenciesextra
(Object) - no default valuefingerprint
(Array) - no default value
For 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
- Docker
- Python
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