Mercurial > hg > orthanc-stone
comparison Platforms/Wasm/logger.ts @ 603:70992b38aa8a
new routable logging system in STDIO mode + flag support (with no value) in StartupParametersBuilder + 80 col indent
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 29 Apr 2019 15:09:48 +0200 |
parents | 548eed46f535 |
children | 4eccf698e52f |
comparison
equal
deleted
inserted
replaced
602:03c4b998fcd0 | 603:70992b38aa8a |
---|---|
6 export class StandardConsoleLogger { | 6 export class StandardConsoleLogger { |
7 public showSource: boolean = true; | 7 public showSource: boolean = true; |
8 | 8 |
9 public debug(...args: any[]): void { | 9 public debug(...args: any[]): void { |
10 this._debug(LogSource.Typescript, ...args); | 10 this._debug(LogSource.Typescript, ...args); |
11 } | |
12 | |
13 public debugFromCpp(...args: any[]): void { | |
14 this._debug(LogSource.Cpp, ...args); | |
11 } | 15 } |
12 | 16 |
13 public info(...args: any[]): void { | 17 public info(...args: any[]): void { |
14 this._info(LogSource.Typescript, ...args); | 18 this._info(LogSource.Typescript, ...args); |
15 } | 19 } |
20 | 24 |
21 public warning(...args: any[]): void { | 25 public warning(...args: any[]): void { |
22 this._warning(LogSource.Typescript, ...args); | 26 this._warning(LogSource.Typescript, ...args); |
23 } | 27 } |
24 | 28 |
29 public warningFromCpp(message: string): void { | |
30 this._warning(LogSource.Cpp, message); | |
31 } | |
32 | |
25 public error(...args: any[]): void { | 33 public error(...args: any[]): void { |
26 this._error(LogSource.Typescript, ...args); | 34 this._error(LogSource.Typescript, ...args); |
27 } | 35 } |
28 | 36 |
29 public errorFromCpp(message: string): void { | 37 public errorFromCpp(message: string): void { |
30 this._error(LogSource.Cpp, message); | 38 this._error(LogSource.Cpp, message); |
31 } | 39 } |
32 | 40 |
33 public _debug(source: LogSource, ...args: any[]): void { | 41 public _debug(source: LogSource, ...args: any[]): void { |
34 var output = this.getOutput(source, args); | 42 if ((<any> window).IsTraceLevelEnabled) |
35 console.debug(...output); | 43 { |
44 if ((<any> window).IsTraceLevelEnabled()) | |
45 { | |
46 var output = this.getOutput(source, args); | |
47 console.debug(...output); | |
48 } | |
49 } | |
36 } | 50 } |
37 | 51 |
38 private _info(source: LogSource, ...args: any[]): void { | 52 private _info(source: LogSource, ...args: any[]): void { |
39 var output = this.getOutput(source, args); | 53 if ((<any> window).IsInfoLevelEnabled) |
40 console.info(...output); | 54 { |
55 if ((<any> window).IsInfoLevelEnabled()) | |
56 { | |
57 var output = this.getOutput(source, args); | |
58 console.info(...output); | |
59 } | |
60 } | |
41 } | 61 } |
42 | 62 |
43 public _warning(source: LogSource, ...args: any[]): void { | 63 public _warning(source: LogSource, ...args: any[]): void { |
44 var output = this.getOutput(source, args); | 64 var output = this.getOutput(source, args); |
45 console.warn(...output); | 65 console.warn(...output); |
86 return timeString; | 106 return timeString; |
87 } | 107 } |
88 } | 108 } |
89 | 109 |
90 export var defaultLogger: StandardConsoleLogger = new TimeConsoleLogger(); | 110 export var defaultLogger: StandardConsoleLogger = new TimeConsoleLogger(); |
111 |