@sjts/lib-log 31.1.5 → 31.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Logger.d.ts +8 -4
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +32 -22
- package/package.json +1 -1
package/dist/Logger.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class Logger {
|
|
|
19
19
|
static underline: string;
|
|
20
20
|
static strikethrough: string;
|
|
21
21
|
static lastLogTimestamp: number;
|
|
22
|
-
private
|
|
22
|
+
private _indent;
|
|
23
23
|
private level;
|
|
24
24
|
private systemTags;
|
|
25
25
|
c: any;
|
|
@@ -27,8 +27,8 @@ export declare class Logger {
|
|
|
27
27
|
static set console(c: any);
|
|
28
28
|
set logLevel(l: LoggerLevel[]);
|
|
29
29
|
static set logLevel(l: LoggerLevel[]);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
indent(): void;
|
|
31
|
+
outdent(): void;
|
|
32
32
|
addDebug(): void;
|
|
33
33
|
static addDebug(): void;
|
|
34
34
|
addSystem(): void;
|
|
@@ -52,10 +52,14 @@ export declare class Logger {
|
|
|
52
52
|
kill: (message: string, data?: any) => void;
|
|
53
53
|
static kill(message: string, data?: any): void;
|
|
54
54
|
static instance: Logger;
|
|
55
|
-
private
|
|
55
|
+
private _openProfiles;
|
|
56
|
+
startProfiling(key: string): void;
|
|
56
57
|
static startProfiling(key: string): void;
|
|
58
|
+
stopProfiling(key: string): void;
|
|
57
59
|
static stopProfiling(key: string): void;
|
|
60
|
+
initProfiles(exclude?: string[]): void;
|
|
58
61
|
static initProfiles(exclude?: string[]): void;
|
|
62
|
+
indentMessage(message: string): string;
|
|
59
63
|
static indentMessage(message: string): string;
|
|
60
64
|
}
|
|
61
65
|
//# sourceMappingURL=Logger.d.ts.map
|
package/dist/Logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":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AK,GAAI,SAAS,MAAM,EAAE,OAAO,GAAG,UAAgC;WAC7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAQxC,KAAK,GAAI,SAAS,MAAM,EAAE,OAAO,GAAG,UAAgC;WAC7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAQxC,IAAI,GAAI,SAAS,MAAM,EAAE,OAAO,GAAG,UAA+B;WAC3D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAW9C,OAAc,QAAQ,EAAE,MAAM,CAAe;IAK7C,OAAO,CAAC,aAAa,CAEf;IACN,cAAc,CAAC,GAAG,EAAE,MAAM;IAG1B,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM;IAGjC,aAAa,CAAC,GAAG,EAAE,MAAM;IAiBzB,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM;IAGhC,YAAY,CAAC,OAAO,GAAE,MAAM,EAAO;IAWnC,MAAM,CAAC,YAAY,CAAC,OAAO,GAAE,MAAM,EAAO;IAG1C,aAAa,CAAC,OAAO,EAAE,MAAM;IAK7B,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;CAGpC"}
|
package/dist/Logger.js
CHANGED
|
@@ -39,7 +39,7 @@ export class Logger {
|
|
|
39
39
|
static underline = underline;
|
|
40
40
|
static strikethrough = strikethrough;
|
|
41
41
|
static lastLogTimestamp = 0;
|
|
42
|
-
|
|
42
|
+
_indent = 0;
|
|
43
43
|
level = [INFO, WARN, ERROR, THROW, KILL];
|
|
44
44
|
systemTags = [];
|
|
45
45
|
c = console;
|
|
@@ -55,10 +55,10 @@ export class Logger {
|
|
|
55
55
|
static set logLevel(l) {
|
|
56
56
|
this.instance.logLevel = l;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
indent() {
|
|
59
59
|
this._indent++;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
outdent() {
|
|
62
62
|
this._indent--;
|
|
63
63
|
}
|
|
64
64
|
addDebug() {
|
|
@@ -146,43 +146,53 @@ export class Logger {
|
|
|
146
146
|
// ------------------------------------------------------------
|
|
147
147
|
// Performance
|
|
148
148
|
// ------------------------------------------------------------
|
|
149
|
-
|
|
149
|
+
_openProfiles = {};
|
|
150
|
+
startProfiling(key) {
|
|
151
|
+
this._openProfiles[key] = { key, start: DateTime.now().toMillis(), initiated: false };
|
|
152
|
+
}
|
|
150
153
|
static startProfiling(key) {
|
|
151
|
-
Logger.
|
|
154
|
+
Logger.instance.startProfiling(key);
|
|
152
155
|
}
|
|
153
|
-
|
|
154
|
-
const p =
|
|
156
|
+
stopProfiling(key) {
|
|
157
|
+
const p = this._openProfiles[key];
|
|
155
158
|
if (!p) {
|
|
156
|
-
this.
|
|
159
|
+
this.c.warn('Cannot STOP profiling. Key "' + key + '" not found');
|
|
157
160
|
return;
|
|
158
161
|
}
|
|
159
162
|
const endTime = DateTime.now().toMillis();
|
|
160
163
|
const duration = endTime - p.start;
|
|
161
164
|
const initiated = p.initiated;
|
|
162
165
|
if (initiated)
|
|
163
|
-
|
|
164
|
-
delete
|
|
166
|
+
this.outdent();
|
|
167
|
+
delete this._openProfiles[key];
|
|
165
168
|
if (!initiated)
|
|
166
169
|
this.initProfiles([key]);
|
|
167
|
-
const msg =
|
|
168
|
-
|
|
169
|
-
: Logger.indentMessage(`${blue}${italic}${key}${reset} - ${green}${duration}ms${reset}`);
|
|
170
|
-
this.instance.c.log(msg);
|
|
170
|
+
const msg = this.indentMessage(`${blue}${italic}${key}${reset} - ${green}${duration}ms${reset}`);
|
|
171
|
+
this.c.log(msg);
|
|
171
172
|
}
|
|
172
|
-
static
|
|
173
|
-
|
|
173
|
+
static stopProfiling(key) {
|
|
174
|
+
Logger.instance.stopProfiling(key);
|
|
175
|
+
}
|
|
176
|
+
initProfiles(exclude = []) {
|
|
177
|
+
Object.values(this._openProfiles)
|
|
174
178
|
.filter(profile => !profile.initiated && !exclude.includes(profile.key))
|
|
175
179
|
.sort((a, b) => a.start - b.start)
|
|
176
180
|
.forEach(profile => {
|
|
177
181
|
profile.initiated = true;
|
|
178
|
-
const msg =
|
|
179
|
-
this.
|
|
180
|
-
|
|
182
|
+
const msg = this.indentMessage(`${blue}${italic}${profile.key}${reset}`);
|
|
183
|
+
this.c.log(msg);
|
|
184
|
+
this.indent();
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
|
-
static
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
static initProfiles(exclude = []) {
|
|
188
|
+
Logger.instance.initProfiles(exclude);
|
|
189
|
+
}
|
|
190
|
+
indentMessage(message) {
|
|
191
|
+
return this._indent > 0
|
|
192
|
+
? `${dim}${blue}${'| '.repeat(this._indent)}${reset}${message}`
|
|
186
193
|
: message;
|
|
187
194
|
}
|
|
195
|
+
static indentMessage(message) {
|
|
196
|
+
return Logger.instance.indentMessage(message);
|
|
197
|
+
}
|
|
188
198
|
}
|