Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

console-blame

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-blame

It highlights and helps to find forgotten console.log calls in runtime

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

console-blame

NPM Version Build Status Coverage Status Dependency Status

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 methods
  • ConsoleBlame#trap(String[] ...methods) traps all listed methods
  • ConsoleBlame#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); // Will print debug message
console.error(123); // Will print debug message

Trap only console.log

require('console-blame')(['log']);

console.log(123); // Will print debug message

Trap only log and error of specific console object

require('console-blame')(console, ['log', 'error']);

console.log(123); // Will print debug message

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); // Will print debug message
blame.restore();
console.log(123); // Will NOT print debug message
blame.trap();
console.log(123); // Will print debug message

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 |

Keywords

FAQs

Package last updated on 25 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc