
logger
Author: Frank Gu <frank@voicelfow.com>
Date: Dec 11, 2019
A logging package for VERY fast and useful JSON logging.
- All log entries go to
process.stdout
- Minimal overhead and no logger hierarchies
- Multiple instantiations allowed
Usage
const Logger = require('@voiceflow/logger').default;
import Logger from '@voiceflow/logger';
const defaultOptions = {
level: 'info',
pretty: false,
};
const overrideOptions = {
level: 'trace',
pretty: true,
};
const defaultLogger = new Logger();
const customLogger = new Logger(overrideOptions);
defaultLogger.trace('this is a trace');
defaultLogger.debug('this is a debug');
defaultLogger.info('this is an info');
defaultLogger.warn('this is a warning');
defaultLogger.error('this is an error');
defaultLogger.fatal('this is a fatal');
customLogger.trace('this is a trace');
customLogger.debug('this is a debug');
customLogger.info('this is an info');
customLogger.warn('this is a warning');
customLogger.error('this is an error');
customLogger.fatal('this is a fatal');
Development Assitance
- For
warn
logs, the calling function and line number is included - For
error
and fatal
logs, the full call-stack is included
Pretty Printing
Pretty printing will add colors, parse unix epoch timestamps into UTC time.