Skip to content

Latest commit

 

History

History
70 lines (47 loc) · 1.13 KB

README.md

File metadata and controls

70 lines (47 loc) · 1.13 KB

Logging utility for Node.js/io.js. Logs to stderr.

Designed to be as simple as possible. No:

  • dependencies;
  • log level control;
  • colors;
  • log servers.

Supports:

  • named logs;
  • four levels: default, warn, error, TODO.

Installation

$ npm install stupid-log

Usage

Top-level log:

var log = require('stupid-log');

log('obj:', { x: 1 });
// obj: { x: 1 }

log.warn('obj:', { x: 1 });
// {WARN} obj: { x: 1 }

log.error('obj:', { x: 1 });
// {ERROR} obj: { x: 1 }

log.TODO('handle this case properly');
// {TODO} handle this case properly

Named log:

var log = require('stupid-log').for('component');

log('obj:', { x: 1 });
// [component] obj: { x: 1 }

log.warn('obj:', { x: 1 });
// [component] {WARN} obj: { x: 1 }

log.error('obj:', { x: 1 });
// [component] {ERROR} obj: { x: 1 }

log.TODO('handle this case properly');
// [component] {TODO} handle this case properly

As separate functions (ES6 syntax):

const log = require('stupid-log').for('component'),
  {warn, error, TODO} = log;

log('obj:', { x: 1 });
warn('obj:', { x: 1 });
error('obj:', { x: 1 });
TODO('handle this case properly');