@sjts/lib-log 31.1.6 → 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 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 static _indent;
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
- static indent(): void;
31
- static outdent(): void;
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 static _openProfiles;
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
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAuB9C,qBAAa,MAAM;IAClB,OAAc,GAAG,SAAM;IACvB,OAAc,KAAK,SAAQ;IAC3B,OAAc,MAAM,SAAS;IAC7B,OAAc,IAAI,SAAO;IACzB,OAAc,OAAO,SAAU;IAC/B,OAAc,IAAI,SAAO;IACzB,OAAc,KAAK,SAAQ;IAC3B,OAAc,KAAK,SAAQ;IAC3B,OAAc,OAAO,SAAU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AC,EAAE,GAAG;IAOvC,MAAM,GAAI,KAAK,MAAM,EAAE,SAAS,MAAM,EAAE,OAAO,GAAG,UAA+B;WAC1E,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAQtD,IAAI,GAAI,SAAS,MAAM,EAAE,OAAO,GAAG,UAA+B;WAC3D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAQvC,KAAK,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
- static _indent = 0;
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
- static indent() {
58
+ indent() {
59
59
  this._indent++;
60
60
  }
61
- static outdent() {
61
+ outdent() {
62
62
  this._indent--;
63
63
  }
64
64
  addDebug() {
@@ -146,41 +146,53 @@ export class Logger {
146
146
  // ------------------------------------------------------------
147
147
  // Performance
148
148
  // ------------------------------------------------------------
149
- static _openProfiles = {};
149
+ _openProfiles = {};
150
+ startProfiling(key) {
151
+ this._openProfiles[key] = { key, start: DateTime.now().toMillis(), initiated: false };
152
+ }
150
153
  static startProfiling(key) {
151
- Logger._openProfiles[key] = { key, start: DateTime.now().toMillis(), initiated: false };
154
+ Logger.instance.startProfiling(key);
152
155
  }
153
- static stopProfiling(key) {
154
- const p = Logger._openProfiles[key];
156
+ stopProfiling(key) {
157
+ const p = this._openProfiles[key];
155
158
  if (!p) {
156
- this.instance.c.warn('Cannot STOP profiling. Key "' + key + '" not found');
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
- Logger.outdent();
164
- delete Logger._openProfiles[key];
166
+ this.outdent();
167
+ delete this._openProfiles[key];
165
168
  if (!initiated)
166
169
  this.initProfiles([key]);
167
- const msg = Logger.indentMessage(`${blue}${italic}${key}${reset} - ${green}${duration}ms${reset}`);
168
- this.instance.c.log(msg);
170
+ const msg = this.indentMessage(`${blue}${italic}${key}${reset} - ${green}${duration}ms${reset}`);
171
+ this.c.log(msg);
169
172
  }
170
- static initProfiles(exclude = []) {
171
- Object.values(Logger._openProfiles)
173
+ static stopProfiling(key) {
174
+ Logger.instance.stopProfiling(key);
175
+ }
176
+ initProfiles(exclude = []) {
177
+ Object.values(this._openProfiles)
172
178
  .filter(profile => !profile.initiated && !exclude.includes(profile.key))
173
179
  .sort((a, b) => a.start - b.start)
174
180
  .forEach(profile => {
175
181
  profile.initiated = true;
176
- const msg = Logger.indentMessage(`${blue}${italic}${profile.key}${reset}`);
177
- this.instance.c.log(msg);
178
- Logger.indent();
182
+ const msg = this.indentMessage(`${blue}${italic}${profile.key}${reset}`);
183
+ this.c.log(msg);
184
+ this.indent();
179
185
  });
180
186
  }
181
- static indentMessage(message) {
182
- return Logger._indent > 0
183
- ? `${dim}${blue}${'| '.repeat(Logger._indent)}${reset}${message}`
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}`
184
193
  : message;
185
194
  }
195
+ static indentMessage(message) {
196
+ return Logger.instance.indentMessage(message);
197
+ }
186
198
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjts/lib-log",
3
3
  "description": "The Steve James Typescript Log package",
4
- "version": "31.1.6",
4
+ "version": "31.1.7",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",