yet-another-logger

0.5.0 • Public • Published

Yet Another Logger

Installation

npm install --save yet-another-logger

Usage

Central logger file, lets call logger.js

const logManager = require('yet-another-logger');

const logglyConfig = {
  token: 'secret-token',
  subdomain: 'subdomain name'
};

global.l = logManager(logglyConfig).loggerFactory({ name: 'app' });

Some other file

process.env.NODE_ENV = 'test';

const _ = require('lodash');
const chai = require('chai');

const expect = chai.expect;

after(function(done) {
  this.timeout(20 * 1000);
  console.log(l.getWaiting()) // prints number of logs waiting for confirmation from loggly
  l.onAllLogsReceived(done);
});

describe('foo', function() {
  this.timeout(10 * 1000);
  describe('foo.search', function() {
    it('should work', async function() {
      let res;
      try { res = foo.search() } catch(e) { log.error(e); }
      l.info('foo.search', res);
    });
  });
});

Documentation

Classes

LogManagerEventEmitter

Functions

logManagerFactory(logglyConfig, [options])

Creates an instance of the LogManager class

LogManager ⇐ EventEmitter

Kind: global class
Extends: EventEmitter
See

logManager.bunyanFactory([options], [cb])

Creates a bunyan instance

Kind: instance method of LogManager

Param Type Default
[options] Object {}
[cb] function noop

logManager.loggerFactory([options], [cb])

Creates a logger instance

Kind: instance method of LogManager

Param Type Default
[options] Object {}
[cb] function

logManagerFactory(logglyConfig, [options])

Creates an instance of the LogManager class

Kind: global function
See: LogManager

Param Type Default
logglyConfig Object
logglyConfig.token String
logglyConfig.subdomain String
[options] Object
[options.logToStdoutInDev] Boolean true

Contributing

Updating docs

Docs are generated from JSDocs via npm run docs

Package Sidebar

Install

npm i yet-another-logger

Weekly Downloads

2

Version

0.5.0

License

MIT

Last publish

Collaborators

  • 3handtypist