Loggabat
Special Logger for filtering logs you need in production, and logs you need in test mode only.
Do not dread over which comments you need to eliminate before production, LoggaBat got ur' back!!
Get a full history of all messages you have logged to your console, just at the call of a function
const loggabat = productionMode: processenvNODE_ENV; loggabat;
Features
-
Selectively log messages to your console, by flags
-
Organize all your logs to your console
-
Recollect all messages you have logged
Installation
Loggabat requires [JS] to run.
Install the dependency via npm
npm install --save loggabat
Importing
// Using Node.js - const Loggabat = require; // Using ES6 importsimport Loggabat from 'loggabat';
Usage
Creating a new loggabat:
const loggabat = productionMode: true // I am running in production mode prefix: "My app name space";
Setting environments:
// First approach, through a constructorconst loggabat = productionMode: true ; // Second approachloggabat; // Environment in test mode nowloggabat; // Environment in production mode now
loggabat; // corresponds to console.info()loggabat; // corresponds to console.log()loggabat; // corresponds to console.warn()loggabat; // corresponds to console.error()
Logging to your console:
const loggabat = productionMode: true // I am running in production mode prefix: "My app name space"; loggabat; // {nothing happens} loggabat; // My app name space: I am confirmedloggabat; // My app name space: I am confirmed loggabat; // In test environment now loggabat; // My app name space: I am confirmedloggabat; // My app name space: I am confirmedloggabat; // My app name space: I am confirmed
All messages you need in production should be preceeded by "prod()" or "production()". This identifies your log message as a production-friendly one. Only production-friendly messages will be logged and recorded in a production environment
Setting your prefix:
// Assuming loggabat is already in test modeloggabat; loggabat; // My app's new name: App crashed
Getting your prefix set to your Loggabat instance:
const loggabat = prefix: "Waist Training App" ;loggabatprefix; // Waist Training App
Determine prefix set already for a Loggabat instance:
const loggabat = ;loggabat; // false loggabat;loggabat; // true
Getting history of all successful logs:
loggabat; // In production mode now, only production-friendly messages are accepted loggabat; // {nothing happens - not added to history}loggabat; // Crucibles {Saved to history} loggabat; // In test mode nowloggabat; // Tahoes {Saved to history}loggabat; // Placenta {Saved to history} loggabat;// [// { type: 'info', logged:'true', message: "Crucibles"}, // {..., message:'Tahoes'},// {..., message:'Placenta'}// ]
Resetting your history:
loggabat; // clears historyloggabat // Returns -> []
Misc
Project is in its early stages and all contributions are welcome.
Contribution Guide
Documentation to follow soon
License
MIT © Justice Appiah