ag-common 0.0.362 → 0.0.363

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.
@@ -1,5 +1,8 @@
1
1
  export type TLogType = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
2
2
  export declare const GetLogLevel: (l: TLogType) => number;
3
+ export type TLogShim = (...args: unknown[]) => void;
4
+ /** if passed in, will use this instead of console.xxx */
5
+ export declare const SetLogShim: (ls: TLogShim) => void;
3
6
  export declare const SetLogLevel: (l: TLogType) => void;
4
7
  export declare const debug: (...args: unknown[]) => void;
5
8
  export declare const info: (...args: unknown[]) => void;
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
2
  /* eslint-disable no-console */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.fatal = exports.error = exports.trace = exports.warn = exports.info = exports.debug = exports.SetLogLevel = exports.GetLogLevel = void 0;
4
+ exports.fatal = exports.error = exports.trace = exports.warn = exports.info = exports.debug = exports.SetLogLevel = exports.SetLogShim = exports.GetLogLevel = void 0;
5
5
  const _1 = require(".");
6
6
  const GetLogLevel = (l) => ['TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].findIndex((s) => s === l);
7
7
  exports.GetLogLevel = GetLogLevel;
8
+ let logShim;
9
+ /** if passed in, will use this instead of console.xxx */
10
+ const SetLogShim = (ls) => {
11
+ logShim = ls;
12
+ };
13
+ exports.SetLogShim = SetLogShim;
8
14
  let userLogLevel = 'WARN';
9
15
  const SetLogLevel = (l) => {
10
16
  const lu = l === null || l === void 0 ? void 0 : l.toUpperCase();
@@ -25,6 +31,10 @@ function logprocess(type, args) {
25
31
  ////////
26
32
  const datetime = new Date().toLocaleTimeString('en-GB');
27
33
  const log = [`[${datetime}]`, type, ...args.filter(_1.notEmpty)];
34
+ if (logShim) {
35
+ logShim(...log);
36
+ return;
37
+ }
28
38
  switch (type) {
29
39
  case 'TRACE': {
30
40
  console.trace(...log);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.362",
3
+ "version": "0.0.363",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",