This package has been deprecated

Author message:

No longer maintained.

long-con

0.1.3 • Public • Published

long-con

Create a console logger w/ formatting, timestamp, color, namespace

Build Status

Examples

stdout, timestamp, namespaces

var longCon = require('long-con');.create();
longCon.set('time', true).set('namespace', 'myLib');
 
var log = longCon.create('cache');
 
// [Sun, 21 Apr 2013 21:33:20 GMT] myLib cache
log('hit key: %s', 'key-name');

stderr, color, no namespace

// namespace: white foreground, red background
// body: white foreground, green background
var log = longCon.create(null, console.error, 'white.bgRed', 'white.bgGreen');

See cli-color for color names.

Automatic object-specific stack trace

function Klass() {
  this.console = longCon.create();
  this.log = this.console.create(null, console.log);
  this.console.traceMethods('Klass', this, this.log, Klass.prototype);
}
Klass.prototype.foo = function() {
  this.log('foo1');
  this.bar();
  this.log('foo2');
};
Klass.prototype.bar = function() {
  this.log('bar1');
  this.baz();
  this.log('bar2');
};
Klass.prototype.baz = function() {
  this.log('baz');
};
(new Klass()).foo();

Output:

Klass#foo
|    foo1
|    Klass#bar
|    |    bar1
|    |    Klass#baz
|    |    |    baz
|    |    bar2
|    foo2

See traceMethods().

Manual stack trace

var log = longCon.create(null, console.log);
log.push('foo');
log('msg1')
log.push('bar')
log('msg2')
log.pop();
log.pop();
log('msg3');
foo
|    msg1
|    bar
|    |    msg2
msg3

Installation

NPM

npm install long-con

API

Documentation

License

MIT

Tests

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i long-con

Weekly Downloads

7

Version

0.1.3

License

MIT

Last publish

Collaborators

  • codeactual