Skip to content

Simple and lightweight logger that writes to a stream

License

Notifications You must be signed in to change notification settings

lpinca/stream-log-level

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stream-log-level

Version npm Build Status Coverage Status

Simple and lightweight logger that writes to a stream.

This module is like console-log-level but instead of using the console object it uses a given stream.

Log levels supported: trace, debug, info, warn, error and fatal.

Install

npm install --save stream-log-level

Usage

var logger = require('stream-log-level');

var log = logger();

log.trace('a'); // => does nothing
log.debug('b'); // => does nothing
log.info('c'); // => writes 'c\n' to STDOUT
log.warn('d'); // => writes 'd\n' to STDOUT
log.error('e'); // => writes 'e\n' to STDOUT
log.fatal('f'); // => writes 'f\n' to STDOUT

Options

The logger can be configured by passing in an options object:

var logger = require('stream-log-level');

var log = logger({
  prefix: function () {
    return new Date().toISOString();
  },
  level: 'info'
});

Supported options:

Name Description Type Default value
level Specify the log level String info
prefix Set a prefix for all log messages String or Function undefined
stream The stream to write to Stream process.stdout

License

MIT

About

Simple and lightweight logger that writes to a stream

Resources

License

Stars

Watchers

Forks

Packages

No packages published