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 logestige
or
yarn add logestige
Usage
import { Logestige } from "logestige";
const logger = new Logestige();
logger.log("info", "Hello, world!"); // logs "Hello, world!" at the "info" level
You can also use the convenience methods error()
, warn()
, info()
, and debug()
:
logger.error("Something went wrong"); // logs "Something went wrong" at the "error" level
You 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 off
To 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:
error
warn
info
debug
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()