@contember/logger 2.1.0-alpha.3 → 2.1.0-alpha.35
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/package.json +9 -4
- package/src/handlers/FingerCrossedLoggerHandler.ts +0 -4
- package/src/handlers/JsonStreamLoggerHandler.ts +2 -1
- package/src/handlers/PrettyPrintLoggerHandler.ts +3 -2
- package/src/handlers/TestLoggerHandler.ts +0 -2
- package/src/impl.ts +11 -10
- package/src/proxy.ts +1 -1
- package/src/types.ts +1 -1
- package/dist/development/index.cjs +0 -23
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -23
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/formatting.cjs +0 -65
- package/dist/development/src/formatting.cjs.map +0 -1
- package/dist/development/src/formatting.js +0 -65
- package/dist/development/src/formatting.js.map +0 -1
- package/dist/development/src/handlers/FingerCrossedLoggerHandler.cjs +0 -68
- package/dist/development/src/handlers/FingerCrossedLoggerHandler.cjs.map +0 -1
- package/dist/development/src/handlers/FingerCrossedLoggerHandler.js +0 -68
- package/dist/development/src/handlers/FingerCrossedLoggerHandler.js.map +0 -1
- package/dist/development/src/handlers/JsonStreamLoggerHandler.cjs +0 -32
- package/dist/development/src/handlers/JsonStreamLoggerHandler.cjs.map +0 -1
- package/dist/development/src/handlers/JsonStreamLoggerHandler.js +0 -32
- package/dist/development/src/handlers/JsonStreamLoggerHandler.js.map +0 -1
- package/dist/development/src/handlers/LoggerHandlerList.cjs +0 -25
- package/dist/development/src/handlers/LoggerHandlerList.cjs.map +0 -1
- package/dist/development/src/handlers/LoggerHandlerList.js +0 -25
- package/dist/development/src/handlers/LoggerHandlerList.js.map +0 -1
- package/dist/development/src/handlers/NullLoggerHandler.cjs +0 -13
- package/dist/development/src/handlers/NullLoggerHandler.cjs.map +0 -1
- package/dist/development/src/handlers/NullLoggerHandler.js +0 -13
- package/dist/development/src/handlers/NullLoggerHandler.js.map +0 -1
- package/dist/development/src/handlers/PrettyPrintLoggerHandler.cjs +0 -79
- package/dist/development/src/handlers/PrettyPrintLoggerHandler.cjs.map +0 -1
- package/dist/development/src/handlers/PrettyPrintLoggerHandler.js +0 -79
- package/dist/development/src/handlers/PrettyPrintLoggerHandler.js.map +0 -1
- package/dist/development/src/handlers/TestLoggerHandler.cjs +0 -24
- package/dist/development/src/handlers/TestLoggerHandler.cjs.map +0 -1
- package/dist/development/src/handlers/TestLoggerHandler.js +0 -24
- package/dist/development/src/handlers/TestLoggerHandler.js.map +0 -1
- package/dist/development/src/impl.cjs +0 -109
- package/dist/development/src/impl.cjs.map +0 -1
- package/dist/development/src/impl.js +0 -109
- package/dist/development/src/impl.js.map +0 -1
- package/dist/development/src/levels.cjs +0 -11
- package/dist/development/src/levels.cjs.map +0 -1
- package/dist/development/src/levels.js +0 -11
- package/dist/development/src/levels.js.map +0 -1
- package/dist/development/src/proxy.cjs +0 -54
- package/dist/development/src/proxy.cjs.map +0 -1
- package/dist/development/src/proxy.js +0 -54
- package/dist/development/src/proxy.js.map +0 -1
- package/dist/production/index.cjs +0 -23
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -23
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/formatting.cjs +0 -65
- package/dist/production/src/formatting.cjs.map +0 -1
- package/dist/production/src/formatting.js +0 -65
- package/dist/production/src/formatting.js.map +0 -1
- package/dist/production/src/handlers/FingerCrossedLoggerHandler.cjs +0 -68
- package/dist/production/src/handlers/FingerCrossedLoggerHandler.cjs.map +0 -1
- package/dist/production/src/handlers/FingerCrossedLoggerHandler.js +0 -68
- package/dist/production/src/handlers/FingerCrossedLoggerHandler.js.map +0 -1
- package/dist/production/src/handlers/JsonStreamLoggerHandler.cjs +0 -32
- package/dist/production/src/handlers/JsonStreamLoggerHandler.cjs.map +0 -1
- package/dist/production/src/handlers/JsonStreamLoggerHandler.js +0 -32
- package/dist/production/src/handlers/JsonStreamLoggerHandler.js.map +0 -1
- package/dist/production/src/handlers/LoggerHandlerList.cjs +0 -25
- package/dist/production/src/handlers/LoggerHandlerList.cjs.map +0 -1
- package/dist/production/src/handlers/LoggerHandlerList.js +0 -25
- package/dist/production/src/handlers/LoggerHandlerList.js.map +0 -1
- package/dist/production/src/handlers/NullLoggerHandler.cjs +0 -13
- package/dist/production/src/handlers/NullLoggerHandler.cjs.map +0 -1
- package/dist/production/src/handlers/NullLoggerHandler.js +0 -13
- package/dist/production/src/handlers/NullLoggerHandler.js.map +0 -1
- package/dist/production/src/handlers/PrettyPrintLoggerHandler.cjs +0 -79
- package/dist/production/src/handlers/PrettyPrintLoggerHandler.cjs.map +0 -1
- package/dist/production/src/handlers/PrettyPrintLoggerHandler.js +0 -79
- package/dist/production/src/handlers/PrettyPrintLoggerHandler.js.map +0 -1
- package/dist/production/src/handlers/TestLoggerHandler.cjs +0 -24
- package/dist/production/src/handlers/TestLoggerHandler.cjs.map +0 -1
- package/dist/production/src/handlers/TestLoggerHandler.js +0 -24
- package/dist/production/src/handlers/TestLoggerHandler.js.map +0 -1
- package/dist/production/src/impl.cjs +0 -109
- package/dist/production/src/impl.cjs.map +0 -1
- package/dist/production/src/impl.js +0 -109
- package/dist/production/src/impl.js.map +0 -1
- package/dist/production/src/levels.cjs +0 -11
- package/dist/production/src/levels.cjs.map +0 -1
- package/dist/production/src/levels.js +0 -11
- package/dist/production/src/levels.js.map +0 -1
- package/dist/production/src/proxy.cjs +0 -54
- package/dist/production/src/proxy.cjs.map +0 -1
- package/dist/production/src/proxy.js +0 -54
- package/dist/production/src/proxy.js.map +0 -1
- package/dist/types/formatting.d.ts +0 -9
- package/dist/types/formatting.d.ts.map +0 -1
- package/dist/types/handlers/FingerCrossedLoggerHandler.d.ts +0 -20
- package/dist/types/handlers/FingerCrossedLoggerHandler.d.ts.map +0 -1
- package/dist/types/handlers/JsonStreamLoggerHandler.d.ts +0 -13
- package/dist/types/handlers/JsonStreamLoggerHandler.d.ts.map +0 -1
- package/dist/types/handlers/LoggerHandlerList.d.ts +0 -10
- package/dist/types/handlers/LoggerHandlerList.d.ts.map +0 -1
- package/dist/types/handlers/NullLoggerHandler.d.ts +0 -7
- package/dist/types/handlers/NullLoggerHandler.d.ts.map +0 -1
- package/dist/types/handlers/PrettyPrintLoggerHandler.d.ts +0 -27
- package/dist/types/handlers/PrettyPrintLoggerHandler.d.ts.map +0 -1
- package/dist/types/handlers/TestLoggerHandler.d.ts +0 -10
- package/dist/types/handlers/TestLoggerHandler.d.ts.map +0 -1
- package/dist/types/impl.d.ts +0 -28
- package/dist/types/impl.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/levels.d.ts +0 -8
- package/dist/types/levels.d.ts.map +0 -1
- package/dist/types/proxy.d.ts +0 -5
- package/dist/types/proxy.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/types.d.ts +0 -55
- package/dist/types/types.d.ts.map +0 -1
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const node_async_hooks = require("node:async_hooks");
|
|
4
|
-
const loggerStore = new node_async_hooks.AsyncLocalStorage();
|
|
5
|
-
class CurrentLoggerProxy {
|
|
6
|
-
crit(a, b, c) {
|
|
7
|
-
getLogger().crit(a, b);
|
|
8
|
-
}
|
|
9
|
-
error(a, b, c) {
|
|
10
|
-
getLogger().error(a, b);
|
|
11
|
-
}
|
|
12
|
-
warn(a, b, c) {
|
|
13
|
-
getLogger().warn(a, b);
|
|
14
|
-
}
|
|
15
|
-
info(a, b, c) {
|
|
16
|
-
getLogger().info(a, b);
|
|
17
|
-
}
|
|
18
|
-
debug(a, b, c) {
|
|
19
|
-
getLogger().debug(a, b);
|
|
20
|
-
}
|
|
21
|
-
log(level, a, b, c) {
|
|
22
|
-
getLogger().log(level, a, b);
|
|
23
|
-
}
|
|
24
|
-
child(attributes, options) {
|
|
25
|
-
return getLogger().child(attributes, options);
|
|
26
|
-
}
|
|
27
|
-
get attributes() {
|
|
28
|
-
return getLogger().attributes;
|
|
29
|
-
}
|
|
30
|
-
close() {
|
|
31
|
-
getLogger().close();
|
|
32
|
-
}
|
|
33
|
-
scope(cb, attributes, options) {
|
|
34
|
-
return getLogger().scope(cb, attributes, options);
|
|
35
|
-
}
|
|
36
|
-
addHandler(handler) {
|
|
37
|
-
getLogger().addHandler(handler);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const logger = new CurrentLoggerProxy();
|
|
41
|
-
const withLogger = (logger2, callback) => {
|
|
42
|
-
return loggerStore.run(logger2, callback);
|
|
43
|
-
};
|
|
44
|
-
const getLogger = () => {
|
|
45
|
-
const logger2 = loggerStore.getStore();
|
|
46
|
-
if (!logger2) {
|
|
47
|
-
throw new Error("Logger was not set");
|
|
48
|
-
}
|
|
49
|
-
return logger2;
|
|
50
|
-
};
|
|
51
|
-
exports.getLogger = getLogger;
|
|
52
|
-
exports.logger = logger;
|
|
53
|
-
exports.withLogger = withLogger;
|
|
54
|
-
//# sourceMappingURL=proxy.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.cjs","sources":["../../../../packages/logger/src/proxy.ts"],"sourcesContent":["import { Logger, LoggerAttributes, LoggerHandler, LoggerOptions } from './types'\nimport { AsyncLocalStorage } from 'node:async_hooks'\n\nconst loggerStore = new AsyncLocalStorage<Logger>()\n\nclass CurrentLoggerProxy implements Logger {\n\tcrit(a: any, b?: any, c?: any) {\n\t\tgetLogger().crit(a, b)\n\t}\n\n\terror(a: any, b?: any, c?: any) {\n\t\tgetLogger().error(a, b)\n\t}\n\n\twarn(a: any, b?: any, c?: any) {\n\t\tgetLogger().warn(a, b)\n\t}\n\n\tinfo(a: any, b?: any, c?: any) {\n\t\tgetLogger().info(a, b)\n\t}\n\n\tdebug(a: any, b?: any, c?: any) {\n\t\tgetLogger().debug(a, b)\n\t}\n\n\tlog(level: any, a: any, b?: any, c?: any) {\n\t\tgetLogger().log(level, a, b)\n\t}\n\n\tchild(attributes?: LoggerAttributes, options?: Partial<LoggerOptions>): Logger {\n\t\treturn getLogger().child(attributes, options)\n\t}\n\n\tget attributes() {\n\t\treturn getLogger().attributes\n\t}\n\n\tclose(): void {\n\t\tgetLogger().close()\n\t}\n\n\tscope<T>(cb: (logger: Logger) => (Promise<T> | T), attributes?: LoggerAttributes, options?: Partial<LoggerOptions>): Promise<T> {\n\t\treturn getLogger().scope(cb, attributes, options)\n\t}\n\n\taddHandler(handler: LoggerHandler): void {\n\t\tgetLogger().addHandler(handler)\n\t}\n}\n\nexport const logger: Logger = new CurrentLoggerProxy()\n\nexport const withLogger = <R>(logger: Logger, callback: () => R): R => {\n\treturn loggerStore.run(logger, callback)\n}\n\nexport const getLogger = (): Logger => {\n\tconst logger = loggerStore.getStore()\n\tif (!logger) {\n\t\tthrow new Error('Logger was not set')\n\t}\n\treturn logger\n}\n"],"names":["AsyncLocalStorage","logger"],"mappings":";;;AAGA,MAAM,cAAc,IAAIA,iBAAAA,kBAA0B;AAElD,MAAM,mBAAqC;AAAA,EAC1C,KAAK,GAAQ,GAAS,GAAS;AACpB,gBAAE,KAAK,GAAG,CAAC;AAAA,EAAA;AAAA,EAGtB,MAAM,GAAQ,GAAS,GAAS;AACrB,gBAAE,MAAM,GAAG,CAAC;AAAA,EAAA;AAAA,EAGvB,KAAK,GAAQ,GAAS,GAAS;AACpB,gBAAE,KAAK,GAAG,CAAC;AAAA,EAAA;AAAA,EAGtB,KAAK,GAAQ,GAAS,GAAS;AACpB,gBAAE,KAAK,GAAG,CAAC;AAAA,EAAA;AAAA,EAGtB,MAAM,GAAQ,GAAS,GAAS;AACrB,gBAAE,MAAM,GAAG,CAAC;AAAA,EAAA;AAAA,EAGvB,IAAI,OAAY,GAAQ,GAAS,GAAS;AACzC,cAAY,EAAA,IAAI,OAAO,GAAG,CAAC;AAAA,EAAA;AAAA,EAG5B,MAAM,YAA+B,SAA0C;AAC9E,WAAO,UAAU,EAAE,MAAM,YAAY,OAAO;AAAA,EAAA;AAAA,EAG7C,IAAI,aAAa;AAChB,WAAO,UAAY,EAAA;AAAA,EAAA;AAAA,EAGpB,QAAc;AACb,cAAA,EAAY,MAAM;AAAA,EAAA;AAAA,EAGnB,MAAS,IAA0C,YAA+B,SAA8C;AAC/H,WAAO,UAAU,EAAE,MAAM,IAAI,YAAY,OAAO;AAAA,EAAA;AAAA,EAGjD,WAAW,SAA8B;AAC9B,cAAA,EAAE,WAAW,OAAO;AAAA,EAAA;AAEhC;AAEa,MAAA,SAAiB,IAAI,mBAAmB;AAExC,MAAA,aAAa,CAAIC,SAAgB,aAAyB;AAC/D,SAAA,YAAY,IAAIA,SAAQ,QAAQ;AACxC;AAEO,MAAM,YAAY,MAAc;AAChCA,QAAAA,UAAS,YAAY,SAAS;AACpC,MAAI,CAACA,SAAQ;AACN,UAAA,IAAI,MAAM,oBAAoB;AAAA,EAAA;AAE9BA,SAAAA;AACR;;;;"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
const loggerStore = new AsyncLocalStorage();
|
|
3
|
-
class CurrentLoggerProxy {
|
|
4
|
-
crit(a, b, c) {
|
|
5
|
-
getLogger().crit(a, b);
|
|
6
|
-
}
|
|
7
|
-
error(a, b, c) {
|
|
8
|
-
getLogger().error(a, b);
|
|
9
|
-
}
|
|
10
|
-
warn(a, b, c) {
|
|
11
|
-
getLogger().warn(a, b);
|
|
12
|
-
}
|
|
13
|
-
info(a, b, c) {
|
|
14
|
-
getLogger().info(a, b);
|
|
15
|
-
}
|
|
16
|
-
debug(a, b, c) {
|
|
17
|
-
getLogger().debug(a, b);
|
|
18
|
-
}
|
|
19
|
-
log(level, a, b, c) {
|
|
20
|
-
getLogger().log(level, a, b);
|
|
21
|
-
}
|
|
22
|
-
child(attributes, options) {
|
|
23
|
-
return getLogger().child(attributes, options);
|
|
24
|
-
}
|
|
25
|
-
get attributes() {
|
|
26
|
-
return getLogger().attributes;
|
|
27
|
-
}
|
|
28
|
-
close() {
|
|
29
|
-
getLogger().close();
|
|
30
|
-
}
|
|
31
|
-
scope(cb, attributes, options) {
|
|
32
|
-
return getLogger().scope(cb, attributes, options);
|
|
33
|
-
}
|
|
34
|
-
addHandler(handler) {
|
|
35
|
-
getLogger().addHandler(handler);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const logger = new CurrentLoggerProxy();
|
|
39
|
-
const withLogger = (logger2, callback) => {
|
|
40
|
-
return loggerStore.run(logger2, callback);
|
|
41
|
-
};
|
|
42
|
-
const getLogger = () => {
|
|
43
|
-
const logger2 = loggerStore.getStore();
|
|
44
|
-
if (!logger2) {
|
|
45
|
-
throw new Error("Logger was not set");
|
|
46
|
-
}
|
|
47
|
-
return logger2;
|
|
48
|
-
};
|
|
49
|
-
export {
|
|
50
|
-
getLogger,
|
|
51
|
-
logger,
|
|
52
|
-
withLogger
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=proxy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sources":["../../../../packages/logger/src/proxy.ts"],"sourcesContent":["import { Logger, LoggerAttributes, LoggerHandler, LoggerOptions } from './types'\nimport { AsyncLocalStorage } from 'node:async_hooks'\n\nconst loggerStore = new AsyncLocalStorage<Logger>()\n\nclass CurrentLoggerProxy implements Logger {\n\tcrit(a: any, b?: any, c?: any) {\n\t\tgetLogger().crit(a, b)\n\t}\n\n\terror(a: any, b?: any, c?: any) {\n\t\tgetLogger().error(a, b)\n\t}\n\n\twarn(a: any, b?: any, c?: any) {\n\t\tgetLogger().warn(a, b)\n\t}\n\n\tinfo(a: any, b?: any, c?: any) {\n\t\tgetLogger().info(a, b)\n\t}\n\n\tdebug(a: any, b?: any, c?: any) {\n\t\tgetLogger().debug(a, b)\n\t}\n\n\tlog(level: any, a: any, b?: any, c?: any) {\n\t\tgetLogger().log(level, a, b)\n\t}\n\n\tchild(attributes?: LoggerAttributes, options?: Partial<LoggerOptions>): Logger {\n\t\treturn getLogger().child(attributes, options)\n\t}\n\n\tget attributes() {\n\t\treturn getLogger().attributes\n\t}\n\n\tclose(): void {\n\t\tgetLogger().close()\n\t}\n\n\tscope<T>(cb: (logger: Logger) => (Promise<T> | T), attributes?: LoggerAttributes, options?: Partial<LoggerOptions>): Promise<T> {\n\t\treturn getLogger().scope(cb, attributes, options)\n\t}\n\n\taddHandler(handler: LoggerHandler): void {\n\t\tgetLogger().addHandler(handler)\n\t}\n}\n\nexport const logger: Logger = new CurrentLoggerProxy()\n\nexport const withLogger = <R>(logger: Logger, callback: () => R): R => {\n\treturn loggerStore.run(logger, callback)\n}\n\nexport const getLogger = (): Logger => {\n\tconst logger = loggerStore.getStore()\n\tif (!logger) {\n\t\tthrow new Error('Logger was not set')\n\t}\n\treturn logger\n}\n"],"names":["logger"],"mappings":";AAGA,MAAM,cAAc,IAAI,kBAA0B;AAElD,MAAM,mBAAqC;AAAA,EAC1C,KAAK,GAAQ,GAAS,GAAS;AACpB,gBAAE,KAAK,GAAG,CAAC;AAAA,EAAA;AAAA,EAGtB,MAAM,GAAQ,GAAS,GAAS;AACrB,gBAAE,MAAM,GAAG,CAAC;AAAA,EAAA;AAAA,EAGvB,KAAK,GAAQ,GAAS,GAAS;AACpB,gBAAE,KAAK,GAAG,CAAC;AAAA,EAAA;AAAA,EAGtB,KAAK,GAAQ,GAAS,GAAS;AACpB,gBAAE,KAAK,GAAG,CAAC;AAAA,EAAA;AAAA,EAGtB,MAAM,GAAQ,GAAS,GAAS;AACrB,gBAAE,MAAM,GAAG,CAAC;AAAA,EAAA;AAAA,EAGvB,IAAI,OAAY,GAAQ,GAAS,GAAS;AACzC,cAAY,EAAA,IAAI,OAAO,GAAG,CAAC;AAAA,EAAA;AAAA,EAG5B,MAAM,YAA+B,SAA0C;AAC9E,WAAO,UAAU,EAAE,MAAM,YAAY,OAAO;AAAA,EAAA;AAAA,EAG7C,IAAI,aAAa;AAChB,WAAO,UAAY,EAAA;AAAA,EAAA;AAAA,EAGpB,QAAc;AACb,cAAA,EAAY,MAAM;AAAA,EAAA;AAAA,EAGnB,MAAS,IAA0C,YAA+B,SAA8C;AAC/H,WAAO,UAAU,EAAE,MAAM,IAAI,YAAY,OAAO;AAAA,EAAA;AAAA,EAGjD,WAAW,SAA8B;AAC9B,cAAA,EAAE,WAAW,OAAO;AAAA,EAAA;AAEhC;AAEa,MAAA,SAAiB,IAAI,mBAAmB;AAExC,MAAA,aAAa,CAAIA,SAAgB,aAAyB;AAC/D,SAAA,YAAY,IAAIA,SAAQ,QAAQ;AACxC;AAEO,MAAM,YAAY,MAAc;AAChCA,QAAAA,UAAS,YAAY,SAAS;AACpC,MAAI,CAACA,SAAQ;AACN,UAAA,IAAI,MAAM,oBAAoB;AAAA,EAAA;AAE9BA,SAAAA;AACR;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const impl = require("./src/impl.cjs");
|
|
4
|
-
const levels = require("./src/levels.cjs");
|
|
5
|
-
const proxy = require("./src/proxy.cjs");
|
|
6
|
-
const FingerCrossedLoggerHandler = require("./src/handlers/FingerCrossedLoggerHandler.cjs");
|
|
7
|
-
const JsonStreamLoggerHandler = require("./src/handlers/JsonStreamLoggerHandler.cjs");
|
|
8
|
-
const PrettyPrintLoggerHandler = require("./src/handlers/PrettyPrintLoggerHandler.cjs");
|
|
9
|
-
const LoggerHandlerList = require("./src/handlers/LoggerHandlerList.cjs");
|
|
10
|
-
const NullLoggerHandler = require("./src/handlers/NullLoggerHandler.cjs");
|
|
11
|
-
const TestLoggerHandler = require("./src/handlers/TestLoggerHandler.cjs");
|
|
12
|
-
exports.createLogger = impl.createLogger;
|
|
13
|
-
exports.LogLevels = levels.LogLevels;
|
|
14
|
-
exports.getLogger = proxy.getLogger;
|
|
15
|
-
exports.logger = proxy.logger;
|
|
16
|
-
exports.withLogger = proxy.withLogger;
|
|
17
|
-
exports.FingerCrossedLoggerHandler = FingerCrossedLoggerHandler.FingerCrossedLoggerHandler;
|
|
18
|
-
exports.JsonStreamLoggerHandler = JsonStreamLoggerHandler.JsonStreamLoggerHandler;
|
|
19
|
-
exports.PrettyPrintLoggerHandler = PrettyPrintLoggerHandler.PrettyPrintLoggerHandler;
|
|
20
|
-
exports.LoggerHandlerList = LoggerHandlerList.LoggerHandlerList;
|
|
21
|
-
exports.NullLoggerHandler = NullLoggerHandler.NullLoggerHandler;
|
|
22
|
-
exports.TestLoggerHandler = TestLoggerHandler.TestLoggerHandler;
|
|
23
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/production/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "./src/impl.js";
|
|
2
|
-
import { LogLevels } from "./src/levels.js";
|
|
3
|
-
import { getLogger, logger, withLogger } from "./src/proxy.js";
|
|
4
|
-
import { FingerCrossedLoggerHandler } from "./src/handlers/FingerCrossedLoggerHandler.js";
|
|
5
|
-
import { JsonStreamLoggerHandler } from "./src/handlers/JsonStreamLoggerHandler.js";
|
|
6
|
-
import { PrettyPrintLoggerHandler } from "./src/handlers/PrettyPrintLoggerHandler.js";
|
|
7
|
-
import { LoggerHandlerList } from "./src/handlers/LoggerHandlerList.js";
|
|
8
|
-
import { NullLoggerHandler } from "./src/handlers/NullLoggerHandler.js";
|
|
9
|
-
import { TestLoggerHandler } from "./src/handlers/TestLoggerHandler.js";
|
|
10
|
-
export {
|
|
11
|
-
FingerCrossedLoggerHandler,
|
|
12
|
-
JsonStreamLoggerHandler,
|
|
13
|
-
LogLevels,
|
|
14
|
-
LoggerHandlerList,
|
|
15
|
-
NullLoggerHandler,
|
|
16
|
-
PrettyPrintLoggerHandler,
|
|
17
|
-
TestLoggerHandler,
|
|
18
|
-
createLogger,
|
|
19
|
-
getLogger,
|
|
20
|
-
logger,
|
|
21
|
-
withLogger
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const node_util = require("node:util");
|
|
4
|
-
const formatLoggerAttributes = (parentAttributes, ownAttributes) => {
|
|
5
|
-
const formattedAttributes = {};
|
|
6
|
-
let formattedLine = "";
|
|
7
|
-
for (const key in ownAttributes) {
|
|
8
|
-
const value = ownAttributes[key];
|
|
9
|
-
if (value === void 0) {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const formattedKey = stringify(key);
|
|
13
|
-
const formattedValue = stringify(value);
|
|
14
|
-
formattedAttributes[formattedKey] = formattedValue;
|
|
15
|
-
formattedLine += `, ${formattedKey}: ${formattedValue}`;
|
|
16
|
-
}
|
|
17
|
-
const parentFormattedAttributes = parentAttributes?.formattedAttributes;
|
|
18
|
-
for (const key in parentFormattedAttributes) {
|
|
19
|
-
if (!(key in formattedAttributes)) {
|
|
20
|
-
const formattedValue = parentFormattedAttributes[key];
|
|
21
|
-
formattedAttributes[key] = formattedValue;
|
|
22
|
-
formattedLine += `, ${key}: ${formattedValue}`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return { formattedAttributes, formattedLine };
|
|
26
|
-
};
|
|
27
|
-
const formatLogEntryAttributes = (attributes, entry) => {
|
|
28
|
-
let entryAttributes = "";
|
|
29
|
-
let reformatRest = false;
|
|
30
|
-
const omitInRest = {};
|
|
31
|
-
for (const key in entry.ownAttributes) {
|
|
32
|
-
const value = entry.ownAttributes[key];
|
|
33
|
-
if (value === void 0) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const formattedKey = stringify(key);
|
|
37
|
-
const formattedValue = stringify(value);
|
|
38
|
-
entryAttributes += `, ${formattedKey}: ${formattedValue}`;
|
|
39
|
-
if (key in attributes.formattedAttributes) {
|
|
40
|
-
reformatRest = true;
|
|
41
|
-
omitInRest[formattedKey] = true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (reformatRest) {
|
|
45
|
-
for (const key in attributes.formattedAttributes) {
|
|
46
|
-
if (!(key in omitInRest)) {
|
|
47
|
-
entryAttributes += `, ${key}: ${attributes.formattedAttributes[key]}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
entryAttributes += attributes.formattedLine;
|
|
52
|
-
}
|
|
53
|
-
return entryAttributes;
|
|
54
|
-
};
|
|
55
|
-
const stringify = (value) => {
|
|
56
|
-
try {
|
|
57
|
-
return JSON.stringify(value);
|
|
58
|
-
} catch {
|
|
59
|
-
return JSON.stringify(node_util.inspect(value));
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
exports.formatLogEntryAttributes = formatLogEntryAttributes;
|
|
63
|
-
exports.formatLoggerAttributes = formatLoggerAttributes;
|
|
64
|
-
exports.stringify = stringify;
|
|
65
|
-
//# sourceMappingURL=formatting.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.cjs","sources":["../../../../packages/logger/src/formatting.ts"],"sourcesContent":["import { LogEntry, LoggerAttributes } from './types'\nimport { inspect } from 'node:util'\n\nexport type FormattedAttributes = {\n\tformattedAttributes: Record<string, string>\n\tformattedLine: string\n}\n\nexport const formatLoggerAttributes = (parentAttributes: FormattedAttributes | undefined, ownAttributes: LoggerAttributes): FormattedAttributes => {\n\tconst formattedAttributes: Record<string, string> = {}\n\tlet formattedLine = ''\n\tfor (const key in ownAttributes) {\n\t\tconst value = ownAttributes[key]\n\t\tif (value === undefined) {\n\t\t\tcontinue\n\t\t}\n\t\tconst formattedKey = stringify(key)\n\t\tconst formattedValue = stringify(value)\n\t\tformattedAttributes[formattedKey] = formattedValue\n\t\tformattedLine += `, ${formattedKey}: ${formattedValue}`\n\t}\n\tconst parentFormattedAttributes = parentAttributes?.formattedAttributes\n\tfor (const key in parentFormattedAttributes) {\n\t\tif (!(key in formattedAttributes)) {\n\t\t\tconst formattedValue = parentFormattedAttributes[key]\n\t\t\tformattedAttributes[key] = formattedValue\n\t\t\tformattedLine += `, ${key}: ${formattedValue}`\n\t\t}\n\t}\n\treturn { formattedAttributes, formattedLine }\n}\n\nexport const formatLogEntryAttributes = (attributes: FormattedAttributes, entry: LogEntry): string => {\n\tlet entryAttributes = ''\n\tlet reformatRest = false\n\tconst omitInRest: Record<string, boolean> = {}\n\n\tfor (const key in entry.ownAttributes) {\n\t\tconst value = entry.ownAttributes[key]\n\t\tif (value === undefined) {\n\t\t\tcontinue\n\t\t}\n\t\tconst formattedKey = stringify(key)\n\t\tconst formattedValue = stringify(value)\n\t\tentryAttributes += `, ${formattedKey}: ${formattedValue}`\n\t\tif (key in attributes.formattedAttributes) {\n\t\t\treformatRest = true\n\t\t\tomitInRest[formattedKey] = true\n\t\t}\n\t}\n\tif (reformatRest) {\n\t\tfor (const key in attributes.formattedAttributes) {\n\t\t\tif (!(key in omitInRest)) {\n\t\t\t\tentryAttributes += `, ${key}: ${attributes.formattedAttributes[key]}`\n\t\t\t}\n\t\t}\n\t} else {\n\t\tentryAttributes += attributes.formattedLine\n\t}\n\n\treturn entryAttributes\n}\n\nexport const stringify = (value: unknown) => {\n\ttry {\n\t\treturn JSON.stringify(value)\n\t} catch {\n\t\treturn JSON.stringify(inspect(value))\n\t}\n}\n"],"names":["inspect"],"mappings":";;;AAQa,MAAA,yBAAyB,CAAC,kBAAmD,kBAAyD;AAClJ,QAAM,sBAA8C,CAAC;AACrD,MAAI,gBAAgB;AACpB,aAAW,OAAO,eAAe;AAC1B,UAAA,QAAQ,cAAc,GAAG;AAC/B,QAAI,UAAU,QAAW;AACxB;AAAA,IAAA;AAEK,UAAA,eAAe,UAAU,GAAG;AAC5B,UAAA,iBAAiB,UAAU,KAAK;AACtC,wBAAoB,YAAY,IAAI;AACnB,qBAAA,KAAK,YAAY,KAAK,cAAc;AAAA,EAAA;AAEtD,QAAM,4BAA4B,kBAAkB;AACpD,aAAW,OAAO,2BAA2B;AACxC,QAAA,EAAE,OAAO,sBAAsB;AAC5B,YAAA,iBAAiB,0BAA0B,GAAG;AACpD,0BAAoB,GAAG,IAAI;AACV,uBAAA,KAAK,GAAG,KAAK,cAAc;AAAA,IAAA;AAAA,EAC7C;AAEM,SAAA,EAAE,qBAAqB,cAAc;AAC7C;AAEa,MAAA,2BAA2B,CAAC,YAAiC,UAA4B;AACrG,MAAI,kBAAkB;AACtB,MAAI,eAAe;AACnB,QAAM,aAAsC,CAAC;AAElC,aAAA,OAAO,MAAM,eAAe;AAChC,UAAA,QAAQ,MAAM,cAAc,GAAG;AACrC,QAAI,UAAU,QAAW;AACxB;AAAA,IAAA;AAEK,UAAA,eAAe,UAAU,GAAG;AAC5B,UAAA,iBAAiB,UAAU,KAAK;AACnB,uBAAA,KAAK,YAAY,KAAK,cAAc;AACnD,QAAA,OAAO,WAAW,qBAAqB;AAC3B,qBAAA;AACf,iBAAW,YAAY,IAAI;AAAA,IAAA;AAAA,EAC5B;AAED,MAAI,cAAc;AACN,eAAA,OAAO,WAAW,qBAAqB;AAC7C,UAAA,EAAE,OAAO,aAAa;AACzB,2BAAmB,KAAK,GAAG,KAAK,WAAW,oBAAoB,GAAG,CAAC;AAAA,MAAA;AAAA,IACpE;AAAA,EACD,OACM;AACN,uBAAmB,WAAW;AAAA,EAAA;AAGxB,SAAA;AACR;AAEa,MAAA,YAAY,CAAC,UAAmB;AACxC,MAAA;AACI,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA,QACpB;AACP,WAAO,KAAK,UAAUA,UAAQ,QAAA,KAAK,CAAC;AAAA,EAAA;AAEtC;;;;"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { inspect } from "node:util";
|
|
2
|
-
const formatLoggerAttributes = (parentAttributes, ownAttributes) => {
|
|
3
|
-
const formattedAttributes = {};
|
|
4
|
-
let formattedLine = "";
|
|
5
|
-
for (const key in ownAttributes) {
|
|
6
|
-
const value = ownAttributes[key];
|
|
7
|
-
if (value === void 0) {
|
|
8
|
-
continue;
|
|
9
|
-
}
|
|
10
|
-
const formattedKey = stringify(key);
|
|
11
|
-
const formattedValue = stringify(value);
|
|
12
|
-
formattedAttributes[formattedKey] = formattedValue;
|
|
13
|
-
formattedLine += `, ${formattedKey}: ${formattedValue}`;
|
|
14
|
-
}
|
|
15
|
-
const parentFormattedAttributes = parentAttributes?.formattedAttributes;
|
|
16
|
-
for (const key in parentFormattedAttributes) {
|
|
17
|
-
if (!(key in formattedAttributes)) {
|
|
18
|
-
const formattedValue = parentFormattedAttributes[key];
|
|
19
|
-
formattedAttributes[key] = formattedValue;
|
|
20
|
-
formattedLine += `, ${key}: ${formattedValue}`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return { formattedAttributes, formattedLine };
|
|
24
|
-
};
|
|
25
|
-
const formatLogEntryAttributes = (attributes, entry) => {
|
|
26
|
-
let entryAttributes = "";
|
|
27
|
-
let reformatRest = false;
|
|
28
|
-
const omitInRest = {};
|
|
29
|
-
for (const key in entry.ownAttributes) {
|
|
30
|
-
const value = entry.ownAttributes[key];
|
|
31
|
-
if (value === void 0) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const formattedKey = stringify(key);
|
|
35
|
-
const formattedValue = stringify(value);
|
|
36
|
-
entryAttributes += `, ${formattedKey}: ${formattedValue}`;
|
|
37
|
-
if (key in attributes.formattedAttributes) {
|
|
38
|
-
reformatRest = true;
|
|
39
|
-
omitInRest[formattedKey] = true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (reformatRest) {
|
|
43
|
-
for (const key in attributes.formattedAttributes) {
|
|
44
|
-
if (!(key in omitInRest)) {
|
|
45
|
-
entryAttributes += `, ${key}: ${attributes.formattedAttributes[key]}`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
entryAttributes += attributes.formattedLine;
|
|
50
|
-
}
|
|
51
|
-
return entryAttributes;
|
|
52
|
-
};
|
|
53
|
-
const stringify = (value) => {
|
|
54
|
-
try {
|
|
55
|
-
return JSON.stringify(value);
|
|
56
|
-
} catch {
|
|
57
|
-
return JSON.stringify(inspect(value));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
export {
|
|
61
|
-
formatLogEntryAttributes,
|
|
62
|
-
formatLoggerAttributes,
|
|
63
|
-
stringify
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=formatting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.js","sources":["../../../../packages/logger/src/formatting.ts"],"sourcesContent":["import { LogEntry, LoggerAttributes } from './types'\nimport { inspect } from 'node:util'\n\nexport type FormattedAttributes = {\n\tformattedAttributes: Record<string, string>\n\tformattedLine: string\n}\n\nexport const formatLoggerAttributes = (parentAttributes: FormattedAttributes | undefined, ownAttributes: LoggerAttributes): FormattedAttributes => {\n\tconst formattedAttributes: Record<string, string> = {}\n\tlet formattedLine = ''\n\tfor (const key in ownAttributes) {\n\t\tconst value = ownAttributes[key]\n\t\tif (value === undefined) {\n\t\t\tcontinue\n\t\t}\n\t\tconst formattedKey = stringify(key)\n\t\tconst formattedValue = stringify(value)\n\t\tformattedAttributes[formattedKey] = formattedValue\n\t\tformattedLine += `, ${formattedKey}: ${formattedValue}`\n\t}\n\tconst parentFormattedAttributes = parentAttributes?.formattedAttributes\n\tfor (const key in parentFormattedAttributes) {\n\t\tif (!(key in formattedAttributes)) {\n\t\t\tconst formattedValue = parentFormattedAttributes[key]\n\t\t\tformattedAttributes[key] = formattedValue\n\t\t\tformattedLine += `, ${key}: ${formattedValue}`\n\t\t}\n\t}\n\treturn { formattedAttributes, formattedLine }\n}\n\nexport const formatLogEntryAttributes = (attributes: FormattedAttributes, entry: LogEntry): string => {\n\tlet entryAttributes = ''\n\tlet reformatRest = false\n\tconst omitInRest: Record<string, boolean> = {}\n\n\tfor (const key in entry.ownAttributes) {\n\t\tconst value = entry.ownAttributes[key]\n\t\tif (value === undefined) {\n\t\t\tcontinue\n\t\t}\n\t\tconst formattedKey = stringify(key)\n\t\tconst formattedValue = stringify(value)\n\t\tentryAttributes += `, ${formattedKey}: ${formattedValue}`\n\t\tif (key in attributes.formattedAttributes) {\n\t\t\treformatRest = true\n\t\t\tomitInRest[formattedKey] = true\n\t\t}\n\t}\n\tif (reformatRest) {\n\t\tfor (const key in attributes.formattedAttributes) {\n\t\t\tif (!(key in omitInRest)) {\n\t\t\t\tentryAttributes += `, ${key}: ${attributes.formattedAttributes[key]}`\n\t\t\t}\n\t\t}\n\t} else {\n\t\tentryAttributes += attributes.formattedLine\n\t}\n\n\treturn entryAttributes\n}\n\nexport const stringify = (value: unknown) => {\n\ttry {\n\t\treturn JSON.stringify(value)\n\t} catch {\n\t\treturn JSON.stringify(inspect(value))\n\t}\n}\n"],"names":[],"mappings":";AAQa,MAAA,yBAAyB,CAAC,kBAAmD,kBAAyD;AAClJ,QAAM,sBAA8C,CAAC;AACrD,MAAI,gBAAgB;AACpB,aAAW,OAAO,eAAe;AAC1B,UAAA,QAAQ,cAAc,GAAG;AAC/B,QAAI,UAAU,QAAW;AACxB;AAAA,IAAA;AAEK,UAAA,eAAe,UAAU,GAAG;AAC5B,UAAA,iBAAiB,UAAU,KAAK;AACtC,wBAAoB,YAAY,IAAI;AACnB,qBAAA,KAAK,YAAY,KAAK,cAAc;AAAA,EAAA;AAEtD,QAAM,4BAA4B,kBAAkB;AACpD,aAAW,OAAO,2BAA2B;AACxC,QAAA,EAAE,OAAO,sBAAsB;AAC5B,YAAA,iBAAiB,0BAA0B,GAAG;AACpD,0BAAoB,GAAG,IAAI;AACV,uBAAA,KAAK,GAAG,KAAK,cAAc;AAAA,IAAA;AAAA,EAC7C;AAEM,SAAA,EAAE,qBAAqB,cAAc;AAC7C;AAEa,MAAA,2BAA2B,CAAC,YAAiC,UAA4B;AACrG,MAAI,kBAAkB;AACtB,MAAI,eAAe;AACnB,QAAM,aAAsC,CAAC;AAElC,aAAA,OAAO,MAAM,eAAe;AAChC,UAAA,QAAQ,MAAM,cAAc,GAAG;AACrC,QAAI,UAAU,QAAW;AACxB;AAAA,IAAA;AAEK,UAAA,eAAe,UAAU,GAAG;AAC5B,UAAA,iBAAiB,UAAU,KAAK;AACnB,uBAAA,KAAK,YAAY,KAAK,cAAc;AACnD,QAAA,OAAO,WAAW,qBAAqB;AAC3B,qBAAA;AACf,iBAAW,YAAY,IAAI;AAAA,IAAA;AAAA,EAC5B;AAED,MAAI,cAAc;AACN,eAAA,OAAO,WAAW,qBAAqB;AAC7C,UAAA,EAAE,OAAO,aAAa;AACzB,2BAAmB,KAAK,GAAG,KAAK,WAAW,oBAAoB,GAAG,CAAC;AAAA,MAAA;AAAA,IACpE;AAAA,EACD,OACM;AACN,uBAAmB,WAAW;AAAA,EAAA;AAGxB,SAAA;AACR;AAEa,MAAA,YAAY,CAAC,UAAmB;AACxC,MAAA;AACI,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA,QACpB;AACP,WAAO,KAAK,UAAU,QAAQ,KAAK,CAAC;AAAA,EAAA;AAEtC;"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const levels = require("../levels.cjs");
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
-
class FingerCrossedLoggerHandler {
|
|
8
|
-
constructor(inner, options = {}) {
|
|
9
|
-
this.inner = inner;
|
|
10
|
-
__publicField(this, "buffer", []);
|
|
11
|
-
__publicField(this, "active", false);
|
|
12
|
-
__publicField(this, "options");
|
|
13
|
-
this.options = {
|
|
14
|
-
logAlwaysLevel: levels.LogLevels.info,
|
|
15
|
-
logWhenActivatedLevel: levels.LogLevels.debug,
|
|
16
|
-
activationLevel: levels.LogLevels.warn,
|
|
17
|
-
maxBufferSize: 100,
|
|
18
|
-
...options
|
|
19
|
-
};
|
|
20
|
-
if (this.options.logAlwaysLevel.value < this.options.logWhenActivatedLevel.value) {
|
|
21
|
-
this.options.logWhenActivatedLevel = this.options.logAlwaysLevel;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
static factory(options = {}) {
|
|
25
|
-
return (current, globalOptions) => new FingerCrossedLoggerHandler(current, { ...globalOptions.fingerCrossedOptions, ...options });
|
|
26
|
-
}
|
|
27
|
-
getMinLevel() {
|
|
28
|
-
return this.options.logWhenActivatedLevel.value;
|
|
29
|
-
}
|
|
30
|
-
handle(logEntry) {
|
|
31
|
-
const logEntryLevel = logEntry.level.value;
|
|
32
|
-
if (logEntryLevel < this.options.logWhenActivatedLevel.value) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (this.active) {
|
|
36
|
-
this.inner.handle(logEntry);
|
|
37
|
-
} else if (logEntryLevel >= this.options.activationLevel.value) {
|
|
38
|
-
this.active = true;
|
|
39
|
-
this.doFlush(this.options.logWhenActivatedLevel);
|
|
40
|
-
this.inner.handle(logEntry);
|
|
41
|
-
} else if (this.buffer.length === 0 && logEntryLevel >= this.options.logAlwaysLevel.value) {
|
|
42
|
-
this.inner.handle(logEntry);
|
|
43
|
-
} else {
|
|
44
|
-
this.buffer.push(logEntry);
|
|
45
|
-
if (this.buffer.length >= this.options.maxBufferSize) {
|
|
46
|
-
const first = this.buffer.shift();
|
|
47
|
-
if (first !== void 0 && first.level.value >= this.options.logAlwaysLevel.value) {
|
|
48
|
-
this.inner.handle(first);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
close() {
|
|
54
|
-
this.doFlush(this.options.logAlwaysLevel);
|
|
55
|
-
this.inner.close?.();
|
|
56
|
-
}
|
|
57
|
-
doFlush(minLevel) {
|
|
58
|
-
const entries = this.buffer;
|
|
59
|
-
this.buffer = [];
|
|
60
|
-
for (const entry of entries) {
|
|
61
|
-
if (entry.level.value >= minLevel.value) {
|
|
62
|
-
this.inner.handle(entry);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.FingerCrossedLoggerHandler = FingerCrossedLoggerHandler;
|
|
68
|
-
//# sourceMappingURL=FingerCrossedLoggerHandler.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FingerCrossedLoggerHandler.cjs","sources":["../../../../../packages/logger/src/handlers/FingerCrossedLoggerHandler.ts"],"sourcesContent":["import { LogEntry, LoggerHandler, LoggerHandlerFactory, LogLevel } from '../types'\nimport { LogLevels } from '../levels'\n\nexport interface FingerCrossedLoggerHandlerOptions {\n\tlogAlwaysLevel: LogLevel\n\tlogWhenActivatedLevel: LogLevel\n\tactivationLevel: LogLevel\n\tmaxBufferSize: number\n}\n\nexport class FingerCrossedLoggerHandler implements LoggerHandler {\n\tprivate buffer: LogEntry[] = []\n\n\tprivate active: boolean = false\n\tprivate options: FingerCrossedLoggerHandlerOptions\n\n\tconstructor(\n\t\tprivate readonly inner: LoggerHandler,\n\t\toptions: Partial<FingerCrossedLoggerHandlerOptions> = {},\n\t) {\n\t\tthis.options = {\n\t\t\tlogAlwaysLevel: LogLevels.info,\n\t\t\tlogWhenActivatedLevel: LogLevels.debug,\n\t\t\tactivationLevel: LogLevels.warn,\n\t\t\tmaxBufferSize: 100,\n\t\t\t...options,\n\t\t}\n\t\tif (this.options.logAlwaysLevel.value < this.options.logWhenActivatedLevel.value) {\n\t\t\tthis.options.logWhenActivatedLevel = this.options.logAlwaysLevel\n\t\t}\n\t}\n\n\tpublic static factory(options: Partial<FingerCrossedLoggerHandlerOptions> = {}): LoggerHandlerFactory {\n\t\treturn (current, globalOptions) => new FingerCrossedLoggerHandler(current, { ...globalOptions.fingerCrossedOptions, ...options })\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.options.logWhenActivatedLevel.value\n\t}\n\n\n\thandle(logEntry: LogEntry): void {\n\t\tconst logEntryLevel = logEntry.level.value\n\t\tif (logEntryLevel < this.options.logWhenActivatedLevel.value) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.active) {\n\t\t\tthis.inner.handle(logEntry)\n\n\t\t} else if (logEntryLevel >= this.options.activationLevel.value) {\n\t\t\tthis.active = true\n\t\t\tthis.doFlush(this.options.logWhenActivatedLevel)\n\t\t\tthis.inner.handle(logEntry)\n\n\t\t} else if (this.buffer.length === 0 && logEntryLevel >= this.options.logAlwaysLevel.value) {\n\t\t\tthis.inner.handle(logEntry)\n\n\t\t} else {\n\t\t\tthis.buffer.push(logEntry)\n\n\t\t\tif (this.buffer.length >= this.options.maxBufferSize) {\n\t\t\t\tconst first = this.buffer.shift()\n\t\t\t\tif (first !== undefined && first.level.value >= this.options.logAlwaysLevel.value) {\n\t\t\t\t\tthis.inner.handle(first)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tclose(): void {\n\t\tthis.doFlush(this.options.logAlwaysLevel)\n\t\tthis.inner.close?.()\n\t}\n\n\tprivate doFlush(minLevel: LogLevel) {\n\t\tconst entries = this.buffer\n\t\tthis.buffer = []\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.level.value >= minLevel.value) {\n\t\t\t\tthis.inner.handle(entry)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["LogLevels"],"mappings":";;;;;;AAUO,MAAM,2BAAoD;AAAA,EAMhE,YACkB,OACjB,UAAsD,IACrD;AAFgB,SAAA,QAAA;AANlB,kBAAA,MAAQ,UAAqB,EAAC;AAE9B,kBAAA,MAAQ,UAAkB,KAAA;AAClB,kBAAA,MAAA,SAAA;AAMP,SAAK,UAAU;AAAA,MACd,gBAAgBA,OAAU,UAAA;AAAA,MAC1B,uBAAuBA,OAAU,UAAA;AAAA,MACjC,iBAAiBA,OAAU,UAAA;AAAA,MAC3B,eAAe;AAAA,MACf,GAAG;AAAA,IACJ;AACA,QAAI,KAAK,QAAQ,eAAe,QAAQ,KAAK,QAAQ,sBAAsB,OAAO;AAC5E,WAAA,QAAQ,wBAAwB,KAAK,QAAQ;AAAA,IAAA;AAAA,EACnD;AAAA,EAGD,OAAc,QAAQ,UAAsD,IAA0B;AACrG,WAAO,CAAC,SAAS,kBAAkB,IAAI,2BAA2B,SAAS,EAAE,GAAG,cAAc,sBAAsB,GAAG,SAAS;AAAA,EAAA;AAAA,EAGjI,cAAsB;AACd,WAAA,KAAK,QAAQ,sBAAsB;AAAA,EAAA;AAAA,EAI3C,OAAO,UAA0B;AAC1B,UAAA,gBAAgB,SAAS,MAAM;AACrC,QAAI,gBAAgB,KAAK,QAAQ,sBAAsB,OAAO;AAC7D;AAAA,IAAA;AAGD,QAAI,KAAK,QAAQ;AACX,WAAA,MAAM,OAAO,QAAQ;AAAA,IAEhB,WAAA,iBAAiB,KAAK,QAAQ,gBAAgB,OAAO;AAC/D,WAAK,SAAS;AACT,WAAA,QAAQ,KAAK,QAAQ,qBAAqB;AAC1C,WAAA,MAAM,OAAO,QAAQ;AAAA,IAAA,WAEhB,KAAK,OAAO,WAAW,KAAK,iBAAiB,KAAK,QAAQ,eAAe,OAAO;AACrF,WAAA,MAAM,OAAO,QAAQ;AAAA,IAAA,OAEpB;AACD,WAAA,OAAO,KAAK,QAAQ;AAEzB,UAAI,KAAK,OAAO,UAAU,KAAK,QAAQ,eAAe;AAC/C,cAAA,QAAQ,KAAK,OAAO,MAAM;AAC5B,YAAA,UAAU,UAAa,MAAM,MAAM,SAAS,KAAK,QAAQ,eAAe,OAAO;AAC7E,eAAA,MAAM,OAAO,KAAK;AAAA,QAAA;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AAAA,EAGD,QAAc;AACR,SAAA,QAAQ,KAAK,QAAQ,cAAc;AACxC,SAAK,MAAM,QAAQ;AAAA,EAAA;AAAA,EAGZ,QAAQ,UAAoB;AACnC,UAAM,UAAU,KAAK;AACrB,SAAK,SAAS,CAAC;AACf,eAAW,SAAS,SAAS;AAC5B,UAAI,MAAM,MAAM,SAAS,SAAS,OAAO;AACnC,aAAA,MAAM,OAAO,KAAK;AAAA,MAAA;AAAA,IACxB;AAAA,EACD;AAEF;;"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { LogLevels } from "../levels.js";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
class FingerCrossedLoggerHandler {
|
|
6
|
-
constructor(inner, options = {}) {
|
|
7
|
-
this.inner = inner;
|
|
8
|
-
__publicField(this, "buffer", []);
|
|
9
|
-
__publicField(this, "active", false);
|
|
10
|
-
__publicField(this, "options");
|
|
11
|
-
this.options = {
|
|
12
|
-
logAlwaysLevel: LogLevels.info,
|
|
13
|
-
logWhenActivatedLevel: LogLevels.debug,
|
|
14
|
-
activationLevel: LogLevels.warn,
|
|
15
|
-
maxBufferSize: 100,
|
|
16
|
-
...options
|
|
17
|
-
};
|
|
18
|
-
if (this.options.logAlwaysLevel.value < this.options.logWhenActivatedLevel.value) {
|
|
19
|
-
this.options.logWhenActivatedLevel = this.options.logAlwaysLevel;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static factory(options = {}) {
|
|
23
|
-
return (current, globalOptions) => new FingerCrossedLoggerHandler(current, { ...globalOptions.fingerCrossedOptions, ...options });
|
|
24
|
-
}
|
|
25
|
-
getMinLevel() {
|
|
26
|
-
return this.options.logWhenActivatedLevel.value;
|
|
27
|
-
}
|
|
28
|
-
handle(logEntry) {
|
|
29
|
-
const logEntryLevel = logEntry.level.value;
|
|
30
|
-
if (logEntryLevel < this.options.logWhenActivatedLevel.value) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (this.active) {
|
|
34
|
-
this.inner.handle(logEntry);
|
|
35
|
-
} else if (logEntryLevel >= this.options.activationLevel.value) {
|
|
36
|
-
this.active = true;
|
|
37
|
-
this.doFlush(this.options.logWhenActivatedLevel);
|
|
38
|
-
this.inner.handle(logEntry);
|
|
39
|
-
} else if (this.buffer.length === 0 && logEntryLevel >= this.options.logAlwaysLevel.value) {
|
|
40
|
-
this.inner.handle(logEntry);
|
|
41
|
-
} else {
|
|
42
|
-
this.buffer.push(logEntry);
|
|
43
|
-
if (this.buffer.length >= this.options.maxBufferSize) {
|
|
44
|
-
const first = this.buffer.shift();
|
|
45
|
-
if (first !== void 0 && first.level.value >= this.options.logAlwaysLevel.value) {
|
|
46
|
-
this.inner.handle(first);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
close() {
|
|
52
|
-
this.doFlush(this.options.logAlwaysLevel);
|
|
53
|
-
this.inner.close?.();
|
|
54
|
-
}
|
|
55
|
-
doFlush(minLevel) {
|
|
56
|
-
const entries = this.buffer;
|
|
57
|
-
this.buffer = [];
|
|
58
|
-
for (const entry of entries) {
|
|
59
|
-
if (entry.level.value >= minLevel.value) {
|
|
60
|
-
this.inner.handle(entry);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
FingerCrossedLoggerHandler
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=FingerCrossedLoggerHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FingerCrossedLoggerHandler.js","sources":["../../../../../packages/logger/src/handlers/FingerCrossedLoggerHandler.ts"],"sourcesContent":["import { LogEntry, LoggerHandler, LoggerHandlerFactory, LogLevel } from '../types'\nimport { LogLevels } from '../levels'\n\nexport interface FingerCrossedLoggerHandlerOptions {\n\tlogAlwaysLevel: LogLevel\n\tlogWhenActivatedLevel: LogLevel\n\tactivationLevel: LogLevel\n\tmaxBufferSize: number\n}\n\nexport class FingerCrossedLoggerHandler implements LoggerHandler {\n\tprivate buffer: LogEntry[] = []\n\n\tprivate active: boolean = false\n\tprivate options: FingerCrossedLoggerHandlerOptions\n\n\tconstructor(\n\t\tprivate readonly inner: LoggerHandler,\n\t\toptions: Partial<FingerCrossedLoggerHandlerOptions> = {},\n\t) {\n\t\tthis.options = {\n\t\t\tlogAlwaysLevel: LogLevels.info,\n\t\t\tlogWhenActivatedLevel: LogLevels.debug,\n\t\t\tactivationLevel: LogLevels.warn,\n\t\t\tmaxBufferSize: 100,\n\t\t\t...options,\n\t\t}\n\t\tif (this.options.logAlwaysLevel.value < this.options.logWhenActivatedLevel.value) {\n\t\t\tthis.options.logWhenActivatedLevel = this.options.logAlwaysLevel\n\t\t}\n\t}\n\n\tpublic static factory(options: Partial<FingerCrossedLoggerHandlerOptions> = {}): LoggerHandlerFactory {\n\t\treturn (current, globalOptions) => new FingerCrossedLoggerHandler(current, { ...globalOptions.fingerCrossedOptions, ...options })\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.options.logWhenActivatedLevel.value\n\t}\n\n\n\thandle(logEntry: LogEntry): void {\n\t\tconst logEntryLevel = logEntry.level.value\n\t\tif (logEntryLevel < this.options.logWhenActivatedLevel.value) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.active) {\n\t\t\tthis.inner.handle(logEntry)\n\n\t\t} else if (logEntryLevel >= this.options.activationLevel.value) {\n\t\t\tthis.active = true\n\t\t\tthis.doFlush(this.options.logWhenActivatedLevel)\n\t\t\tthis.inner.handle(logEntry)\n\n\t\t} else if (this.buffer.length === 0 && logEntryLevel >= this.options.logAlwaysLevel.value) {\n\t\t\tthis.inner.handle(logEntry)\n\n\t\t} else {\n\t\t\tthis.buffer.push(logEntry)\n\n\t\t\tif (this.buffer.length >= this.options.maxBufferSize) {\n\t\t\t\tconst first = this.buffer.shift()\n\t\t\t\tif (first !== undefined && first.level.value >= this.options.logAlwaysLevel.value) {\n\t\t\t\t\tthis.inner.handle(first)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tclose(): void {\n\t\tthis.doFlush(this.options.logAlwaysLevel)\n\t\tthis.inner.close?.()\n\t}\n\n\tprivate doFlush(minLevel: LogLevel) {\n\t\tconst entries = this.buffer\n\t\tthis.buffer = []\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.level.value >= minLevel.value) {\n\t\t\t\tthis.inner.handle(entry)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAUO,MAAM,2BAAoD;AAAA,EAMhE,YACkB,OACjB,UAAsD,IACrD;AAFgB,SAAA,QAAA;AANlB,kBAAA,MAAQ,UAAqB,EAAC;AAE9B,kBAAA,MAAQ,UAAkB,KAAA;AAClB,kBAAA,MAAA,SAAA;AAMP,SAAK,UAAU;AAAA,MACd,gBAAgB,UAAU;AAAA,MAC1B,uBAAuB,UAAU;AAAA,MACjC,iBAAiB,UAAU;AAAA,MAC3B,eAAe;AAAA,MACf,GAAG;AAAA,IACJ;AACA,QAAI,KAAK,QAAQ,eAAe,QAAQ,KAAK,QAAQ,sBAAsB,OAAO;AAC5E,WAAA,QAAQ,wBAAwB,KAAK,QAAQ;AAAA,IAAA;AAAA,EACnD;AAAA,EAGD,OAAc,QAAQ,UAAsD,IAA0B;AACrG,WAAO,CAAC,SAAS,kBAAkB,IAAI,2BAA2B,SAAS,EAAE,GAAG,cAAc,sBAAsB,GAAG,SAAS;AAAA,EAAA;AAAA,EAGjI,cAAsB;AACd,WAAA,KAAK,QAAQ,sBAAsB;AAAA,EAAA;AAAA,EAI3C,OAAO,UAA0B;AAC1B,UAAA,gBAAgB,SAAS,MAAM;AACrC,QAAI,gBAAgB,KAAK,QAAQ,sBAAsB,OAAO;AAC7D;AAAA,IAAA;AAGD,QAAI,KAAK,QAAQ;AACX,WAAA,MAAM,OAAO,QAAQ;AAAA,IAEhB,WAAA,iBAAiB,KAAK,QAAQ,gBAAgB,OAAO;AAC/D,WAAK,SAAS;AACT,WAAA,QAAQ,KAAK,QAAQ,qBAAqB;AAC1C,WAAA,MAAM,OAAO,QAAQ;AAAA,IAAA,WAEhB,KAAK,OAAO,WAAW,KAAK,iBAAiB,KAAK,QAAQ,eAAe,OAAO;AACrF,WAAA,MAAM,OAAO,QAAQ;AAAA,IAAA,OAEpB;AACD,WAAA,OAAO,KAAK,QAAQ;AAEzB,UAAI,KAAK,OAAO,UAAU,KAAK,QAAQ,eAAe;AAC/C,cAAA,QAAQ,KAAK,OAAO,MAAM;AAC5B,YAAA,UAAU,UAAa,MAAM,MAAM,SAAS,KAAK,QAAQ,eAAe,OAAO;AAC7E,eAAA,MAAM,OAAO,KAAK;AAAA,QAAA;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AAAA,EAGD,QAAc;AACR,SAAA,QAAQ,KAAK,QAAQ,cAAc;AACxC,SAAK,MAAM,QAAQ;AAAA,EAAA;AAAA,EAGZ,QAAQ,UAAoB;AACnC,UAAM,UAAU,KAAK;AACrB,SAAK,SAAS,CAAC;AACf,eAAW,SAAS,SAAS;AAC5B,UAAI,MAAM,MAAM,SAAS,SAAS,OAAO;AACnC,aAAA,MAAM,OAAO,KAAK;AAAA,MAAA;AAAA,IACxB;AAAA,EACD;AAEF;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const levels = require("../levels.cjs");
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
7
|
-
class JsonStreamLoggerHandler {
|
|
8
|
-
constructor(stream, options = {}) {
|
|
9
|
-
this.stream = stream;
|
|
10
|
-
__publicField(this, "options");
|
|
11
|
-
this.options = {
|
|
12
|
-
logLevel: levels.LogLevels.debug,
|
|
13
|
-
...options
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
handle(entry) {
|
|
17
|
-
if (entry.level.value < this.options.logLevel.value) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const formatted = entry.format();
|
|
21
|
-
const line = `{"time": "${entry.isoTime}", "level": "${entry.level.name}", "message": ${formatted.message}${formatted.error}${formatted.attributes}}
|
|
22
|
-
`;
|
|
23
|
-
this.stream.write(line);
|
|
24
|
-
}
|
|
25
|
-
getMinLevel() {
|
|
26
|
-
return this.options.logLevel.value;
|
|
27
|
-
}
|
|
28
|
-
close() {
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.JsonStreamLoggerHandler = JsonStreamLoggerHandler;
|
|
32
|
-
//# sourceMappingURL=JsonStreamLoggerHandler.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonStreamLoggerHandler.cjs","sources":["../../../../../packages/logger/src/handlers/JsonStreamLoggerHandler.ts"],"sourcesContent":["import { LogEntry, LoggerHandler, LogLevel } from '../types'\nimport { LogLevels } from '../levels'\n\nexport interface JsonStreamLoggerHandlerOptions {\n\tlogLevel: LogLevel\n}\n\nexport class JsonStreamLoggerHandler implements LoggerHandler {\n\tprivate options: JsonStreamLoggerHandlerOptions\n\n\tconstructor(\n\t\tprivate readonly stream: NodeJS.WritableStream,\n\t\toptions: Partial<JsonStreamLoggerHandlerOptions> = {},\n\t) {\n\t\tthis.options = {\n\t\t\tlogLevel: LogLevels.debug,\n\t\t\t...options,\n\t\t}\n\t}\n\n\thandle(entry: LogEntry): void {\n\t\tif (entry.level.value < this.options.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tconst formatted = entry.format()\n\t\tconst line = `{\"time\": \"${entry.isoTime}\", \"level\": \"${entry.level.name}\", \"message\": ${formatted.message}${formatted.error}${formatted.attributes}}\\n`\n\t\tthis.stream.write(line)\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.options.logLevel.value\n\t}\n\n\tclose(): void {\n\t}\n}\n"],"names":["LogLevels"],"mappings":";;;;;;AAOO,MAAM,wBAAiD;AAAA,EAG7D,YACkB,QACjB,UAAmD,IAClD;AAFgB,SAAA,SAAA;AAHV,kBAAA,MAAA,SAAA;AAMP,SAAK,UAAU;AAAA,MACd,UAAUA,OAAU,UAAA;AAAA,MACpB,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGD,OAAO,OAAuB;AAC7B,QAAI,MAAM,MAAM,QAAQ,KAAK,QAAQ,SAAS,OAAO;AACpD;AAAA,IAAA;AAEK,UAAA,YAAY,MAAM,OAAO;AAC/B,UAAM,OAAO,aAAa,MAAM,OAAO,gBAAgB,MAAM,MAAM,IAAI,iBAAiB,UAAU,OAAO,GAAG,UAAU,KAAK,GAAG,UAAU,UAAU;AAAA;AAC7I,SAAA,OAAO,MAAM,IAAI;AAAA,EAAA;AAAA,EAGvB,cAAsB;AACd,WAAA,KAAK,QAAQ,SAAS;AAAA,EAAA;AAAA,EAG9B,QAAc;AAAA,EAAA;AAEf;;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { LogLevels } from "../levels.js";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
5
|
-
class JsonStreamLoggerHandler {
|
|
6
|
-
constructor(stream, options = {}) {
|
|
7
|
-
this.stream = stream;
|
|
8
|
-
__publicField(this, "options");
|
|
9
|
-
this.options = {
|
|
10
|
-
logLevel: LogLevels.debug,
|
|
11
|
-
...options
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
handle(entry) {
|
|
15
|
-
if (entry.level.value < this.options.logLevel.value) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const formatted = entry.format();
|
|
19
|
-
const line = `{"time": "${entry.isoTime}", "level": "${entry.level.name}", "message": ${formatted.message}${formatted.error}${formatted.attributes}}
|
|
20
|
-
`;
|
|
21
|
-
this.stream.write(line);
|
|
22
|
-
}
|
|
23
|
-
getMinLevel() {
|
|
24
|
-
return this.options.logLevel.value;
|
|
25
|
-
}
|
|
26
|
-
close() {
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
JsonStreamLoggerHandler
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=JsonStreamLoggerHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonStreamLoggerHandler.js","sources":["../../../../../packages/logger/src/handlers/JsonStreamLoggerHandler.ts"],"sourcesContent":["import { LogEntry, LoggerHandler, LogLevel } from '../types'\nimport { LogLevels } from '../levels'\n\nexport interface JsonStreamLoggerHandlerOptions {\n\tlogLevel: LogLevel\n}\n\nexport class JsonStreamLoggerHandler implements LoggerHandler {\n\tprivate options: JsonStreamLoggerHandlerOptions\n\n\tconstructor(\n\t\tprivate readonly stream: NodeJS.WritableStream,\n\t\toptions: Partial<JsonStreamLoggerHandlerOptions> = {},\n\t) {\n\t\tthis.options = {\n\t\t\tlogLevel: LogLevels.debug,\n\t\t\t...options,\n\t\t}\n\t}\n\n\thandle(entry: LogEntry): void {\n\t\tif (entry.level.value < this.options.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tconst formatted = entry.format()\n\t\tconst line = `{\"time\": \"${entry.isoTime}\", \"level\": \"${entry.level.name}\", \"message\": ${formatted.message}${formatted.error}${formatted.attributes}}\\n`\n\t\tthis.stream.write(line)\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.options.logLevel.value\n\t}\n\n\tclose(): void {\n\t}\n}\n"],"names":[],"mappings":";;;;AAOO,MAAM,wBAAiD;AAAA,EAG7D,YACkB,QACjB,UAAmD,IAClD;AAFgB,SAAA,SAAA;AAHV,kBAAA,MAAA,SAAA;AAMP,SAAK,UAAU;AAAA,MACd,UAAU,UAAU;AAAA,MACpB,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGD,OAAO,OAAuB;AAC7B,QAAI,MAAM,MAAM,QAAQ,KAAK,QAAQ,SAAS,OAAO;AACpD;AAAA,IAAA;AAEK,UAAA,YAAY,MAAM,OAAO;AAC/B,UAAM,OAAO,aAAa,MAAM,OAAO,gBAAgB,MAAM,MAAM,IAAI,iBAAiB,UAAU,OAAO,GAAG,UAAU,KAAK,GAAG,UAAU,UAAU;AAAA;AAC7I,SAAA,OAAO,MAAM,IAAI;AAAA,EAAA;AAAA,EAGvB,cAAsB;AACd,WAAA,KAAK,QAAQ,SAAS;AAAA,EAAA;AAAA,EAG9B,QAAc;AAAA,EAAA;AAEf;"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class LoggerHandlerList {
|
|
4
|
-
constructor(transports = []) {
|
|
5
|
-
this.transports = transports;
|
|
6
|
-
}
|
|
7
|
-
getMinLevel() {
|
|
8
|
-
return Math.min(Number.MAX_SAFE_INTEGER, ...this.transports.map((it) => it.getMinLevel()));
|
|
9
|
-
}
|
|
10
|
-
addHandler(transport) {
|
|
11
|
-
this.transports.push(transport);
|
|
12
|
-
}
|
|
13
|
-
handle(logEntry) {
|
|
14
|
-
for (const transport of this.transports) {
|
|
15
|
-
transport.handle(logEntry);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
close() {
|
|
19
|
-
for (const transport of this.transports) {
|
|
20
|
-
transport.close();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.LoggerHandlerList = LoggerHandlerList;
|
|
25
|
-
//# sourceMappingURL=LoggerHandlerList.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerHandlerList.cjs","sources":["../../../../../packages/logger/src/handlers/LoggerHandlerList.ts"],"sourcesContent":["import { LogEntry, LoggerHandler } from '../types'\n\nexport class LoggerHandlerList implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly transports: LoggerHandler[] = [],\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn Math.min(Number.MAX_SAFE_INTEGER, ...this.transports.map(it => it.getMinLevel()))\n\t}\n\n\tpublic addHandler(transport: LoggerHandler) {\n\t\tthis.transports.push(transport)\n\t}\n\n\thandle(logEntry: LogEntry) {\n\t\tfor (const transport of this.transports) {\n\t\t\ttransport.handle(logEntry)\n\t\t}\n\t}\n\n\tclose(): void {\n\t\tfor (const transport of this.transports) {\n\t\t\ttransport.close()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,kBAA2C;AAAA,EACvD,YACkB,aAA8B,IAC9C;AADgB,SAAA,aAAA;AAAA,EAAA;AAAA,EAIlB,cAAsB;AACrB,WAAO,KAAK,IAAI,OAAO,kBAAkB,GAAG,KAAK,WAAW,IAAI,CAAM,OAAA,GAAG,YAAa,CAAA,CAAC;AAAA,EAAA;AAAA,EAGjF,WAAW,WAA0B;AACtC,SAAA,WAAW,KAAK,SAAS;AAAA,EAAA;AAAA,EAG/B,OAAO,UAAoB;AACf,eAAA,aAAa,KAAK,YAAY;AACxC,gBAAU,OAAO,QAAQ;AAAA,IAAA;AAAA,EAC1B;AAAA,EAGD,QAAc;AACF,eAAA,aAAa,KAAK,YAAY;AACxC,gBAAU,MAAM;AAAA,IAAA;AAAA,EACjB;AAEF;;"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
class LoggerHandlerList {
|
|
2
|
-
constructor(transports = []) {
|
|
3
|
-
this.transports = transports;
|
|
4
|
-
}
|
|
5
|
-
getMinLevel() {
|
|
6
|
-
return Math.min(Number.MAX_SAFE_INTEGER, ...this.transports.map((it) => it.getMinLevel()));
|
|
7
|
-
}
|
|
8
|
-
addHandler(transport) {
|
|
9
|
-
this.transports.push(transport);
|
|
10
|
-
}
|
|
11
|
-
handle(logEntry) {
|
|
12
|
-
for (const transport of this.transports) {
|
|
13
|
-
transport.handle(logEntry);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
close() {
|
|
17
|
-
for (const transport of this.transports) {
|
|
18
|
-
transport.close();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
LoggerHandlerList
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=LoggerHandlerList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerHandlerList.js","sources":["../../../../../packages/logger/src/handlers/LoggerHandlerList.ts"],"sourcesContent":["import { LogEntry, LoggerHandler } from '../types'\n\nexport class LoggerHandlerList implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly transports: LoggerHandler[] = [],\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn Math.min(Number.MAX_SAFE_INTEGER, ...this.transports.map(it => it.getMinLevel()))\n\t}\n\n\tpublic addHandler(transport: LoggerHandler) {\n\t\tthis.transports.push(transport)\n\t}\n\n\thandle(logEntry: LogEntry) {\n\t\tfor (const transport of this.transports) {\n\t\t\ttransport.handle(logEntry)\n\t\t}\n\t}\n\n\tclose(): void {\n\t\tfor (const transport of this.transports) {\n\t\t\ttransport.close()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,kBAA2C;AAAA,EACvD,YACkB,aAA8B,IAC9C;AADgB,SAAA,aAAA;AAAA,EAAA;AAAA,EAIlB,cAAsB;AACrB,WAAO,KAAK,IAAI,OAAO,kBAAkB,GAAG,KAAK,WAAW,IAAI,CAAM,OAAA,GAAG,YAAa,CAAA,CAAC;AAAA,EAAA;AAAA,EAGjF,WAAW,WAA0B;AACtC,SAAA,WAAW,KAAK,SAAS;AAAA,EAAA;AAAA,EAG/B,OAAO,UAAoB;AACf,eAAA,aAAa,KAAK,YAAY;AACxC,gBAAU,OAAO,QAAQ;AAAA,IAAA;AAAA,EAC1B;AAAA,EAGD,QAAc;AACF,eAAA,aAAa,KAAK,YAAY;AACxC,gBAAU,MAAM;AAAA,IAAA;AAAA,EACjB;AAEF;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class NullLoggerHandler {
|
|
4
|
-
close() {
|
|
5
|
-
}
|
|
6
|
-
getMinLevel() {
|
|
7
|
-
return Number.POSITIVE_INFINITY;
|
|
8
|
-
}
|
|
9
|
-
handle() {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.NullLoggerHandler = NullLoggerHandler;
|
|
13
|
-
//# sourceMappingURL=NullLoggerHandler.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NullLoggerHandler.cjs","sources":["../../../../../packages/logger/src/handlers/NullLoggerHandler.ts"],"sourcesContent":["import { LoggerHandler } from '../types'\n\nexport class NullLoggerHandler implements LoggerHandler {\n\tclose(): void {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn Number.POSITIVE_INFINITY\n\t}\n\n\thandle(): void {\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,kBAA2C;AAAA,EACvD,QAAc;AAAA,EAAA;AAAA,EAGd,cAAsB;AACrB,WAAO,OAAO;AAAA,EAAA;AAAA,EAGf,SAAe;AAAA,EAAA;AAEhB;;"}
|