A simple, log4j style wrapper for logging. Easier to setup and use than the default Winston configuration.
npm install winston-simpleA simple, log4j style wrapper for Winston logging. Easier to setup
and use than the default Winston configuration.
node_modules folder, or you can install it globally.To install the latest version available on NPM:
npm install winston-simple
To install the latest development version:
npm install git+https://github.com/sseaman/winston-simple.git
none, which will disable logging for a specifed object.The full list of logging levels are:
``{ none, error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }`
``
{
"MyObjectName" : "debug",
"AnotherObject" : "info",
and so on
}
The above would set the the log level of MyObjectName to debug and AnotherObject to info. All other objects will have logging disabled.
key for the map. The value is the level of the logging to apply to all object.`
{
"all" : "debug"
}
`
The above would set all logging levels for all objects to "debug".You can also disable logging for all objects by setting the logging levels to:
`
{
"all" : "none"
}
`$3
winston-simple also support a combination of per object and global configuration. This allow a default log level to be
set for all object levels but different specific levels for certain objectsExample:
`
{
"all" : "debug",
"MyObjectName" : "info"
}
`$3
winston-simple defaults to the standard Winston configuration, but with the
addition of the Object name as a label.
This results in the following formatted log entry:`
2016-10-07T19:24:56.995Z - info: [MyObjectName] This is the log message
`$3
To set the log levels used by winston-simple first require the npm package and then set the logging level.
`
var Logger = require('winston-simple);
Logger.setLevels({
'all' : 'debug',
'MyObjectName' : 'info'
});
`You can the use the Logger to get a logger for use in your code:
`
var log = Logger.getLogger('MyObjectName');log.debug("This is a debug message");
`$3
winston-simple exposes it's underlying Winston instance so that you may
configure winston-simple however you want. To retreived the instance, simply call
getWinston() on your winston-simple instance. Any changes made to the
returned Winston object will be applied to all loggers.Example
-----
The following example shows the tightest way to initialize winston-simple./index.js
`
var log = require('winston-simple').setLevels(
{
'all' : 'info',
'SomeObject' : 'debug'
}).getLogger("Index");//some code....
log.info("This will be logged");
log.debug("This will NOT be logged");
`/lib/SomeObject.js
`
var log = require('winston-simple').getLogger('SomeObject');log.info("This will be logged");
log.debug("This will also be logged because it was configued in index.js");
``winston-simple is free software, licensed under the Apache License, Version 2.0.