1.0.0 • Published 8 years ago

good-logmatic v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

good-logmatic

Good Reporter for Logmatic

npm i -S good-logmatic

Config

You need to pass down two config objects to good-logmatic for him to work.

{
  token: undefined, // Required : your Logmatic token
  tcp: {
    host: 'api.logmatic.io',
    port: 10515
  },
  retryTimeout: 5000, // when failling to reconnect, this timeout if used for each retry
  defaultProps: {}, // add a default value to your log messages (like appname or hostname)
  logger: { //Define the logging functions used
    debug: _.noop,
    info: console.log.bind(console),
    warn: console.warn.bind(console),
    error: console.error.bind(console)
  }
}

Notes:

  • There is only one mandatory field for you to define : your logmatic token
  • The tcp object is passed to node tls.connect.

Examples

var GoodLogmatic = require('good-logmatic');
hapi.register({
  register : require('good'),
  options : {
    reporters : [
      new GoodLogmatic({
        log : '*',
        request : '*',
        error : '*',
        response : '*',
        ops : '*',
      }, { // your config
        token : 'YOUR LOG TOKEN',
      }),
    ],
  },
}, function(err) {
  if (err) {
    throw err;
  }
});
var GoodLogmatic = require('good-logmatic');
hapi.register({
  register : require('good'),
  options : {
    reporters : [
      new GoodLogmatic({
        log : '*',
        request : '*',
        error : '*',
        response : '*',
        ops : '*',
      }, { // your config
        token : 'YOUR LOG TOKEN',
        defaultProps: {
          appname: require('./package.json').name,
          hostname: 'prod'
        },
        logger: require('winston')
      }),
    ],
  },
}, function(err) {
  if (err) {
    throw err;
  }
});