logestige v5.3.3
Logestige
Logestige is a customizable logging utility for JavaScript applications. It allows you to log messages at different levels and selectively turn logging on or off for specific levels.
Installation
Logestige can be installed via npm or yarn:
npm install logestigeor
yarn add logestigeUsage
import { Logestige } from "logestige";
const logger = new Logestige();
logger.log("info", "Hello, world!"); // logs "Hello, world!" at the "info" levelYou can also use the convenience methods error(), warn(), info(), and debug():
logger.error("Something went wrong"); // logs "Something went wrong" at the "error" levelYou can also override the default console methods by calling overrideConsole(). This will replace the default console methods with the corresponding Logestige methods:
const logger = new Logestige();
logger.overrideConsole(); // replaces default console methods with Logestige methods
console.log("info", "This will be logged by Logestige"); // this will be logged by Logestige with the level of "info".Log Levels
By default, all log levels are enabled. You can selectively turn logging on or off for specific levels by calling on() or off() with the appropriate level(s). For example to turn off the "debug" level:
logger.off("debug"); // turns off logging for the "debug" level
logger.debug("This won't be logged"); // this won't be logged because "debug" logging is turned offTo turn on the "debug" level:
logger.on("debug"); // turns logging back on for the "debug" level
logger.debug("This will be logged now");The available logging levels are:
errorwarninfodebug
You can log messages at a specific level by calling the corresponding method:
logger.error("Something went wrong");
logger.warn("This could be a problem");
logger.info("Just an FYI");
logger.debug("Debugging information");You can turn all logging levels on or off by calling onAll() or offAll()