Giter Club home page Giter Club logo

console-prod's Introduction

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

console-prod's People

Contributors

emekaorji avatar

Stargazers

Shodipo Ayomide avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.