Skip to content

defvol/nulog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nulog

Switch off console.log

A custom logger to skip conditional statements when trying to mute logs.

If your code looks like this:

if (!process.env.TEST || !commandLineArguments.quiet)
  console.log('A message to log in production');

You can now initialize a nulog instance with a toggle variable that will send your logs to /dev/null if false is passed.

var logger = require('nulog')(!commandLineArguments.quiet);
logger.log('You will not see this msg when --quiet is true');