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", "name": "@ztimson/js-utilities",
"version": "0.2.0", "version": "0.2.1",
"description": "JavaScript Utility library", "description": "JavaScript Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

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