https://github.com/its-alex/winston-node-sentry
Sentry transport for winston 3.0.0
https://github.com/its-alex/winston-node-sentry
nodejs sentry transport winston
Last synced: 6 months ago
JSON representation
Sentry transport for winston 3.0.0
- Host: GitHub
- URL: https://github.com/its-alex/winston-node-sentry
- Owner: Its-Alex
- License: mit
- Created: 2019-02-07T09:06:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T17:27:13.000Z (over 3 years ago)
- Last Synced: 2025-10-30T17:48:21.713Z (8 months ago)
- Topics: nodejs, sentry, transport, winston
- Language: PLpgSQL
- Size: 610 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# winston-node-sentry
This project aim to create a transport for winston 3.0.0 that send error to
sentry.
## How to use
## Example
```javascript
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](srcs/index.ts#L14)
### Options
You can pass some options to SentryTransport
```javascript
{
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 (defaults
to `false`)
- `sentryScope` (Function) - default custom scope function that can be set by
winston-node-sentry when it init `@node/sentry` (no default)
### Default Sentry Options (`options.sentryOps`)
- `logger` (String) - defaults to `winston-sentry-log`
- `server_name` (String) - defaults to `process.env.SENTRY_NAME` or
`os.hostname()`
- `release` (String) - defaults to `process.env.SENTRY_RELEASE`
- `environment` (String) - defaults to `process.env.SENTRY_ENVIRONMENT`)
- `modules` (Object) - defaults to `package.json` dependencies
- `extra` (Object) - no default value
- `fingerprint` (Array) - no default value
For a full list of Sentry options, please visit
.
## Development
### Start
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
```
## Tests
### Requirements
- Docker
- Python
### Manual
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](/__tests__/base.ts#L12)
And execute tests
```
$ yarn test
```
## Workflow
This is written in typescript and use standard linter.
### 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
```
## License
[MIT](https://en.wikipedia.org/wiki/MIT_License)