logophile
v2.0.4
Published
A basic logging utility based on winston
Downloads
25
Readme
Logophile
A basic logging utility based on winston.
Usage
To use the logger, just require the package as follows
const logger = require('logophile');
Log Levels
The following log levels can be used by this logger:
- debug
- info
- warn
- error
- trace
Each logger method can be called in the same way:
logger.info(message, logContext);
message -- string - The message describing the log
logContext -- object -- [ Optional ] Additional information you want to append to the log
NOTE: Error objects will be converted automatically to raw objects to expose potential appended properties.
Log Level Manipulation
To control what level logs are printed, users can set the level for the 'noisiest' logs they want to see:
Log Levels (From Highest Level to Lowest):
ERROR
WARN
INFO
TRACE
DEBUG
Additionally, you can use OFF
for silencing logs during unit tests.
API Documentation
log
Used to log messages when you don't want to include any other information. This is analogous to a console.log()
statement.
Usage:
logger.log('some message');
error
Logging an error message.
Usage:
logger.error('some message');
warn
Logging a warning message.
Usage:
logger.warn('some message');
info
Logging an info message.
Usage:
logger.info('some message');
debug
Logging a debug message.
Usage:
logger.debug('some message');
trace
Logging a trace message.
Usage:
logger.trace('some message');
setLogLevel
Changing the log level of the current object.
Usage:
logger.setLogLevel('info');
getLogLevel
Getting the current log level.
Usage:
logger.getLogLevel();
addGlobalLogContextKeys
Additional information you want to add to the global log context.
Usage:
logger.addGlobalLogContextKeys(keys);