console-prod
v0.0.6
Published
Hide console logs in production
Downloads
6
Maintainers
Readme
console-prod
Hide console logs in production
This library overrides the default console object, making it non-functional in a production environment.
Install
npm install console-prodUsage
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 bedPROD
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 bedNote: 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.
