https://github.com/mderazon/bunyan-opbeat
Bunyan stream for Opbeat
https://github.com/mderazon/bunyan-opbeat
bunyan bunyan-opbeat bunyan-stream logger opbeat
Last synced: 6 months ago
JSON representation
Bunyan stream for Opbeat
- Host: GitHub
- URL: https://github.com/mderazon/bunyan-opbeat
- Owner: mderazon
- License: mit
- Created: 2016-04-21T12:11:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-12T10:48:16.000Z (over 9 years ago)
- Last Synced: 2025-10-20T06:40:41.701Z (9 months ago)
- Topics: bunyan, bunyan-opbeat, bunyan-stream, logger, opbeat
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# bunyan-opbeat
> Bunyan stream for [Opbeat](https://opbeat.com)
[](https://travis-ci.org/mderazon/bunyan-opbeat)
[](http://standardjs.com/)
## Install
``` sh
# install bunyan
$ npm i --save bunyan
# install bunyan-opbeat
$ npm i --save bunyan-opbeat
```
### Use
``` js
var bunyan = require('bunyan')
var BunyanOpbeat = require('bunyan-opbeat')
var log = bunyan.createLogger({
name: 'my-logger',
streams: [
{
level: 'warn',
type: 'raw', // <-- this is mandatory so bunyan-opbeat gets the log as an object
stream: new BunyanOpbeat({
config: {
appId: '...',
organizationId: '...',
secretToken: '...',
// you can also add any other parameter that opbeat module accepts, it will be passed on
}
})
}
]
})
log.error(new Error('whoops'))
```
Alternatively, if you've already started an opbeat instance somewhere else in your code, you can pass it directly to bunyan-opbeat and it will use it instead:
``` js
var bunyan = require('bunyan')
var BunyanOpbeat = require('bunyan-opbeat')
var opbeat = require('opbeat').start({
appId: '...',
organizationId: '...',
secretToken: '...'
})
var log = bunyan.createLogger({
name: 'my-logger',
streams: [
{
level: 'warn',
type: 'raw', // <-- this is mandatory so bunyan-opbeat gets the log as an object
stream: new BunyanOpbeat({
client: opbeat
})
}
]
})
log.error(new Error('whoops'))
```
* **note**: `bunyan-opbeat` requires `opbeat` client version >= 4.8.0
### How does it work?
bunyan-opbeat reads data coming from your bunyan logger and uses `opbeat.captureError()` to post it to Opbeat.
It will do it's best to pass on some common fields like `user`, `time`, `hostname` and `level`.
Anything else in your logs that opbeat can't understand will be passed as an `extra` field