Snaplog
This small tool allow you to enhance your logs in console. Use differents levels of log, create a progress bar, deeply inspect your objects and enhance your errors.
(Working progress) - only tested on nodejs 5.0 with ES6. I plan to convert in ES5 with Babel and so support older version of nodejs. Please, feel free to contribute.
Todo :
- support ES5 with Babel
- unit tests
Install
$ npm install snaplog --save
Usage
// Basic usagevar logger = ; // Set options to the loggerlogger // optional // Log in console with differents levelslogger;logger;logger;logger;logger;logger; // Create a progressbarvar progress = logger; ;;;; { progressnextdescription: message;}
Methods
.config(options) - This method allows you to set up the logger
- (String) Object
logger
-
.success(message) - print success log in terminal with colors
-
.info(message) - print info log in terminal with colors
-
.warn(message) - print warn log in terminal with colors
-
.error(message) - print error log in terminal with colors
-
.emergency(message) - print emergency log in terminal with colors
-
(String) message
logger;logger;logger;logger;logger;
.inspect(object, depth) - Deep inspection of an object
- (String) message
- (Number) depth
logger;
Progress bar
.progress(options) - Instanciate a new progress bar
- (Number) options.steps [required - set the total steps for the progression]
- (String) options.title [optional - set the log's title]
var progress = logger;
progress.next(options) - Push the next step
- (String) options.description [optional - description of the step - default:1]
- (String) options.steps [optional - number of steps to push - default:'']
progressnextdescription: 'Roger that !';