@contrail/app-framework
Advanced tools
Comparing version 1.0.9 to 1.0.10
export declare class Logger { | ||
allEntries: Array<string>; | ||
private level; | ||
allEntries: any[]; | ||
private fatalOn; | ||
private errorOn; | ||
private warnOn; | ||
private infoOn; | ||
private debugOn; | ||
private traceOn; | ||
constructor(_config?: {}); | ||
isFatalOn(): boolean; | ||
isErrorOn(): boolean; | ||
isWarnOn(): boolean; | ||
isInfoOn(): boolean; | ||
isDebugOn(): boolean; | ||
isTraceOn(): boolean; | ||
fatal(...args: any[]): void; | ||
error(...args: any[]): void; | ||
warn(...args: any[]): void; | ||
info(...args: any[]): void; | ||
debug(...args: any[]): void; | ||
trace(...args: any[]): void; | ||
log(...args: any[]): void; | ||
@@ -4,0 +24,0 @@ getEntries(): string; |
@@ -5,5 +5,98 @@ "use strict"; | ||
class Logger { | ||
constructor() { | ||
constructor(_config = {}) { | ||
this.level = 'error'; | ||
this.allEntries = []; | ||
this.fatalOn = true; | ||
this.errorOn = true; | ||
this.warnOn = false; | ||
this.infoOn = false; | ||
this.debugOn = false; | ||
this.traceOn = false; | ||
let configLevel = _config['logLevel']; | ||
if (configLevel) { | ||
configLevel = configLevel.toLowerCase(); | ||
} | ||
else { | ||
configLevel = 'error'; | ||
} | ||
if (['fatal', 'error', 'warn', 'info', 'debug', 'trace'].includes(configLevel)) { | ||
this.level = configLevel; | ||
} | ||
this.fatalOn = this.errorOn = this.warnOn = this.infoOn = this.debugOn = this.traceOn = false; | ||
switch (this.level) { | ||
case 'fatal': | ||
this.fatalOn = true; | ||
this.errorOn = this.warnOn = this.infoOn = this.debugOn = this.traceOn = false; | ||
break; | ||
case 'error': | ||
this.fatalOn = this.errorOn = true; | ||
this.warnOn = this.infoOn = this.debugOn = this.traceOn = false; | ||
break; | ||
case 'warn': | ||
this.fatalOn = this.errorOn = this.warnOn = true; | ||
this.infoOn = this.debugOn = this.traceOn = false; | ||
break; | ||
case 'info': | ||
this.fatalOn = this.errorOn = this.warnOn = this.infoOn = true; | ||
this.debugOn = this.traceOn = false; | ||
break; | ||
case 'debug': | ||
this.fatalOn = this.errorOn = this.warnOn = this.infoOn = this.debugOn = true; | ||
this.traceOn = false; | ||
break; | ||
case 'trace': | ||
this.fatalOn = this.errorOn = this.warnOn = this.infoOn = this.debugOn = this.traceOn = true; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
isFatalOn() { | ||
return this.fatalOn; | ||
} | ||
isErrorOn() { | ||
return this.errorOn; | ||
} | ||
isWarnOn() { | ||
return this.warnOn; | ||
} | ||
isInfoOn() { | ||
return this.infoOn; | ||
} | ||
isDebugOn() { | ||
return this.debugOn; | ||
} | ||
isTraceOn() { | ||
return this.traceOn; | ||
} | ||
fatal(...args) { | ||
if (this.fatalOn) { | ||
this.log(args); | ||
} | ||
} | ||
error(...args) { | ||
if (this.errorOn) { | ||
this.log(args); | ||
} | ||
} | ||
warn(...args) { | ||
if (this.warnOn) { | ||
this.log(args); | ||
} | ||
} | ||
info(...args) { | ||
if (this.infoOn) { | ||
this.log(args); | ||
} | ||
} | ||
debug(...args) { | ||
if (this.debugOn) { | ||
this.log(args); | ||
} | ||
} | ||
trace(...args) { | ||
if (this.traceOn) { | ||
this.log(args); | ||
} | ||
} | ||
log(...args) { | ||
@@ -10,0 +103,0 @@ console.log(...args); |
{ | ||
"name": "@contrail/app-framework", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "The app framework for VibeIQ Apps.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
17162
422