scout-winston
A tiny custom configuration module around Winston logger.
This Winston configuration module is a result of having the same custom configuration logic over multiple backend services powering the Scout Finance app, which got abstracted away to avoid repeating it over and over again.
Also, this module is pretty much not intended to have a wide public adoption, it's a result of our custom needs. Still, if you like the approach - feel free to use it.
How to install
$ npm install scout-winston
How to use
At your application startup, invoke this module passing it an options object, containing general logger configuration, and specific configuration for each of the supported loggers.
require('scout-winston').init({
console: {
treshold : 'error',
timestamp: true,
colorize : true,
},
file: {
treshold : 'info',
timestamp: true,
logfile: '/path/to/logfile'
}
});
var log = require('winston');
log.info('This is an "info" level log message');
Calling init()
on the scout-winston
module configures Winston logger according
to the custom configuration provided. Afterwards, all the logging is made by using
winston
directly, as shown in the above example. Without the scout-winston
initialization, Winston will just work with its default configuration.
Log levels are Winston's default:
silly
, debug
, verbose
, info
, warn
, error
.
Supported options:
console
- console logger optionstreshold
- minimum log level for messages to be logged; empty value, or any value outside of configured log levels disables the loggertimestamp
- option to add timestamps to log messages; defaults totrue
colorize
- option to color the output; defaults totrue
file
- file logger optionstreshold
- same as abovetimestamp
- same as abovelogfile
- path to the log file; defaults tolog/scout-winston.log
Changelog
- 0.2.0 - Change Array.includes from a prototype to a helper function due to weird behaviour with Lodash
- 0.1.0 - Initial release