1.0.7 • Published 6 years ago

ctz-bunyan v1.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

NPM Version

get started

Instanciate a logger

  • We are using default values in the example below:
const bunyan = require("ctz-bunyan");

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()
  }
});

log.info('hi');
log.warn({lang: 'fr'}, 'au revoir');
  • Bunyan will have stdout stream only in the example below:
const bunyan = require("ctz-bunyan");

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(...).

const bunyan = require("ctz-bunyan");

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');
1.0.7

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago