thefp-logger
v1.0.2
Published
common library to log in a standard format to stdout and stderr.
Downloads
4
Readme
logger
common library to log in a standard format to stdout and stderr.
usage
const Logger = require('fondation-patrimoine/logger');
const logger = new Logger(__filename);
// simple string log
logger.trace('hello');
logger.debug('hello');
logger.info('hello');
logger.warn('hello');
logger.error('hello');
// advanced logging
logger.info({
httpCode: 403,
message: 'Forbidden to create book',
error : new Error('a very odd error occurred'),
correlationId: 'ddcdcf3b991c94152ef0fe95b1e549c734438ec5',
});
Log level
default
default log level is 'INFO'
environment variable
to set log level from an env variable, define LOG_LEVEL
runtime
to set log level at runtime :
logger.setLevel('DEBUG');