basiclogger

1.0.1 • Public • Published

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.');
}

Package Sidebar

Install

npm i basiclogger

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • compudaze