logbuddy-js
Version:
🪵 Your friendly neighborhood logging companion for Node.js applications with intelligent file rotation and flexible configuration
60 lines (49 loc) • 1.09 kB
JavaScript
class LogLevel {
static
static
static
static
static
static get Debug() {
return this.
}
static get Info() {
return this.
}
static get Warn() {
return this.
}
static get Error() {
return this.
}
static get Critical() {
return this.
}
static assert(log_level) {
if (
![this.Debug, this.Info, this.Warn, this.Error, this.Critical].includes(
log_level
)
) {
throw new Error(
`log_level must be an instance of LogLevel. Unsupported param ${JSON.stringify(
log_level
)}`
);
}
}
static to_string(log_level) {
const levelMap = {
[]: "DEBUG",
[]: "INFO",
[]: "WARN",
[]: "ERROR",
[]: "CRITICAL",
};
if (levelMap.hasOwnProperty(log_level)) {
return levelMap[log_level];
}
throw new Error(`Unsupported log level ${log_level}`);
}
}
module.exports = { LogLevel };