@icord/logger
v1.1.9
Published
A library for logging your projects to a new level!
Downloads
8
Readme
Installation
npm install @icord/logger
Usage
Example 1
import { Logger } from "@icord/logger";
const logger = new Logger("ClassName"); // options: { delay: true, writeStreamType: "stderr", timestamp: "en-US" }
logger.log("Log");
logger.error("Error");
logger.warn("Warn");
logger.success("Success");
logger.verbose("Verbose");
logger.event("Event");
logger.debug("Debug");
Example 2
import { Logger } from "@icord/logger";
class ExampleLogger {
private logger = new Logger(ExampleLogger.name, { delay: true, timestamp: "en-US" })
constructor() {
this.logger.log("Log");
this.logger.error("Error");
this.logger.warn("Warn");
this.logger.success("Success");
this.logger.verbose("Verbose");
this.logger.event("Event");
this.logger.debug("Debug");
}
}
Example 3
- Also make sure that the
"experimentalDecorators": true
option is enabled in your TypeScript config file tsconfig.json to use decorators.
import { IcordLogger, LoggerService } from "@icord/logger";
class ExampleLogger {
@IcordLogger(ExampleLogger.name, { /* options here */ })
logger!: LoggerService;
constructor() {
this.logger.log("Log");
this.logger.error("Error");
this.logger.warn("Warn");
this.logger.success("Success");
this.logger.verbose("Verbose");
this.logger.event("Event");
this.logger.debug("Debug");
}
}
Example
Options
- timestamp — Is not a declaration of a custom Timestamp type, which can take only three values:
"en-US"
,"de-DE"
or"ru-RU"
. - writeStreamType — Is an optional writeStreamType field that can take only two values:
"stdout"
or"stderr"
. - delay — Is an optional delay field that can take
boolean
values.