1.0.1 • Published 10 years ago

basiclogger v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

basiclogger

Copyright ©2014 Jared Bell

basiclogger is a very basic node.js logger. Instead of writing console.log() everywhere, you can use this. Has levels so you only see what you want even though you may be logging more. Future plans include being able to pipe to a log file while still outputing to stdout/stderr as configured.

Logging Levels

  • debug (stdout)
  • info (stdout)
  • warning (stderr)
  • error (stderr)

Install

npm install basiclogger

Example

var log = require('basiclogger');

//these are the allowed values for log.setLevel(level)
var levels = ['debug', 'info', 'warning', 'error'];

//run the test without setting the log level to show how the default level is debug
console.log('Log level not set, using default.');
doLogTests();

//cycle through each log level to see how setting the level affects which messages are displayed
levels.forEach(function (level) {
    console.log('Log level set to: ' + level);
    log.setLevel(level);
    doLogTests()
});

//attempt to log each of the levels
function doLogTests() {
    log.debug('This a debug log.');
    log.info('This an info log.');
    log.warning('This a warning log.');
    log.error('This an error log.');
}
1.0.1

10 years ago

1.0.0

10 years ago