console-prod
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

console-prod

npm package Build Status Downloads Issues Package Size

Hide console logs in production

This library overrides the default console object, making it non-functional in a production environment.

Install

npm install console-prod

Usage

Import at the root of your project

For Example, in a NextJS app, that'll be _app.js.

// _app.js

import 'console-prod';

In Dev mode, the console methods have their default behavior. In production, all methods are void functions and will do nothing.

DEV or STAGING
import 'console-prod';

console.log('Wild fire on the ocean bed');
// => Wild fire on the ocean bed
PROD
import 'console-prod';

console.log('Wild fire on the ocean bed');
// => 

To override this behaviour and force logs in prod, use the console.prod method. Which is a direct implementation of the default console object.

PROD
import 'console-prod';

console.prod.log('Wild fire on the ocean bed');
// => Wild fire on the ocean bed

Note: The above examples also goes for all other console methods e.g warn, error, info, table, etc.

Server-side

In a server environment, console methods are not affected and function just as the default console methods.

API

console: Console

console.prod: Console

Package Sidebar

Install

npm i console-prod

Weekly Downloads

3

Version

0.0.6

License

MIT

Unpacked Size

5.15 kB

Total Files

6

Last publish

Collaborators

  • emekaorji