node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

superconsole

superconsole

Note : Mostly a fork of console-trace created by Learnboost with more options.

Extends the native Node.JS console object to prefix logging functions with the CallSite information, timestamp and log level.

To read more about runtime stack trace introspection you can refer to this article.

Installation

$ npm install superconsole

Syntax:

require('superconsole')([options])

Available Options:

  • callsite - (Boolean: defaults to false) prepend the callsite info even without accessing methods from the t or traced getters.
  • level - (Boolean : defaults to false) prepend the log level to the log
  • timestamp - (Boolean : defaults to false) prepend the ISO Date to the log
  • logLevel - (String : defaults to "debug") call to console[level] under logLevel will be skipped
  • cwd - (String: defaults to process.cwd()) the path that will be stripped from the callsite info
  • colors - (Boolean|Object: defaults to true) terminal colors support flag or a custom color object
  • right - (Boolean: defaults to false) callsite alignment flag, when true prints infos on the right

Examples:

require('superconsole')

You can add the t or traced getter to your calls to obtain a stacktrace:

console.t.log('a');
console.traced.log('a');

Or:

require('superconsole')({
  callsite: true,
  level : true,
  timestamp : true,
  logLevel : 'info'
})
 

Credits