console-blame
It highlights and helps to find forgotten console.log calls in runtime. Live example
Installation
console-blame
can be installed using npm
:
npm install console-blame --save-dev
Interface
ConsoleBlame(Object consoleObject, String[] trapsList)
ConsoleBlame(Object consoleObject)
ConsoleBlame(String[] trapsList)
ConsoleBlame()
ConsoleBlame#configure(Object options)
see Configuration options
ConsoleBlame#restore()
releases all trapped methodsConsoleBlame#trap(String[] ...methods)
traps all listed methodsConsoleBlame#trap()
traps all available methods
Configuration options
Can be configured, using require('console-blame').configure({ ... })
pathFormat
format of file name, line and column. default: '%s:%d:%d'
lineFormat
format of code line. default: '%d | %s'
contextSize
number of lines before and after target line. default: 3
sources
print source code? default: true
Example
Trap all methods of console
require('console-blame')();
console.log(123);
console.error(123);
Trap only console.log
require('console-blame')(['log']);
console.log(123);
Trap only log and error of specific console object
require('console-blame')(console, ['log', 'error']);
console.log(123);
Trap all methods and change size of context and line format
require('console-blame')().configure({
contextSize: 5,
lineFormat: '%d\t%s'
});
console.log(123);
Restore traps
var blame = require('console-blame')();
console.log(123);
blame.restore();
console.log(123);
blame.trap();
console.log(123);
Output example
A log message
/home/username/projects/console-blame/lib/index.js:174:9
169 | attachTrapsTo(console).configure({
170 | contextSize: 5,
171 | lineFormat: '%d\t%s'
172 | });
173 |
174 | console.log('A log message'); // <<< This line will be highlighted
175 |