Novelty Promotes Magicians
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

log_

0.0.4 • Public • Published

log_

console.log + color + prefix for node.js

Installation

npm install --save log_

Usage

var log = require('log_')('server', 'blue');
 
// Basic logging
log('starting on port 8080');
 
// Error messages
log.warn('server crashed!');

This logs the following:

[server] starting on port 8080
[server] server crashed!

Available Colors

var Log = require('log_');
console.log(Log.colors);
 
// outputs the following
{
  'reset':      '\u001b[0m',
  'bold':       '\u001b[1m',
  'italic':     '\u001b[3m',
  'underline':  '\u001b[4m',
  'blink':      '\u001b[5m',
  'black':      '\u001b[30m',
  'red':        '\u001b[31m',
  'green':      '\u001b[32m',
  'yellow':     '\u001b[33m',
  'blue':       '\u001b[34m',
  'magenta':    '\u001b[35m',
  'cyan':       '\u001b[36m',
  'white':      '\u001b[37m'
}

Enabling and Disabling

var Log, log;
 
Log = require('log_');
log = Log('test', 'green');
 
log('enabled by default');
 
Log.disable();
log('disabling the logs');
log.warn('no one can hear you');
 
Log.enable();
log('enable the logs again');

[server] enabled by default
[server] enable the logs again

install

npm i log_

Downloadsweekly downloads

12

version

0.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar