https://github.com/khezen/bunyancat
extend bunyan logger integrating useful streams
https://github.com/khezen/bunyancat
bunyan bunyan-stream javascript logger logging nodejs
Last synced: about 2 months ago
JSON representation
extend bunyan logger integrating useful streams
- Host: GitHub
- URL: https://github.com/khezen/bunyancat
- Owner: khezen
- License: mit
- Created: 2017-03-18T15:02:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-18T15:52:49.000Z (over 9 years ago)
- Last Synced: 2025-04-22T19:13:18.750Z (about 1 year ago)
- Topics: bunyan, bunyan-stream, javascript, logger, logging, nodejs
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.org/package/bunyancat)
# get started
## Instanciate a logger
* We are using default values in the example below:
```javascript
const bunyan = require("bunyancat");
let log = bunyan.createLogger({
name: "helloworld",
stdout:{
level: "debug",
},
rotatingFile: {
path: "/var/logs/helloworld",
period: "1d",
count: 7,
level: "info"
},
logstash: {
host: "localhost",
port: 5000,
level: "info",
tags: null
},
rollbar: {
token: "rollback access token",
rollbarOptions: {} // Options to pass to rollbar.init()
},
kafka: {
host: "localhost",
port: 2181,
level: "info",
topic: "log-helloworld-topic"
},
slack: {
webhook: "slack webhook url",
channel: "slack channel",
username: "bunyancat",
level: "error"
}
});
log.info('hi');
log.warn({lang: 'fr'}, 'au revoir');
```
* Bunyan will have stdout stream only in the example below:
```javascript
const bunyan = require("bunyancat");
let log = bunyan.createLogger({
name: "helloworld"
});
log.info('hi');
log.warn({lang: 'fr'}, 'au revoir');
```
## Inheritence
Bunyan has a concept of a child logger to specialize a logger for a sub-component of your application, i.e. to create a new logger with additional bound fields that will be included in its log records. A child logger is created with `log.child(...)`.
```javascript
const bunyan = require("bunyancat");
let log = bunyan.createLogger({
name: "helloworld"
});
function Wuzzle(options) {
this.log = options.log.child({widget_type: 'wuzzle'});
this.log.info('creating a wuzzle')
}
Wuzzle.prototype.woos = function () {
this.log.warn('This wuzzle is woosey.')
}
log.info('start');
var wuzzle = new Wuzzle({log: log});
wuzzle.woos();
log.info('done');
```