Changed logger events
All checks were successful
Build / Build NPM Project (push) Successful in 30s
Build / Tag Version (push) Successful in 12s
Build / Publish (push) Successful in 21s

This commit is contained in:
Zakary Timson 2024-02-28 19:23:58 -05:00
parent d4996201cf
commit 24edc4a12d
2 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/js-utilities",
"version": "0.2.0",
"version": "0.2.1",
"description": "JavaScript Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -68,36 +68,41 @@ export class Logger extends TypedEmitter<LoggerEvents> {
debug(...args: string[]) {
if(LOG_LEVEL.VERBOSE >= Logger.LOG_LEVEL) {
Logger.emit(LOG_LEVEL.VERBOSE, ...args);
console.debug(CliForeground.LIGHT_GREY + this.format(...args) + CliEffects.CLEAR);
const str = this.format(...args);
Logger.emit(LOG_LEVEL.VERBOSE, str);
console.debug(CliForeground.LIGHT_GREY + str + CliEffects.CLEAR);
}
}
error(...args: string[]) {
if(LOG_LEVEL.ERROR >= Logger.LOG_LEVEL) {
Logger.emit(LOG_LEVEL.ERROR, ...args);
console.error(CliForeground.RED + this.format(...args) + CliEffects.CLEAR);
const str = this.format(...args);
Logger.emit(LOG_LEVEL.ERROR, str);
console.error(CliForeground.RED + str + CliEffects.CLEAR);
}
}
info(...args: string[]) {
if(LOG_LEVEL.INFO >= Logger.LOG_LEVEL) {
Logger.emit(LOG_LEVEL.INFO, ...args);
console.info(CliForeground.CYAN + this.format(...args) + CliEffects.CLEAR);
const str = this.format(...args);
Logger.emit(LOG_LEVEL.INFO, str);
console.info(CliForeground.CYAN + str + CliEffects.CLEAR);
}
}
log(...args: string[]) {
if(LOG_LEVEL.INFO >= Logger.LOG_LEVEL) {
Logger.emit(LOG_LEVEL.INFO, ...args);
console.log(CliEffects.CLEAR + this.format(...args));
const str = this.format(...args);
Logger.emit(LOG_LEVEL.INFO, str);
console.log(CliEffects.CLEAR + str);
}
}
warn(...args: string[]) {
if(LOG_LEVEL.WARN >= Logger.LOG_LEVEL) {
Logger.emit(LOG_LEVEL.WARN, ...args);
console.warn(CliForeground.YELLOW + this.format(...args) + CliEffects.CLEAR);
const str = this.format(...args);
Logger.emit(LOG_LEVEL.WARN, str);
console.warn(CliForeground.YELLOW + str + CliEffects.CLEAR);
}
}
}