@pristine-ts/logging 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/cjs/enums/enums.js +1 -0
- package/dist/lib/cjs/enums/enums.js.map +1 -1
- package/dist/lib/cjs/enums/output-mode.enum.js +6 -0
- package/dist/lib/cjs/enums/output-mode.enum.js.map +1 -1
- package/dist/lib/cjs/enums/severity.enum.js +10 -4
- package/dist/lib/cjs/enums/severity.enum.js.map +1 -1
- package/dist/lib/cjs/enums/stream.enum.js +14 -0
- package/dist/lib/cjs/enums/stream.enum.js.map +1 -0
- package/dist/lib/cjs/handlers/log.handler.js +16 -4
- package/dist/lib/cjs/handlers/log.handler.js.map +1 -1
- package/dist/lib/cjs/loggers/base.logger.js +11 -5
- package/dist/lib/cjs/loggers/base.logger.js.map +1 -1
- package/dist/lib/cjs/loggers/console.logger.js +41 -51
- package/dist/lib/cjs/loggers/console.logger.js.map +1 -1
- package/dist/lib/cjs/loggers/loggers.js +0 -1
- package/dist/lib/cjs/loggers/loggers.js.map +1 -1
- package/dist/lib/cjs/logging.configuration-keys.js +8 -4
- package/dist/lib/cjs/logging.configuration-keys.js.map +1 -1
- package/dist/lib/cjs/logging.module.js +64 -16
- package/dist/lib/cjs/logging.module.js.map +1 -1
- package/dist/lib/cjs/models/log.model.js +1 -1
- package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/lib/cjs/utils/pretty-log-formatter.js +80 -0
- package/dist/lib/cjs/utils/pretty-log-formatter.js.map +1 -0
- package/dist/lib/cjs/utils/utils.js +8 -1
- package/dist/lib/cjs/utils/utils.js.map +1 -1
- package/dist/lib/esm/enums/enums.js +1 -0
- package/dist/lib/esm/enums/enums.js.map +1 -1
- package/dist/lib/esm/enums/output-mode.enum.js +6 -0
- package/dist/lib/esm/enums/output-mode.enum.js.map +1 -1
- package/dist/lib/esm/enums/severity.enum.js +10 -4
- package/dist/lib/esm/enums/severity.enum.js.map +1 -1
- package/dist/lib/esm/enums/stream.enum.js +11 -0
- package/dist/lib/esm/enums/stream.enum.js.map +1 -0
- package/dist/lib/esm/handlers/log.handler.js +16 -4
- package/dist/lib/esm/handlers/log.handler.js.map +1 -1
- package/dist/lib/esm/loggers/base.logger.js +11 -5
- package/dist/lib/esm/loggers/base.logger.js.map +1 -1
- package/dist/lib/esm/loggers/console.logger.js +41 -51
- package/dist/lib/esm/loggers/console.logger.js.map +1 -1
- package/dist/lib/esm/loggers/loggers.js +0 -1
- package/dist/lib/esm/loggers/loggers.js.map +1 -1
- package/dist/lib/esm/logging.configuration-keys.js +8 -4
- package/dist/lib/esm/logging.configuration-keys.js.map +1 -1
- package/dist/lib/esm/logging.module.js +64 -16
- package/dist/lib/esm/logging.module.js.map +1 -1
- package/dist/lib/esm/models/log.model.js +1 -1
- package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/lib/esm/utils/pretty-log-formatter.js +73 -0
- package/dist/lib/esm/utils/pretty-log-formatter.js.map +1 -0
- package/dist/lib/esm/utils/utils.js +6 -0
- package/dist/lib/esm/utils/utils.js.map +1 -1
- package/dist/types/enums/enums.d.ts +1 -0
- package/dist/types/enums/output-mode.enum.d.ts +7 -1
- package/dist/types/enums/severity.enum.d.ts +10 -4
- package/dist/types/enums/stream.enum.d.ts +9 -0
- package/dist/types/handlers/log.handler.d.ts +8 -1
- package/dist/types/interfaces/log-handler.interface.d.ts +8 -0
- package/dist/types/loggers/base.logger.d.ts +2 -1
- package/dist/types/loggers/console.logger.d.ts +13 -21
- package/dist/types/loggers/loggers.d.ts +0 -1
- package/dist/types/logging.configuration-keys.d.ts +17 -8
- package/dist/types/models/log.model.d.ts +1 -1
- package/dist/types/utils/pretty-log-formatter.d.ts +22 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/package.json +4 -4
- package/dist/lib/cjs/loggers/file.logger.js +0 -127
- package/dist/lib/cjs/loggers/file.logger.js.map +0 -1
- package/dist/lib/esm/loggers/file.logger.js +0 -121
- package/dist/lib/esm/loggers/file.logger.js.map +0 -1
- package/dist/types/loggers/file.logger.d.ts +0 -60
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,KAAK;IAIhB;;;OAGG;IACI,MAAM,CAAC,SAAS,CAAC,GAAQ;QAC9B,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,GAAQ;QAC3B,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACzE,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,WAAW,CAAC,GAAQ;QAChC,IAAI,OAAiB,CAAC;QACtB,IAAI,IAAI,GAAa,EAAE,CAAC;QACxB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;gBAClB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBACd,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;aACjB,CAAC;YAEF,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAExC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,WAAW,CAAC,cAAc,KAAK,SAAS,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClF,WAAW,CAAC,cAAc,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;;AA5LM,eAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -9,5 +9,11 @@ export declare enum OutputModeEnum {
|
|
|
9
9
|
/**
|
|
10
10
|
* The logs will output a simple string format.
|
|
11
11
|
*/
|
|
12
|
-
Simple = "SIMPLE"
|
|
12
|
+
Simple = "SIMPLE",
|
|
13
|
+
/**
|
|
14
|
+
* The logs will output a colored, icon-prefixed single-line format intended for
|
|
15
|
+
* interactive terminals. Renders the message, severity badge, and `highlights` only;
|
|
16
|
+
* `extra` is omitted (still preserved in the LogModel for JSON/file/Sentry transports).
|
|
17
|
+
*/
|
|
18
|
+
Pretty = "PRETTY"
|
|
13
19
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The severity supported for logging purposes.
|
|
3
|
+
*
|
|
4
|
+
* Ranks are ordered low → high so consumers can gate by `severity >= threshold`. `Success`
|
|
5
|
+
* slots between `Info` and `Notice`: it's a positive event that should be visible at the
|
|
6
|
+
* default `Info` threshold but hidden when the operator only wants to see problems
|
|
7
|
+
* (threshold ≥ `Warning`).
|
|
3
8
|
*/
|
|
4
9
|
export declare enum SeverityEnum {
|
|
5
|
-
Critical =
|
|
6
|
-
Error =
|
|
7
|
-
Warning =
|
|
8
|
-
Notice =
|
|
10
|
+
Critical = 6,
|
|
11
|
+
Error = 5,
|
|
12
|
+
Warning = 4,
|
|
13
|
+
Notice = 3,
|
|
14
|
+
Success = 2,
|
|
9
15
|
Info = 1,
|
|
10
16
|
Debug = 0
|
|
11
17
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which standard stream a logger should write to for a given severity. Used by the
|
|
3
|
+
* ConsoleLogger to pick between `process.stdout` and `process.stderr` per-severity via
|
|
4
|
+
* configuration.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum StreamEnum {
|
|
7
|
+
Stdout = "stdout",
|
|
8
|
+
Stderr = "stderr"
|
|
9
|
+
}
|
|
@@ -7,7 +7,7 @@ import { LogData } from "../types/log-data.type";
|
|
|
7
7
|
* The LogHandler emits structured log entries through every registered `LoggerInterface`.
|
|
8
8
|
* Logs carry their own content (message, severity, eventId, traceId, extra, highlights) —
|
|
9
9
|
* nothing more. "What happened around this log" lives in the trace, not the log: use the
|
|
10
|
-
* registered tracers (ConsoleTracer,
|
|
10
|
+
* registered tracers (ConsoleTracer, the observability tracer, X-Ray, etc.) to render the span tree.
|
|
11
11
|
*/
|
|
12
12
|
export declare class LogHandler implements LogHandlerInterface {
|
|
13
13
|
private readonly loggers;
|
|
@@ -58,6 +58,13 @@ export declare class LogHandler implements LogHandlerInterface {
|
|
|
58
58
|
* @param data The data being passed to the log
|
|
59
59
|
*/
|
|
60
60
|
info(message: string, data?: LogData): void;
|
|
61
|
+
/**
|
|
62
|
+
* Logs the message at Success severity (rank 2). Visible at the default Info threshold,
|
|
63
|
+
* hidden when the threshold is set to Warning or above. Use for positive completion events.
|
|
64
|
+
* @param message The message to log.
|
|
65
|
+
* @param data The data being passed to the log
|
|
66
|
+
*/
|
|
67
|
+
success(message: string, data?: LogData): void;
|
|
61
68
|
/**
|
|
62
69
|
* Logs the message if the severity is set to debug or above.
|
|
63
70
|
* @param message The message to log.
|
|
@@ -34,6 +34,14 @@ export interface LogHandlerInterface {
|
|
|
34
34
|
* @param data The data being passed to the log
|
|
35
35
|
*/
|
|
36
36
|
info(message: string, data?: LogData): void;
|
|
37
|
+
/**
|
|
38
|
+
* Logs the message at Success severity (rank 2, between Info and Notice). Visible at
|
|
39
|
+
* the default Info threshold; hidden when the threshold is set to Warning or above.
|
|
40
|
+
* Use for positive completion events (build complete, server started, sync finished).
|
|
41
|
+
* @param message The message to log.
|
|
42
|
+
* @param data The data being passed to the log
|
|
43
|
+
*/
|
|
44
|
+
success(message: string, data?: LogData): void;
|
|
37
45
|
/**
|
|
38
46
|
* Logs the message if the severity is set to debug or above.
|
|
39
47
|
* @param message The message to log.
|
|
@@ -11,6 +11,7 @@ export declare abstract class BaseLogger {
|
|
|
11
11
|
protected readonly logSeverityLevelConfiguration: number;
|
|
12
12
|
protected readonly logDebugDepthConfiguration: number;
|
|
13
13
|
protected readonly logInfoDepthConfiguration: number;
|
|
14
|
+
protected readonly logSuccessDepthConfiguration: number;
|
|
14
15
|
protected readonly logNoticeDepthConfiguration: number;
|
|
15
16
|
protected readonly logWarningDepthConfiguration: number;
|
|
16
17
|
protected readonly logErrorDepthConfiguration: number;
|
|
@@ -45,7 +46,7 @@ export declare abstract class BaseLogger {
|
|
|
45
46
|
* @param outputMode The output mode, that the logger should use.
|
|
46
47
|
* @param spaces The number of spaces to indent the outputted logs.
|
|
47
48
|
*/
|
|
48
|
-
constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logNoticeDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated?: boolean, outputMode?: OutputModeEnum, spaces?: number);
|
|
49
|
+
constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logSuccessDepthConfiguration: number, logNoticeDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated?: boolean, outputMode?: OutputModeEnum, spaces?: number);
|
|
49
50
|
/**
|
|
50
51
|
* Returns whether this particular logger is active and should output logs.
|
|
51
52
|
*/
|
|
@@ -2,9 +2,18 @@ import { LogModel } from "../models/log.model";
|
|
|
2
2
|
import { LoggerInterface } from "../interfaces/logger.interface";
|
|
3
3
|
import { Readable } from "stream";
|
|
4
4
|
import { OutputModeEnum } from "../enums/output-mode.enum";
|
|
5
|
+
import { StreamEnum } from "../enums/stream.enum";
|
|
5
6
|
import { BaseLogger } from "./base.logger";
|
|
6
7
|
/**
|
|
7
|
-
* The ConsoleLogger outputs the logs
|
|
8
|
+
* The ConsoleLogger outputs the logs to `process.stdout` / `process.stderr`. Each severity
|
|
9
|
+
* routes to its configured stream via the per-severity `ConsoleLogger<Sev>Stream` keys, so
|
|
10
|
+
* CLI tools can keep stdout clean for piped output while sending problems to stderr.
|
|
11
|
+
*
|
|
12
|
+
* Writes go through `process.{stdout,stderr}.write` directly rather than `console.*` so the
|
|
13
|
+
* stream choice is explicit, configurable, and not subject to whatever the host runtime
|
|
14
|
+
* does with `console.log` (which can be redirected, suppressed, or swallowed in serverless
|
|
15
|
+
* environments).
|
|
16
|
+
*
|
|
8
17
|
* It is registered with the tag Logger so that it can be injected along with all the other Loggers.
|
|
9
18
|
* It is module scoped to the logging module so that it is only registered if the logging module is imported.
|
|
10
19
|
*/
|
|
@@ -17,28 +26,11 @@ export declare class ConsoleLogger extends BaseLogger implements LoggerInterface
|
|
|
17
26
|
private currentSecond;
|
|
18
27
|
private numberOfLogsInThisSecond;
|
|
19
28
|
private currentlyThrottlingLogs;
|
|
29
|
+
private readonly streams;
|
|
20
30
|
/**
|
|
21
31
|
* The ConsoleLogger outputs the logs in the console.
|
|
22
|
-
* @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
|
|
23
|
-
* @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
|
|
24
|
-
* For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
|
|
25
|
-
* @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
|
|
26
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
27
|
-
* @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
|
|
28
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
29
|
-
* @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning severity.
|
|
30
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
31
|
-
* @param logNoticeDepthConfiguration The number of level to go down in an object when printing a log with the Notice severity.
|
|
32
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
33
|
-
* @param logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error severity.
|
|
34
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
35
|
-
* @param logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
|
|
36
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
37
|
-
* @param isActivated Whether or not this particular logger is activated and should output logs.
|
|
38
|
-
* @param outputMode The output mode, that the logger should use.
|
|
39
|
-
* @param maximumLogsPerSecond The maximum numner of logs per second that can be outputted
|
|
40
32
|
*/
|
|
41
|
-
constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logNoticeDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated: boolean, outputMode: OutputModeEnum, maximumLogsPerSecond: number);
|
|
33
|
+
constructor(numberOfStackedLogs: number, logSeverityLevelConfiguration: number, logDebugDepthConfiguration: number, logInfoDepthConfiguration: number, logSuccessDepthConfiguration: number, logNoticeDepthConfiguration: number, logWarningDepthConfiguration: number, logErrorDepthConfiguration: number, logCriticalDepthConfiguration: number, isActivated: boolean, outputMode: OutputModeEnum, maximumLogsPerSecond: number, debugStream: StreamEnum, infoStream: StreamEnum, successStream: StreamEnum, noticeStream: StreamEnum, warningStream: StreamEnum, errorStream: StreamEnum, criticalStream: StreamEnum);
|
|
42
34
|
/**
|
|
43
35
|
* This will be called when the logger is to be terminated. It must destroy the readable stream.
|
|
44
36
|
*/
|
|
@@ -49,7 +41,7 @@ export declare class ConsoleLogger extends BaseLogger implements LoggerInterface
|
|
|
49
41
|
*/
|
|
50
42
|
protected initialize(): void;
|
|
51
43
|
/**
|
|
52
|
-
* Outputs the log
|
|
44
|
+
* Outputs the log to the configured stream for its severity.
|
|
53
45
|
* @param log The log to be outputted
|
|
54
46
|
* @protected
|
|
55
47
|
*/
|
|
@@ -14,21 +14,26 @@ export declare const LoggingConfigurationKeys: {
|
|
|
14
14
|
readonly LogSeverityLevelConfiguration: "pristine.logging.logSeverityLevelConfiguration";
|
|
15
15
|
readonly LogDebugDepthConfiguration: "pristine.logging.logDebugDepthConfiguration";
|
|
16
16
|
readonly LogInfoDepthConfiguration: "pristine.logging.logInfoDepthConfiguration";
|
|
17
|
+
readonly LogSuccessDepthConfiguration: "pristine.logging.logSuccessDepthConfiguration";
|
|
17
18
|
readonly LogNoticeDepthConfiguration: "pristine.logging.logNoticeDepthConfiguration";
|
|
18
19
|
readonly LogWarningDepthConfiguration: "pristine.logging.logWarningDepthConfiguration";
|
|
19
20
|
readonly LogErrorDepthConfiguration: "pristine.logging.logErrorDepthConfiguration";
|
|
20
21
|
readonly LogCriticalDepthConfiguration: "pristine.logging.logCriticalDepthConfiguration";
|
|
21
22
|
readonly ConsoleLoggerActivated: "pristine.logging.consoleLoggerActivated";
|
|
22
23
|
readonly ConsoleLoggerOutputMode: "pristine.logging.consoleLoggerOutputMode";
|
|
23
|
-
readonly
|
|
24
|
-
readonly
|
|
25
|
-
readonly
|
|
26
|
-
readonly
|
|
24
|
+
readonly ConsoleLoggerDebugStream: "pristine.logging.consoleLoggerDebugStream";
|
|
25
|
+
readonly ConsoleLoggerInfoStream: "pristine.logging.consoleLoggerInfoStream";
|
|
26
|
+
readonly ConsoleLoggerSuccessStream: "pristine.logging.consoleLoggerSuccessStream";
|
|
27
|
+
readonly ConsoleLoggerNoticeStream: "pristine.logging.consoleLoggerNoticeStream";
|
|
28
|
+
readonly ConsoleLoggerWarningStream: "pristine.logging.consoleLoggerWarningStream";
|
|
29
|
+
readonly ConsoleLoggerErrorStream: "pristine.logging.consoleLoggerErrorStream";
|
|
30
|
+
readonly ConsoleLoggerCriticalStream: "pristine.logging.consoleLoggerCriticalStream";
|
|
27
31
|
readonly ActivateDiagnostics: "pristine.logging.activateDiagnostics";
|
|
28
32
|
readonly MaximumLogsPerSecond: "pristine.logging.maximumLogsPerSecond";
|
|
29
33
|
};
|
|
30
34
|
import { OutputModeEnum } from "./enums/output-mode.enum";
|
|
31
35
|
import { SeverityEnum } from "./enums/severity.enum";
|
|
36
|
+
import { StreamEnum } from "./enums/stream.enum";
|
|
32
37
|
/**
|
|
33
38
|
* The expected runtime types for each configuration value defined by `@pristine-ts/logging`.
|
|
34
39
|
* See `AwsConfigurationValueMap` in `@pristine-ts/aws` for the full pattern + caveats.
|
|
@@ -38,16 +43,20 @@ export interface LoggingConfigurationValueMap {
|
|
|
38
43
|
"pristine.logging.logSeverityLevelConfiguration": SeverityEnum;
|
|
39
44
|
"pristine.logging.logDebugDepthConfiguration": number;
|
|
40
45
|
"pristine.logging.logInfoDepthConfiguration": number;
|
|
46
|
+
"pristine.logging.logSuccessDepthConfiguration": number;
|
|
41
47
|
"pristine.logging.logNoticeDepthConfiguration": number;
|
|
42
48
|
"pristine.logging.logWarningDepthConfiguration": number;
|
|
43
49
|
"pristine.logging.logErrorDepthConfiguration": number;
|
|
44
50
|
"pristine.logging.logCriticalDepthConfiguration": number;
|
|
45
51
|
"pristine.logging.consoleLoggerActivated": boolean;
|
|
46
52
|
"pristine.logging.consoleLoggerOutputMode": OutputModeEnum;
|
|
47
|
-
"pristine.logging.
|
|
48
|
-
"pristine.logging.
|
|
49
|
-
"pristine.logging.
|
|
50
|
-
"pristine.logging.
|
|
53
|
+
"pristine.logging.consoleLoggerDebugStream": StreamEnum;
|
|
54
|
+
"pristine.logging.consoleLoggerInfoStream": StreamEnum;
|
|
55
|
+
"pristine.logging.consoleLoggerSuccessStream": StreamEnum;
|
|
56
|
+
"pristine.logging.consoleLoggerNoticeStream": StreamEnum;
|
|
57
|
+
"pristine.logging.consoleLoggerWarningStream": StreamEnum;
|
|
58
|
+
"pristine.logging.consoleLoggerErrorStream": StreamEnum;
|
|
59
|
+
"pristine.logging.consoleLoggerCriticalStream": StreamEnum;
|
|
51
60
|
"pristine.logging.activateDiagnostics": boolean;
|
|
52
61
|
"pristine.logging.maximumLogsPerSecond": number;
|
|
53
62
|
}
|
|
@@ -6,7 +6,7 @@ import { OutputHints } from "../types/output-hints.type";
|
|
|
6
6
|
*
|
|
7
7
|
* Logs carry their own content only — no inline breadcrumb trail. To reconstruct "what
|
|
8
8
|
* happened" around a log entry, look at the trace via the registered tracers
|
|
9
|
-
* (ConsoleTracer,
|
|
9
|
+
* (ConsoleTracer, the observability tracer, X-Ray, etc.) using the `traceId`/`eventId` on the log.
|
|
10
10
|
*/
|
|
11
11
|
export declare class LogModel {
|
|
12
12
|
severity: SeverityEnum;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LogModel } from "../models/log.model";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a `LogModel` as a colored, icon-prefixed single line for interactive terminals.
|
|
4
|
+
*
|
|
5
|
+
* Pretty mode is deliberately compact: severity badge + message + optional indented
|
|
6
|
+
* highlights. The `extra` payload is intentionally not rendered here — it remains on the
|
|
7
|
+
* `LogModel` for JSON/file/Sentry transports, where machine-readable depth matters more
|
|
8
|
+
* than terminal readability.
|
|
9
|
+
*
|
|
10
|
+
* This formatter lives in `@pristine-ts/logging` (not `@pristine-ts/cli`) because the
|
|
11
|
+
* ConsoleLogger that consumes it lives here, and a one-way dependency from logging → cli
|
|
12
|
+
* would invert the module hierarchy.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PrettyLogFormatter {
|
|
15
|
+
/**
|
|
16
|
+
* Renders the log entry. Static because it has no per-instance state and we want
|
|
17
|
+
* callers to invoke it as `PrettyLogFormatter.format(log)` without managing a lifecycle.
|
|
18
|
+
*/
|
|
19
|
+
static format(log: LogModel): string;
|
|
20
|
+
private static iconAndColor;
|
|
21
|
+
private static renderHighlights;
|
|
22
|
+
}
|
|
@@ -2,6 +2,7 @@ import { LogModel } from "../models/log.model";
|
|
|
2
2
|
import { OutputModeEnum } from "../enums/output-mode.enum";
|
|
3
3
|
import { SeverityEnum } from "../enums/severity.enum";
|
|
4
4
|
import { DiagnosticsModel } from "../models/diagnostics.model";
|
|
5
|
+
export { PrettyLogFormatter } from "./pretty-log-formatter";
|
|
5
6
|
/**
|
|
6
7
|
* This class provides some utility functions to help with the logging.
|
|
7
8
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/logging",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/logging.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/logging.module.js",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"test:cov": "jest --coverage"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@pristine-ts/common": "^2.0.
|
|
16
|
-
"@pristine-ts/configuration": "^2.0.
|
|
15
|
+
"@pristine-ts/common": "^2.0.8",
|
|
16
|
+
"@pristine-ts/configuration": "^2.0.8",
|
|
17
17
|
"date-fns": "^2.30.0"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"src/*.{js,ts}"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "c760fc252d427fec8d98dfadf06e36db232bc8c9",
|
|
62
62
|
"repository": {
|
|
63
63
|
"type": "git",
|
|
64
64
|
"url": "https://github.com/magieno/pristine-ts.git",
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.FileLogger = void 0;
|
|
19
|
-
const tsyringe_1 = require("tsyringe");
|
|
20
|
-
const logging_configuration_keys_1 = require("../logging.configuration-keys");
|
|
21
|
-
const severity_enum_1 = require("../enums/severity.enum");
|
|
22
|
-
const common_1 = require("@pristine-ts/common");
|
|
23
|
-
const fs_1 = __importDefault(require("fs"));
|
|
24
|
-
const logging_module_keyname_1 = require("../logging.module.keyname");
|
|
25
|
-
const output_mode_enum_1 = require("../enums/output-mode.enum");
|
|
26
|
-
const base_logger_1 = require("./base.logger");
|
|
27
|
-
/**
|
|
28
|
-
* The FileLogger outputs the logs into file.
|
|
29
|
-
* It is registered with the tag Logger so that it can be injected along with all the other Loggers.
|
|
30
|
-
* It is module scoped to the logging module so that it is only registered if the logging module is imported.
|
|
31
|
-
*/
|
|
32
|
-
let FileLogger = class FileLogger extends base_logger_1.BaseLogger {
|
|
33
|
-
/**
|
|
34
|
-
* The ConsoleLogger outputs the logs in the console.
|
|
35
|
-
* @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
|
|
36
|
-
* @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
|
|
37
|
-
* For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
|
|
38
|
-
* @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
|
|
39
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
40
|
-
* @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
|
|
41
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
42
|
-
* @param logNoticeDepthConfiguration The number of level to go down in an object when printing a log with the Notice severity.
|
|
43
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
44
|
-
* @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning severity.
|
|
45
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
46
|
-
* @param logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error severity.
|
|
47
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
48
|
-
* @param logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
|
|
49
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
50
|
-
* @param isActivated Whether or not this particular logger is activated and should output logs.
|
|
51
|
-
* @param outputMode The output mode, that the logger should use.
|
|
52
|
-
* @param fileLoggerPretty Whether or not the file logger should prettify the output.
|
|
53
|
-
* @param filePath The file path where to output the log.
|
|
54
|
-
*/
|
|
55
|
-
constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logNoticeDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode, fileLoggerPretty, filePath) {
|
|
56
|
-
super(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logNoticeDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode, fileLoggerPretty ? 2 : 0);
|
|
57
|
-
this.filePath = filePath;
|
|
58
|
-
this.initialize();
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* This will be called when the logger is to be terminated. It must destroy the readable stream.
|
|
62
|
-
*/
|
|
63
|
-
terminate() {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
(_a = this.readableStream) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
66
|
-
(_b = this.writableStream) === null || _b === void 0 ? void 0 : _b.end();
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Initializes the file logger, and opens the write stream.
|
|
70
|
-
* @protected
|
|
71
|
-
*/
|
|
72
|
-
initialize() {
|
|
73
|
-
if (this.isActive()) {
|
|
74
|
-
this.readableStream = this.createSafeReadableStream();
|
|
75
|
-
this.writableStream = fs_1.default.createWriteStream(this.filePath);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Outputs the log in the file.
|
|
80
|
-
* @param log The log to be outputted
|
|
81
|
-
* @protected
|
|
82
|
-
*/
|
|
83
|
-
log(log) {
|
|
84
|
-
if (this.writableStream === undefined) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const outputLog = this.getFormattedOutputLog(log) + ";\n";
|
|
88
|
-
switch (log.severity) {
|
|
89
|
-
case severity_enum_1.SeverityEnum.Debug:
|
|
90
|
-
this.writableStream.write(outputLog);
|
|
91
|
-
break;
|
|
92
|
-
case severity_enum_1.SeverityEnum.Info:
|
|
93
|
-
this.writableStream.write(outputLog);
|
|
94
|
-
break;
|
|
95
|
-
case severity_enum_1.SeverityEnum.Warning:
|
|
96
|
-
this.writableStream.write(outputLog);
|
|
97
|
-
break;
|
|
98
|
-
case severity_enum_1.SeverityEnum.Error:
|
|
99
|
-
this.writableStream.write(outputLog);
|
|
100
|
-
break;
|
|
101
|
-
case severity_enum_1.SeverityEnum.Critical:
|
|
102
|
-
this.writableStream.write(outputLog);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
exports.FileLogger = FileLogger;
|
|
108
|
-
exports.FileLogger = FileLogger = __decorate([
|
|
109
|
-
(0, common_1.moduleScoped)(logging_module_keyname_1.LoggingModuleKeyname),
|
|
110
|
-
(0, tsyringe_1.singleton)(),
|
|
111
|
-
(0, common_1.tag)(common_1.ServiceDefinitionTagEnum.Logger),
|
|
112
|
-
(0, tsyringe_1.injectable)(),
|
|
113
|
-
__param(0, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.NumberOfStackedLogs)),
|
|
114
|
-
__param(1, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogSeverityLevelConfiguration)),
|
|
115
|
-
__param(2, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogDebugDepthConfiguration)),
|
|
116
|
-
__param(3, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogInfoDepthConfiguration)),
|
|
117
|
-
__param(4, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogNoticeDepthConfiguration)),
|
|
118
|
-
__param(5, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogWarningDepthConfiguration)),
|
|
119
|
-
__param(6, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogErrorDepthConfiguration)),
|
|
120
|
-
__param(7, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.LogCriticalDepthConfiguration)),
|
|
121
|
-
__param(8, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.FileLoggerActivated)),
|
|
122
|
-
__param(9, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.FileLoggerOutputMode)),
|
|
123
|
-
__param(10, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.FileLoggerPretty)),
|
|
124
|
-
__param(11, (0, common_1.injectConfig)(logging_configuration_keys_1.LoggingConfigurationKeys.FilePath)),
|
|
125
|
-
__metadata("design:paramtypes", [Number, Number, Number, Number, Number, Number, Number, Number, Boolean, String, Boolean, String])
|
|
126
|
-
], FileLogger);
|
|
127
|
-
//# sourceMappingURL=file.logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.logger.js","sourceRoot":"","sources":["../../../../src/loggers/file.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AACvD,8EAAuE;AACvE,0DAAoD;AAIpD,gDAA8F;AAC9F,4CAAoB;AACpB,sEAA+D;AAC/D,gEAAyD;AACzD,+CAAyC;AAEzC;;;;GAIG;AAKI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,wBAAU;IAaxC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAA+E,mBAA2B,EACjB,6BAAqC,EACxC,0BAAkC,EACnC,yBAAiC,EAC/B,2BAAmC,EAClC,4BAAoC,EACtC,0BAAkC,EAC/B,6BAAqC,EAC/C,WAAoB,EACnB,UAA0B,EAC9B,gBAAyB,EAChB,QAAgB;QAEnG,KAAK,CAAC,mBAAmB,EACvB,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,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.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
-
};
|
|
13
|
-
import { injectable, singleton } from "tsyringe";
|
|
14
|
-
import { LoggingConfigurationKeys } from "../logging.configuration-keys";
|
|
15
|
-
import { SeverityEnum } from "../enums/severity.enum";
|
|
16
|
-
import { injectConfig, moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
|
|
17
|
-
import fs from 'fs';
|
|
18
|
-
import { LoggingModuleKeyname } from "../logging.module.keyname";
|
|
19
|
-
import { OutputModeEnum } from "../enums/output-mode.enum";
|
|
20
|
-
import { BaseLogger } from "./base.logger";
|
|
21
|
-
/**
|
|
22
|
-
* The FileLogger outputs the logs into file.
|
|
23
|
-
* It is registered with the tag Logger so that it can be injected along with all the other Loggers.
|
|
24
|
-
* It is module scoped to the logging module so that it is only registered if the logging module is imported.
|
|
25
|
-
*/
|
|
26
|
-
let FileLogger = class FileLogger extends BaseLogger {
|
|
27
|
-
/**
|
|
28
|
-
* The ConsoleLogger outputs the logs in the console.
|
|
29
|
-
* @param numberOfStackedLogs The number of logs to keep in the stack and to print once a log with a high enough severity arrives.
|
|
30
|
-
* @param logSeverityLevelConfiguration The number representing the severity from which logs should be outputted.
|
|
31
|
-
* For example, if this is set to 3, any log that has a severity of Error(3) or critical(4) will be outputted.
|
|
32
|
-
* @param logDebugDepthConfiguration The number of level to go down in an object when printing a log with the Debug severity.
|
|
33
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
34
|
-
* @param logInfoDepthConfiguration The number of level to go down in an object when printing a log with the Info severity.
|
|
35
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
36
|
-
* @param logNoticeDepthConfiguration The number of level to go down in an object when printing a log with the Notice severity.
|
|
37
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
38
|
-
* @param logWarningDepthConfiguration The number of level to go down in an object when printing a log with the Warning severity.
|
|
39
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
40
|
-
* @param logErrorDepthConfiguration The number of level to go down in an object when printing a log with the Error severity.
|
|
41
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
42
|
-
* @param logCriticalDepthConfiguration The number of level to go down in an object when printing a log with the Critical severity.
|
|
43
|
-
* We often do not need to go to the bottom layer of an object, so we can truncate at a certain depth.
|
|
44
|
-
* @param isActivated Whether or not this particular logger is activated and should output logs.
|
|
45
|
-
* @param outputMode The output mode, that the logger should use.
|
|
46
|
-
* @param fileLoggerPretty Whether or not the file logger should prettify the output.
|
|
47
|
-
* @param filePath The file path where to output the log.
|
|
48
|
-
*/
|
|
49
|
-
constructor(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logNoticeDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode, fileLoggerPretty, filePath) {
|
|
50
|
-
super(numberOfStackedLogs, logSeverityLevelConfiguration, logDebugDepthConfiguration, logInfoDepthConfiguration, logNoticeDepthConfiguration, logWarningDepthConfiguration, logErrorDepthConfiguration, logCriticalDepthConfiguration, isActivated, outputMode, fileLoggerPretty ? 2 : 0);
|
|
51
|
-
this.filePath = filePath;
|
|
52
|
-
this.initialize();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* This will be called when the logger is to be terminated. It must destroy the readable stream.
|
|
56
|
-
*/
|
|
57
|
-
terminate() {
|
|
58
|
-
var _a, _b;
|
|
59
|
-
(_a = this.readableStream) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
60
|
-
(_b = this.writableStream) === null || _b === void 0 ? void 0 : _b.end();
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Initializes the file logger, and opens the write stream.
|
|
64
|
-
* @protected
|
|
65
|
-
*/
|
|
66
|
-
initialize() {
|
|
67
|
-
if (this.isActive()) {
|
|
68
|
-
this.readableStream = this.createSafeReadableStream();
|
|
69
|
-
this.writableStream = fs.createWriteStream(this.filePath);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Outputs the log in the file.
|
|
74
|
-
* @param log The log to be outputted
|
|
75
|
-
* @protected
|
|
76
|
-
*/
|
|
77
|
-
log(log) {
|
|
78
|
-
if (this.writableStream === undefined) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const outputLog = this.getFormattedOutputLog(log) + ";\n";
|
|
82
|
-
switch (log.severity) {
|
|
83
|
-
case SeverityEnum.Debug:
|
|
84
|
-
this.writableStream.write(outputLog);
|
|
85
|
-
break;
|
|
86
|
-
case SeverityEnum.Info:
|
|
87
|
-
this.writableStream.write(outputLog);
|
|
88
|
-
break;
|
|
89
|
-
case SeverityEnum.Warning:
|
|
90
|
-
this.writableStream.write(outputLog);
|
|
91
|
-
break;
|
|
92
|
-
case SeverityEnum.Error:
|
|
93
|
-
this.writableStream.write(outputLog);
|
|
94
|
-
break;
|
|
95
|
-
case SeverityEnum.Critical:
|
|
96
|
-
this.writableStream.write(outputLog);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
FileLogger = __decorate([
|
|
102
|
-
moduleScoped(LoggingModuleKeyname),
|
|
103
|
-
singleton(),
|
|
104
|
-
tag(ServiceDefinitionTagEnum.Logger),
|
|
105
|
-
injectable(),
|
|
106
|
-
__param(0, injectConfig(LoggingConfigurationKeys.NumberOfStackedLogs)),
|
|
107
|
-
__param(1, injectConfig(LoggingConfigurationKeys.LogSeverityLevelConfiguration)),
|
|
108
|
-
__param(2, injectConfig(LoggingConfigurationKeys.LogDebugDepthConfiguration)),
|
|
109
|
-
__param(3, injectConfig(LoggingConfigurationKeys.LogInfoDepthConfiguration)),
|
|
110
|
-
__param(4, injectConfig(LoggingConfigurationKeys.LogNoticeDepthConfiguration)),
|
|
111
|
-
__param(5, injectConfig(LoggingConfigurationKeys.LogWarningDepthConfiguration)),
|
|
112
|
-
__param(6, injectConfig(LoggingConfigurationKeys.LogErrorDepthConfiguration)),
|
|
113
|
-
__param(7, injectConfig(LoggingConfigurationKeys.LogCriticalDepthConfiguration)),
|
|
114
|
-
__param(8, injectConfig(LoggingConfigurationKeys.FileLoggerActivated)),
|
|
115
|
-
__param(9, injectConfig(LoggingConfigurationKeys.FileLoggerOutputMode)),
|
|
116
|
-
__param(10, injectConfig(LoggingConfigurationKeys.FileLoggerPretty)),
|
|
117
|
-
__param(11, injectConfig(LoggingConfigurationKeys.FilePath)),
|
|
118
|
-
__metadata("design:paramtypes", [Number, Number, Number, Number, Number, Number, Number, Number, Boolean, String, Boolean, String])
|
|
119
|
-
], FileLogger);
|
|
120
|
-
export { FileLogger };
|
|
121
|
-
//# sourceMappingURL=file.logger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.logger.js","sourceRoot":"","sources":["../../../../src/loggers/file.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAS,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AACvD,OAAO,EAAC,wBAAwB,EAAC,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