0.0.6 • Published 3 months ago

console-prod v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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

0.0.6

3 months ago

0.0.5

3 months ago

0.0.4

3 months ago

0.0.3

3 months ago

0.0.2

3 months ago

0.0.1

3 months ago