disable-js-log
v3.1.0
Published
A simple utility to selectively disable console logs in JavaScript applications.
Maintainers
Readme
disable-js-log
A simple utility to selectively disable console logs in JavaScript applications.
Install
npm install disable-js-logAPI
muteConsole(config?)
Pass a config object where each key is a console method. Value true silences it entirely; an array of strings suppresses only messages matching those patterns.
Available methods: log, debug, warn, error, info, assert
import { muteConsole } from 'disable-js-log'
muteConsole({
log: true, // silence entirely
debug: true, // silence entirely
error: ['findDOMNode', 'pattern'], // suppress matching messages only
})allowConsole(config?)
Inverse of muteConsole — specify which methods to keep, and all others are silenced. Same config shape: true keeps the method active, an array keeps it active but filters matching messages.
import { allowConsole } from 'disable-js-log'
allowConsole({
error: true, // keep error active
warn: ['noisy warning text'], // keep warn but suppress matching messages
// log, debug, info, assert are silenced
})Built-in suppressions
The following console.error messages are suppressed by default (known library noise), even without any config:
findDOMNode is deprecated— antd / rc-resize-observer internal warningSupport for defaultProps will be removed— React 18 deprecation
