@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/logger",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.35",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -23,10 +23,15 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "
|
|
26
|
+
"@types/node": "catalog:"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"chalk": "
|
|
29
|
+
"chalk": "catalog:"
|
|
30
30
|
},
|
|
31
|
-
"type": "module"
|
|
31
|
+
"type": "module",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/contember/contember.git",
|
|
35
|
+
"directory": "packages/logger"
|
|
36
|
+
}
|
|
32
37
|
}
|
|
@@ -38,7 +38,6 @@ export class FingerCrossedLoggerHandler implements LoggerHandler {
|
|
|
38
38
|
return this.options.logWhenActivatedLevel.value
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
41
|
handle(logEntry: LogEntry): void {
|
|
43
42
|
const logEntryLevel = logEntry.level.value
|
|
44
43
|
if (logEntryLevel < this.options.logWhenActivatedLevel.value) {
|
|
@@ -47,15 +46,12 @@ export class FingerCrossedLoggerHandler implements LoggerHandler {
|
|
|
47
46
|
|
|
48
47
|
if (this.active) {
|
|
49
48
|
this.inner.handle(logEntry)
|
|
50
|
-
|
|
51
49
|
} else if (logEntryLevel >= this.options.activationLevel.value) {
|
|
52
50
|
this.active = true
|
|
53
51
|
this.doFlush(this.options.logWhenActivatedLevel)
|
|
54
52
|
this.inner.handle(logEntry)
|
|
55
|
-
|
|
56
53
|
} else if (this.buffer.length === 0 && logEntryLevel >= this.options.logAlwaysLevel.value) {
|
|
57
54
|
this.inner.handle(logEntry)
|
|
58
|
-
|
|
59
55
|
} else {
|
|
60
56
|
this.buffer.push(logEntry)
|
|
61
57
|
|
|
@@ -23,7 +23,8 @@ export class JsonStreamLoggerHandler implements LoggerHandler {
|
|
|
23
23
|
return
|
|
24
24
|
}
|
|
25
25
|
const formatted = entry.format()
|
|
26
|
-
const line =
|
|
26
|
+
const line =
|
|
27
|
+
`{"time": "${entry.isoTime}", "level": "${entry.level.name}", "message": ${formatted.message}${formatted.error}${formatted.attributes}}\n`
|
|
27
28
|
this.stream.write(line)
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -6,7 +6,9 @@ import { LogLevels } from '../levels'
|
|
|
6
6
|
export interface PrettyPrintLoggerHandlerOptions {
|
|
7
7
|
logLevel: LogLevel
|
|
8
8
|
formatters: {
|
|
9
|
-
[key: string]: (
|
|
9
|
+
[key: string]: (
|
|
10
|
+
args: { value: any; formattedValue: string; key: string; chalk: typeof chalk; attributes: LoggerAttributes },
|
|
11
|
+
) => undefined | string | { line: string }
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -64,7 +66,6 @@ export class PrettyPrintLoggerHandler implements LoggerHandler {
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
68
69
|
private formatTime(date: string): string {
|
|
69
70
|
const result = date.match(/^([0-9-]+)T([0-9:]+)\.(\d+)Z$/)
|
|
70
71
|
if (!result) {
|
|
@@ -3,7 +3,6 @@ import { LogEntry, LoggerHandler } from '../types'
|
|
|
3
3
|
export class TestLoggerHandler implements LoggerHandler {
|
|
4
4
|
public readonly messages: LogEntry[] = []
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
constructor(
|
|
8
7
|
private print = false,
|
|
9
8
|
) {
|
|
@@ -19,7 +18,6 @@ export class TestLoggerHandler implements LoggerHandler {
|
|
|
19
18
|
handle(logEntry: LogEntry): void {
|
|
20
19
|
this.messages.push(logEntry)
|
|
21
20
|
if (this.print) {
|
|
22
|
-
// eslint-disable-next-line no-console
|
|
23
21
|
console.error(logEntry.message)
|
|
24
22
|
}
|
|
25
23
|
}
|
package/src/impl.ts
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
LoggerChildOptions,
|
|
7
7
|
LoggerHandler,
|
|
8
8
|
LoggerOptions,
|
|
9
|
-
LogLevel,
|
|
9
|
+
LogLevel,
|
|
10
|
+
LogLevelName,
|
|
10
11
|
} from './types'
|
|
11
12
|
import { LogLevels } from './levels'
|
|
12
13
|
import { formatLogEntryAttributes, formatLoggerAttributes, FormattedAttributes, stringify } from './formatting'
|
|
@@ -21,9 +22,7 @@ export const createLogger = (
|
|
|
21
22
|
return LoggerImpl.create(handler, attributes, options)
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
25
|
export class LoggerImpl implements Logger {
|
|
26
|
-
|
|
27
26
|
public readonly attributes: LoggerAttributes
|
|
28
27
|
private formattedAttributes: FormattedAttributes | undefined
|
|
29
28
|
private minLevelValue: number
|
|
@@ -78,7 +77,11 @@ export class LoggerImpl implements Logger {
|
|
|
78
77
|
return new LoggerImpl(newHandler, attributes, this.depth + 1, this, { ...this.options, ...options })
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
public async scope<T>(
|
|
80
|
+
public async scope<T>(
|
|
81
|
+
cb: (logger: Logger) => Promise<T> | T,
|
|
82
|
+
attributes: LoggerAttributes = {},
|
|
83
|
+
options: Partial<LoggerChildOptions> = {},
|
|
84
|
+
): Promise<T> {
|
|
82
85
|
const logger = this.child(attributes, options)
|
|
83
86
|
try {
|
|
84
87
|
return await withLogger(logger, () => cb(logger))
|
|
@@ -90,13 +93,14 @@ export class LoggerImpl implements Logger {
|
|
|
90
93
|
private doLog(level: LogLevel, errorOrMessage: unknown, { error: errorAttr, message: messageAttr, ...attributes }: LoggerAttributes = {}) {
|
|
91
94
|
const error: unknown | undefined = typeof errorOrMessage !== 'string' ? errorOrMessage : errorAttr
|
|
92
95
|
const errorMessage = typeof error === 'object' && error !== null && typeof (error as any).message === 'string'
|
|
93
|
-
? (error as any).message
|
|
96
|
+
? (error as any).message
|
|
97
|
+
: undefined
|
|
94
98
|
|
|
95
99
|
const passedMessage = typeof errorOrMessage === 'string'
|
|
96
100
|
? errorOrMessage
|
|
97
101
|
: (typeof messageAttr === 'string')
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
? messageAttr
|
|
103
|
+
: undefined
|
|
100
104
|
|
|
101
105
|
const message = errorMessage && passedMessage ? `${passedMessage}: ${errorMessage}` : (passedMessage ?? errorMessage ?? 'undefined message')
|
|
102
106
|
|
|
@@ -144,6 +148,3 @@ export class LoggerImpl implements Logger {
|
|
|
144
148
|
return this.formattedAttributes
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
package/src/proxy.ts
CHANGED
|
@@ -40,7 +40,7 @@ class CurrentLoggerProxy implements Logger {
|
|
|
40
40
|
getLogger().close()
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
scope<T>(cb: (logger: Logger) =>
|
|
43
|
+
scope<T>(cb: (logger: Logger) => Promise<T> | T, attributes?: LoggerAttributes, options?: Partial<LoggerOptions>): Promise<T> {
|
|
44
44
|
return getLogger().scope(cb, attributes, options)
|
|
45
45
|
}
|
|
46
46
|
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FingerCrossedLoggerHandlerOptions } from './handlers/FingerCrossedLoggerHandler'
|
|
2
2
|
|
|
3
|
-
export type LogFn = (
|
|
3
|
+
export type LogFn = (errorOrMessage: unknown, attributes?: LoggerAttributes) => void
|
|
4
4
|
|
|
5
5
|
export interface Logger {
|
|
6
6
|
attributes: LoggerAttributes
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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;;"}
|