console-suppress

0.1.1 • Public • Published

Console Suppress

Augments console methods with message suppressing capabilities. Very useful during testing.

Build status

Installation

This package is available on npm as: console-suppress

npm install --dev console-suppress

Basic usage

import console from 'console-suppress'
 
console.log.suppress(/undesired/)
console.log('some undesired log') // not logged to the console.

API

At the context of this documentation, suppressor means either a RegExp instance, a string (which will eventually be converted to a regex for comparison) or an array of the previous two.

Adding suppressors:

Method Arguments Description
console.suppress suppressor Registers a suppressor for all method calls.
console.log.suppress suppressor Registers a suppressor for console.log calls.
console.info.suppress suppressor Registers a suppressor for console.info calls.
console.warn.suppress suppressor Registers a suppressor for console.warn calls.
console.error.suppress suppressor Registers a suppressor for console.error calls.

Removing suppressors:

Method Arguments Description
console.cleanSuppressor suppressor Removes the given suppressor for any logging method calls.
console.log.cleanSuppressor suppressor Removes the given suppressor for console.log calls.
console.info.cleanSuppressor suppressor Removes the given suppressor for console.info calls.
console.warn.cleanSuppressor suppressor Removes the given suppressor for console.warn calls.
console.error.cleanSuppressor suppressor Removes the given suppressor for console.error calls.
console.cleanSuppressors [suppressor] Removes given suppressors (or all, if none provided) any logging method calls.
console.log.cleanSuppressors [suppressor] Removes given suppressors (or all, if none provided) for console.log calls.
console.info.cleanSuppressors [suppressor] Removes given suppressors (or all, if none provided) for console.info calls.
console.warn.cleanSuppressors [suppressor] Removes given suppressors (or all, if none provided) for console.warn calls.
console.error.cleanSuppressors [suppressor] Removes given suppressors (or all, if none provided) for console.error calls.

Package Sidebar

Install

npm i console-suppress

Weekly Downloads

168

Version

0.1.1

License

MIT

Unpacked Size

118 kB

Total Files

6

Last publish

Collaborators

  • lucasconstantino