superconsole
v2.0.2
Published
Prepends handy information before your logs as you wish (timestamp, callsite, loglevel).
Downloads
2,384
Readme
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 thet
ortraced
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 toprocess.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'
})