yet-another-logger
v0.5.0
Published
Manage logs with bunyan and loggly.
Downloads
14
Maintainers
Readme
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
Functions
LogManager ⇐ EventEmitter
Kind: global class
Extends: EventEmitter
See
- https://www.loggly.com/docs/node-js-logs/
- https://github.com/trentm/node-bunyan
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