npm install --save yet-another-logger
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);
});
});
});
-
LogManager ⇐
EventEmitter
- logManagerFactory(logglyConfig, [options])
-
Creates an instance of the LogManager class
Kind: global class
Extends: EventEmitter
See
Creates a bunyan instance
Kind: instance method of LogManager
Param | Type | Default |
---|---|---|
[options] | Object |
{} |
[cb] | function |
noop |
Creates a logger instance
Kind: instance method of LogManager
Param | Type | Default |
---|---|---|
[options] | Object |
{} |
[cb] | function |
|
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 |
Docs are generated from JSDocs via npm run docs