Global toggleable logger for Node.js projects
npm install anmp-loggeranmp-logger
Global toggleable logger for Node.js projects.
anmp-logger is a lightweight logging utility that allows you to enable or disable
logs globally without removing log statements from your code. It is designed as
a clean replacement for console.log using anmp.log, anmp.warn, and anmp.error.
------------------------------------------------------------
INSTALLATION
npm install anmp-logger
------------------------------------------------------------
BASIC USAGE
const anmp = require('anmp-logger');
anmp.log("This is a log message");
anmp.warn("This is a warning message");
anmp.error("This is an error message");
------------------------------------------------------------
ENABLE / DISABLE LOGGING AT RUNTIME
anmp.disable();
anmp.log("This will NOT be printed");
anmp.enable();
anmp.log("Logging enabled again");
Check current status:
console.log(anmp.enabled); // true or false
------------------------------------------------------------
COMMAND LINE FLAGS
Enable logging:
node app.js -eanmp
Disable logging:
node app.js -danmp
Command-line flags override default behavior.
------------------------------------------------------------
ENVIRONMENT VARIABLE CONTROL
Disable logs globally:
Linux / macOS:
export ANMP_LOGS=false
node app.js
Windows (PowerShell):
setx ANMP_LOGS false
node app.js
------------------------------------------------------------
RECOMMENDED USAGE WITH NODE_ENV
const anmp = require('anmp-logger');
if (process.env.NODE_ENV === 'development') {
anmp.enable();
} else {
anmp.disable();
}
------------------------------------------------------------
API
anmp.log(...args)
anmp.warn(...args)
anmp.error(...args)
anmp.enable()
anmp.disable()
anmp.set(value)
anmp.enabled
------------------------------------------------------------
WHY USE anmp-logger
- No need to remove console.log statements
- Centralized logging control
- Production-safe
- Zero dependencies
- Clean and predictable behavior
------------------------------------------------------------
PROJECT STRUCTURE
anmp-logger/
├─ src/index.js
├─ package.json
├─ README
├─ LICENSE
------------------------------------------------------------
LICENSE
MIT License
Copyright (c) 2025 Akshay Patil