@hg-ts/logger 0.3.4 → 0.4.1
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/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/logger/base.formatter.d.ts +1 -1
- package/dist/logger/base.formatter.d.ts.map +1 -1
- package/dist/logger/base.formatter.js +7 -12
- package/dist/logger/base.formatter.js.map +1 -1
- package/dist/logger/base.logger.d.ts +2 -2
- package/dist/logger/base.logger.d.ts.map +1 -1
- package/dist/logger/base.logger.js +9 -14
- package/dist/logger/base.logger.js.map +1 -1
- package/dist/logger/colors.js +3 -7
- package/dist/logger/colors.js.map +1 -1
- package/dist/logger/console.logger.d.ts +3 -3
- package/dist/logger/console.logger.d.ts.map +1 -1
- package/dist/logger/console.logger.js +24 -29
- package/dist/logger/console.logger.js.map +1 -1
- package/dist/logger/index.d.ts +4 -4
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +4 -11
- package/dist/logger/index.js.map +1 -1
- package/dist/logger/json.logger.d.ts +2 -2
- package/dist/logger/json.logger.d.ts.map +1 -1
- package/dist/logger/json.logger.js +6 -11
- package/dist/logger/json.logger.js.map +1 -1
- package/dist/logger/logger.js +1 -5
- package/dist/logger/logger.js.map +1 -1
- package/dist/logger/mock.logger.d.ts +1 -1
- package/dist/logger/mock.logger.d.ts.map +1 -1
- package/dist/logger/mock.logger.js +2 -6
- package/dist/logger/mock.logger.js.map +1 -1
- package/dist/logger.module.js +23 -26
- package/dist/logger.module.js.map +1 -1
- package/dist/nest-wrapped.logger.d.ts +1 -1
- package/dist/nest-wrapped.logger.d.ts.map +1 -1
- package/dist/nest-wrapped.logger.js +11 -15
- package/dist/nest-wrapped.logger.js.map +1 -1
- package/dist/trace.context.js +2 -6
- package/dist/trace.context.js.map +1 -1
- package/package.json +7 -6
- package/tsconfig.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Logger, ConsoleLogger, JSONLogger, MockLogger, } from './logger';
|
|
2
|
-
export * from './logger.module';
|
|
3
|
-
export * from './trace.context';
|
|
1
|
+
export { Logger, ConsoleLogger, JSONLogger, MockLogger, } from './logger/index.js';
|
|
2
|
+
export * from './logger.module.js';
|
|
3
|
+
export * from './trace.context.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,aAAa,EACb,UAAU,EACV,UAAU,GACV,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,aAAa,EACb,UAAU,EACV,UAAU,GACV,MAAM,mBAAmB,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
var logger_1 = require("./logger");
|
|
6
|
-
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
7
|
-
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return logger_1.ConsoleLogger; } });
|
|
8
|
-
Object.defineProperty(exports, "JSONLogger", { enumerable: true, get: function () { return logger_1.JSONLogger; } });
|
|
9
|
-
Object.defineProperty(exports, "MockLogger", { enumerable: true, get: function () { return logger_1.MockLogger; } });
|
|
10
|
-
tslib_1.__exportStar(require("./logger.module"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./trace.context"), exports);
|
|
1
|
+
export { Logger, ConsoleLogger, JSONLogger, MockLogger, } from './logger/index.js';
|
|
2
|
+
export * from './logger.module.js';
|
|
3
|
+
export * from './trace.context.js';
|
|
12
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,MAAM,EACN,aAAa,EACb,UAAU,EACV,UAAU,GACV,MAAM,mBAAmB,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.formatter.d.ts","sourceRoot":"","sources":["../../src/logger/base.formatter.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACN,QAAQ,EAER,MAAM,
|
|
1
|
+
{"version":3,"file":"base.formatter.d.ts","sourceRoot":"","sources":["../../src/logger/base.formatter.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACN,QAAQ,EAER,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,GAAG;IAC5D,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;KACxB,CAAC;IACF,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,OAAO,EAAE,CAAC;CACjB,CAAC;AAqBF,eAAO,MAAM,aAAa,4BAoBxB,CAAC;AAEH,wBAAgB,eAAe,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAEvG"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.createFormatter = createFormatter;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const assert = tslib_1.__importStar(require("node:assert"));
|
|
7
|
-
const winston_1 = tslib_1.__importDefault(require("winston"));
|
|
8
|
-
const base_logger_1 = require("./base.logger");
|
|
1
|
+
import * as assert from 'node:assert';
|
|
2
|
+
import winston from 'winston';
|
|
3
|
+
import { syslogToLoggerMap, } from './base.logger.js';
|
|
9
4
|
function getLogData(info) {
|
|
10
|
-
const level =
|
|
5
|
+
const level = syslogToLoggerMap.get(info.level) ?? info.level;
|
|
11
6
|
const context = info['context'] ?? null;
|
|
12
7
|
assert.ok(typeof context === 'string' || context === null);
|
|
13
8
|
return {
|
|
@@ -22,7 +17,7 @@ function getLogData(info) {
|
|
|
22
17
|
timestamp: new Date(),
|
|
23
18
|
};
|
|
24
19
|
}
|
|
25
|
-
|
|
20
|
+
export const baseFormatter = winston.format(info => {
|
|
26
21
|
const logData = getLogData(info);
|
|
27
22
|
logData['items'] = logData.items
|
|
28
23
|
.map(item => {
|
|
@@ -40,7 +35,7 @@ exports.baseFormatter = winston_1.default.format(info => {
|
|
|
40
35
|
});
|
|
41
36
|
return logData;
|
|
42
37
|
});
|
|
43
|
-
function createFormatter(formatter) {
|
|
44
|
-
return
|
|
38
|
+
export function createFormatter(formatter) {
|
|
39
|
+
return winston.format(formatter);
|
|
45
40
|
}
|
|
46
41
|
//# sourceMappingURL=base.formatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.formatter.js","sourceRoot":"","sources":["../../src/logger/base.formatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.formatter.js","sourceRoot":"","sources":["../../src/logger/base.formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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AAI,YAAY,KAAK,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,CAAC;YAClD,OAAO;gBACN,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;aACjB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;IACJ,OAAO,OAAO,CAAC;AAChB,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,eAAe,CAAC,SAA2C;IAC1E,OAAO,OAAO,CAAC,MAAM,CAAC,SAAgB,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
|
-
import { TraceContext } from '../trace.context';
|
|
3
|
-
import { Logger } from './logger';
|
|
2
|
+
import { TraceContext } from '../trace.context.js';
|
|
3
|
+
import { Logger } from './logger.js';
|
|
4
4
|
type Transport = winston.Logger['add'] extends (transport: infer R) => void ? R : never;
|
|
5
5
|
export type LogLevel = keyof Omit<Logger, 'setContext'>;
|
|
6
6
|
export declare const syslogToLoggerMap: Map<string, "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.logger.d.ts","sourceRoot":"","sources":["../../src/logger/base.logger.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"base.logger.d.ts","sourceRoot":"","sources":["../../src/logger/base.logger.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,KAAK,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAA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|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const node_util_1 = require("node:util");
|
|
6
|
-
const winston_1 = tslib_1.__importDefault(require("winston"));
|
|
7
|
-
exports.syslogToLoggerMap = new Map()
|
|
1
|
+
import { format } from 'node:util';
|
|
2
|
+
import winston from 'winston';
|
|
3
|
+
export const syslogToLoggerMap = new Map()
|
|
8
4
|
.set('emerg', 'emergency')
|
|
9
5
|
.set('crit', 'critical');
|
|
10
|
-
|
|
6
|
+
export const loggerToSyslogMap = new Map()
|
|
11
7
|
.set('emergency', 'emerg')
|
|
12
8
|
.set('critical', 'crit');
|
|
13
|
-
class BaseLogger {
|
|
9
|
+
export class BaseLogger {
|
|
14
10
|
context = null;
|
|
15
11
|
logger;
|
|
16
12
|
traceContext;
|
|
17
13
|
constructor(logLevel, context, traceContext) {
|
|
18
14
|
this.context = context;
|
|
19
15
|
this.traceContext = traceContext;
|
|
20
|
-
this.logger =
|
|
16
|
+
this.logger = winston.createLogger({
|
|
21
17
|
level: logLevel,
|
|
22
|
-
levels:
|
|
18
|
+
levels: winston.config.syslog.levels,
|
|
23
19
|
transports: [],
|
|
24
20
|
handleExceptions: true,
|
|
25
21
|
handleRejections: true,
|
|
@@ -57,15 +53,14 @@ class BaseLogger {
|
|
|
57
53
|
this.logger.add(transport);
|
|
58
54
|
}
|
|
59
55
|
log(level, messages) {
|
|
60
|
-
const mappedLevel =
|
|
56
|
+
const mappedLevel = loggerToSyslogMap.get(level) ?? level;
|
|
61
57
|
this.logger.log({
|
|
62
58
|
level: mappedLevel,
|
|
63
|
-
message:
|
|
59
|
+
message: format(...messages),
|
|
64
60
|
items: messages,
|
|
65
61
|
context: this.context,
|
|
66
62
|
traceId: this.traceContext.get()?.traceId,
|
|
67
63
|
});
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
|
-
exports.BaseLogger = BaseLogger;
|
|
71
66
|
//# sourceMappingURL=base.logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../../src/logger/base.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../../src/logger/base.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,OAAO,MAAM,SAAS,CAAC;AAS9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoB;KAC1D,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC;KACzB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoB;KAC1D,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC;KACzB,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAG1B,MAAM,OAAgB,UAAU;IACrB,OAAO,GAAqB,IAAI,CAAC;IAC1B,MAAM,CAAiB;IACvB,YAAY,CAAe;IAE5C,YAAsB,QAAkB,EAAE,OAAe,EAAE,YAA0B;QACpF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QAEjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;YAClC,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;YACpC,UAAU,EAAE,EAAE;YACd,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,IAAI;YACtB,WAAW,EAAE,KAAK;SAClB,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,GAAG,QAAmB;QAClC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;IACM,IAAI,CAAC,GAAG,QAAmB;QACjC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IA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.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COLOR = void 0;
|
|
4
|
-
exports.colorize = colorize;
|
|
5
1
|
const isColorAllowed = !process.env['NO_COLOR'];
|
|
6
|
-
var COLOR;
|
|
2
|
+
export var COLOR;
|
|
7
3
|
(function (COLOR) {
|
|
8
4
|
COLOR["ORANGE"] = "38;5;3";
|
|
9
5
|
COLOR["GREEN"] = "32";
|
|
@@ -11,8 +7,8 @@ var COLOR;
|
|
|
11
7
|
COLOR["RED"] = "31";
|
|
12
8
|
COLOR["MAGENTA_BRIGHT"] = "95";
|
|
13
9
|
COLOR["CYAN_BRIGHT"] = "96";
|
|
14
|
-
})(COLOR || (
|
|
15
|
-
function colorize(color, text) {
|
|
10
|
+
})(COLOR || (COLOR = {}));
|
|
11
|
+
export function colorize(color, text) {
|
|
16
12
|
if (!isColorAllowed) {
|
|
17
13
|
return text;
|
|
18
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/logger/colors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/logger/colors.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AAEhD,MAAM,CAAN,IAAY,KAOX;AAPD,WAAY,KAAK;IAChB,0BAAiB,CAAA;IACjB,qBAAY,CAAA;IACZ,sBAAa,CAAA;IACb,mBAAU,CAAA;IACV,8BAAqB,CAAA;IACrB,2BAAkB,CAAA;AACnB,CAAC,EAPW,KAAK,KAAL,KAAK,QAOhB;AAED,MAAM,UAAU,QAAQ,CAAC,KAAY,EAAE,IAAY;IAClD,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,QAAQ,KAAK,IAAI,IAAI,UAAU,CAAC;AACxC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TraceContext } from '../trace.context';
|
|
2
|
-
import { BaseLogger } from './base.logger';
|
|
3
|
-
import { COLOR } from './colors';
|
|
1
|
+
import { TraceContext } from '../trace.context.js';
|
|
2
|
+
import { BaseLogger } from './base.logger.js';
|
|
3
|
+
import { COLOR } from './colors.js';
|
|
4
4
|
export declare const colorsMap: Map<"debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency", COLOR>;
|
|
5
5
|
export declare class ConsoleLogger extends BaseLogger {
|
|
6
6
|
constructor(traceContext: TraceContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.logger.d.ts","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"console.logger.d.ts","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,OAAO,EACN,UAAU,EAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,EAEL,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,SAAS,oGAQc,CAAC;AAiErC,qBAAa,aAAc,SAAQ,UAAU;gBACzB,YAAY,EAAE,YAAY;CAK7C"}
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.set('
|
|
12
|
-
.set('
|
|
13
|
-
.set('
|
|
14
|
-
.set('
|
|
15
|
-
.set('warning', colors_1.COLOR.YELLOW)
|
|
16
|
-
.set('notice', colors_1.COLOR.GREEN)
|
|
17
|
-
.set('info', colors_1.COLOR.CYAN_BRIGHT)
|
|
18
|
-
.set('debug', colors_1.COLOR.MAGENTA_BRIGHT);
|
|
1
|
+
import { MESSAGE } from 'triple-beam';
|
|
2
|
+
import winston from 'winston';
|
|
3
|
+
import { baseFormatter, createFormatter, } from './base.formatter.js';
|
|
4
|
+
import { BaseLogger, } from './base.logger.js';
|
|
5
|
+
import { COLOR, colorize, } from './colors.js';
|
|
6
|
+
export const colorsMap = new Map()
|
|
7
|
+
.set('emergency', COLOR.RED)
|
|
8
|
+
.set('alert', COLOR.RED)
|
|
9
|
+
.set('critical', COLOR.RED)
|
|
10
|
+
.set('error', COLOR.RED)
|
|
11
|
+
.set('warning', COLOR.YELLOW)
|
|
12
|
+
.set('notice', COLOR.GREEN)
|
|
13
|
+
.set('info', COLOR.CYAN_BRIGHT)
|
|
14
|
+
.set('debug', COLOR.MAGENTA_BRIGHT);
|
|
19
15
|
function colorizeLevel(level) {
|
|
20
|
-
const levelColor =
|
|
21
|
-
return `<${
|
|
16
|
+
const levelColor = colorsMap.get(level);
|
|
17
|
+
return `<${colorize(levelColor, level)}>`;
|
|
22
18
|
}
|
|
23
19
|
function colorizeContext(context) {
|
|
24
20
|
if (context) {
|
|
25
|
-
return `[${
|
|
21
|
+
return `[${colorize(COLOR.ORANGE, context)}]`;
|
|
26
22
|
}
|
|
27
23
|
return '';
|
|
28
24
|
}
|
|
29
25
|
function colorizeMessage(level, message) {
|
|
30
|
-
const levelColor =
|
|
31
|
-
return
|
|
26
|
+
const levelColor = colorsMap.get(level);
|
|
27
|
+
return colorize(levelColor, message);
|
|
32
28
|
}
|
|
33
29
|
function formatProcess(process) {
|
|
34
30
|
if (process.title) {
|
|
@@ -42,7 +38,7 @@ function formatTraceId(traceId) {
|
|
|
42
38
|
function formatTime(time) {
|
|
43
39
|
return time.toLocaleString('ru-RU');
|
|
44
40
|
}
|
|
45
|
-
const customFormat =
|
|
41
|
+
const customFormat = createFormatter(info => {
|
|
46
42
|
const process = formatProcess(info.process);
|
|
47
43
|
const timestamp = formatTime(info.timestamp);
|
|
48
44
|
const context = colorizeContext(info.context);
|
|
@@ -54,17 +50,16 @@ const customFormat = (0, base_formatter_1.createFormatter)(info => {
|
|
|
54
50
|
metaInfoItems.push(traceId);
|
|
55
51
|
}
|
|
56
52
|
const metaInfo = metaInfoItems.join(' ');
|
|
57
|
-
info[
|
|
53
|
+
info[MESSAGE] = `${metaInfo}: ${message}`;
|
|
58
54
|
return info;
|
|
59
55
|
});
|
|
60
|
-
const consoleTransport = new
|
|
61
|
-
format:
|
|
56
|
+
const consoleTransport = new winston.transports.Console({
|
|
57
|
+
format: winston.format.combine(baseFormatter(), customFormat()),
|
|
62
58
|
});
|
|
63
|
-
class ConsoleLogger extends
|
|
59
|
+
export class ConsoleLogger extends BaseLogger {
|
|
64
60
|
constructor(traceContext) {
|
|
65
61
|
super('debug', 'test', traceContext);
|
|
66
62
|
this.addTransport(consoleTransport);
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
|
-
exports.ConsoleLogger = ConsoleLogger;
|
|
70
65
|
//# sourceMappingURL=console.logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.logger.js","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"console.logger.js","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EACN,aAAa,EACb,eAAe,GAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,UAAU,GAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,EACL,QAAQ,GACR,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAmB;KACjD,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC;KAC3B,GAAG,CAAC,OAAO,E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AAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAErC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACrC,CAAC;CACD"}
|
package/dist/logger/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Logger } from './logger';
|
|
2
|
-
export { MockLogger } from './mock.logger';
|
|
3
|
-
export { ConsoleLogger } from './console.logger';
|
|
4
|
-
export { JSONLogger } from './json.logger';
|
|
1
|
+
export { Logger } from './logger.js';
|
|
2
|
+
export { MockLogger } from './mock.logger.js';
|
|
3
|
+
export { ConsoleLogger } from './console.logger.js';
|
|
4
|
+
export { JSONLogger } from './json.logger.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/logger/index.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
6
|
-
var mock_logger_1 = require("./mock.logger");
|
|
7
|
-
Object.defineProperty(exports, "MockLogger", { enumerable: true, get: function () { return mock_logger_1.MockLogger; } });
|
|
8
|
-
var console_logger_1 = require("./console.logger");
|
|
9
|
-
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return console_logger_1.ConsoleLogger; } });
|
|
10
|
-
var json_logger_1 = require("./json.logger");
|
|
11
|
-
Object.defineProperty(exports, "JSONLogger", { enumerable: true, get: function () { return json_logger_1.JSONLogger; } });
|
|
1
|
+
export { Logger } from './logger.js';
|
|
2
|
+
export { MockLogger } from './mock.logger.js';
|
|
3
|
+
export { ConsoleLogger } from './console.logger.js';
|
|
4
|
+
export { JSONLogger } from './json.logger.js';
|
|
12
5
|
//# sourceMappingURL=index.js.map
|
package/dist/logger/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TraceContext } from '../trace.context';
|
|
2
|
-
import { BaseLogger } from './base.logger';
|
|
1
|
+
import { TraceContext } from '../trace.context.js';
|
|
2
|
+
import { BaseLogger } from './base.logger.js';
|
|
3
3
|
export declare class JSONLogger extends BaseLogger {
|
|
4
4
|
constructor(traceContext: TraceContext);
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.logger.d.ts","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"json.logger.d.ts","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAS9C,qBAAa,UAAW,SAAQ,UAAU;gBACtB,YAAY,EAAE,YAAY;CAK7C"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const base_formatter_1 = require("./base.formatter");
|
|
7
|
-
const base_logger_1 = require("./base.logger");
|
|
8
|
-
const jsonTransport = new winston_1.default.transports.Console({
|
|
9
|
-
format: winston_1.default.format.combine((0, base_formatter_1.baseFormatter)(), winston_1.default.format.json()),
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
import { baseFormatter } from './base.formatter.js';
|
|
3
|
+
import { BaseLogger } from './base.logger.js';
|
|
4
|
+
const jsonTransport = new winston.transports.Console({
|
|
5
|
+
format: winston.format.combine(baseFormatter(), winston.format.json()),
|
|
10
6
|
});
|
|
11
|
-
class JSONLogger extends
|
|
7
|
+
export class JSONLogger extends BaseLogger {
|
|
12
8
|
constructor(traceContext) {
|
|
13
9
|
super('debug', 'test', traceContext);
|
|
14
10
|
this.addTransport(jsonTransport);
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
exports.JSONLogger = JSONLogger;
|
|
18
13
|
//# sourceMappingURL=json.logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.logger.js","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.logger.js","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;IACpD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC7B,aAAa,EAAE,EACf,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACrB;CACD,CAAC,CAAC;AAEH,MAAM,OAAO,UAAW,SAAQ,UAAU;IACzC,YAAmB,YAA0B;QAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAErC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;CACD"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,MAAM;CAW3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.logger.d.ts","sourceRoot":"","sources":["../../src/logger/mock.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mock.logger.d.ts","sourceRoot":"","sources":["../../src/logger/mock.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,qBAAa,UAAW,SAAQ,MAAM;IAC9B,KAAK,IAAI,IAAI;IACb,IAAI,IAAI,IAAI;IACZ,MAAM,IAAI,IAAI;IACd,OAAO,IAAI,IAAI;IACf,KAAK,IAAI,IAAI;IACb,QAAQ,IAAI,IAAI;IAChB,KAAK,IAAI,IAAI;IACb,SAAS,IAAI,IAAI;IAEjB,UAAU,IAAI,IAAI;CACzB"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MockLogger = void 0;
|
|
4
|
-
const logger_1 = require("./logger");
|
|
5
|
-
class MockLogger extends logger_1.Logger {
|
|
1
|
+
import { Logger } from './logger.js';
|
|
2
|
+
export class MockLogger extends Logger {
|
|
6
3
|
debug() { }
|
|
7
4
|
info() { }
|
|
8
5
|
notice() { }
|
|
@@ -13,5 +10,4 @@ class MockLogger extends logger_1.Logger {
|
|
|
13
10
|
emergency() { }
|
|
14
11
|
setContext() { }
|
|
15
12
|
}
|
|
16
|
-
exports.MockLogger = MockLogger;
|
|
17
13
|
//# sourceMappingURL=mock.logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.logger.js","sourceRoot":"","sources":["../../src/logger/mock.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mock.logger.js","sourceRoot":"","sources":["../../src/logger/mock.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,OAAO,UAAW,SAAQ,MAAM;IAC9B,KAAK,KAAU,CAAC;IAChB,IAAI,KAAU,CAAC;IACf,MAAM,KAAU,CAAC;IACjB,OAAO,KAAU,CAAC;IAClB,KAAK,KAAU,CAAC;IAChB,QAAQ,KAAU,CAAC;IACnB,KAAK,KAAU,CAAC;IAChB,SAAS,KAAU,CAAC;IAEpB,UAAU,KAAU,CAAC;CAC5B"}
|
package/dist/logger.module.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const logger_1 = require("./logger");
|
|
9
|
-
const nest_wrapped_logger_1 = require("./nest-wrapped.logger");
|
|
10
|
-
const trace_context_1 = require("./trace.context");
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { ExecutionMode, ExecutionModeModule, ExecutionModeVariants, } from '@hg-ts/execution-mode';
|
|
3
|
+
import { Global, Module, Scope, } from '@nestjs/common';
|
|
4
|
+
import { INQUIRER } from '@nestjs/core';
|
|
5
|
+
import { ConsoleLogger, JSONLogger, Logger, MockLogger, } from './logger/index.js';
|
|
6
|
+
import { NestWrappedLogger } from './nest-wrapped.logger.js';
|
|
7
|
+
import { TraceContext } from './trace.context.js';
|
|
11
8
|
let LoggerModule = class LoggerModule {
|
|
12
9
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
imports: [execution_mode_1.ExecutionModeModule],
|
|
10
|
+
LoggerModule = __decorate([
|
|
11
|
+
Global(),
|
|
12
|
+
Module({
|
|
13
|
+
imports: [ExecutionModeModule],
|
|
18
14
|
providers: [
|
|
19
|
-
|
|
15
|
+
TraceContext,
|
|
20
16
|
{
|
|
21
|
-
provide:
|
|
17
|
+
provide: Logger,
|
|
22
18
|
useFactory(parent, executionMode, traceContext) {
|
|
23
19
|
const context = (parent && Object.getPrototypeOf(parent)?.constructor.name) ?? null;
|
|
24
20
|
const shouldUseConsoleLogger = executionMode.isValueIn([
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
ExecutionModeVariants.DEBUG,
|
|
22
|
+
ExecutionModeVariants.DEV,
|
|
27
23
|
]);
|
|
28
|
-
const shouldUseMockLogger = executionMode.is(
|
|
24
|
+
const shouldUseMockLogger = executionMode.is(ExecutionModeVariants.TEST);
|
|
29
25
|
if (shouldUseMockLogger) {
|
|
30
|
-
return new
|
|
26
|
+
return new MockLogger();
|
|
31
27
|
}
|
|
32
|
-
const logger = shouldUseConsoleLogger ? new
|
|
28
|
+
const logger = shouldUseConsoleLogger ? new ConsoleLogger(traceContext) : new JSONLogger(traceContext);
|
|
33
29
|
logger.setContext(context);
|
|
34
30
|
return logger;
|
|
35
31
|
},
|
|
36
|
-
inject: [
|
|
37
|
-
scope:
|
|
32
|
+
inject: [INQUIRER, ExecutionMode, TraceContext],
|
|
33
|
+
scope: Scope.TRANSIENT,
|
|
38
34
|
},
|
|
39
|
-
|
|
35
|
+
NestWrappedLogger,
|
|
40
36
|
],
|
|
41
|
-
exports: [
|
|
37
|
+
exports: [Logger, TraceContext],
|
|
42
38
|
})
|
|
43
39
|
], LoggerModule);
|
|
40
|
+
export { LoggerModule };
|
|
44
41
|
//# sourceMappingURL=logger.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../src/logger.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../src/logger.module.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,MAAM,EACN,MAAM,EAEN,KAAK,GACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EACN,aAAa,EACb,UAAU,EACV,MAAM,EACN,UAAU,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAgC3C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,YAAY;IA9BxB,MAAM,EAAE;IACR,MAAM,CAAC;QACP,OAAO,EAAE,CAAC,mBAAmB,CAAC;QAC9B,SAAS,EAAE;YACV,YAAY;YACZ;gBACC,OAAO,EAAE,MAAM;gBACf,UAAU,CAAC,MAAW,EAAE,aAA4B,EAAE,YAA0B;oBAC/E,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;oBACpF,MAAM,sBAAsB,GAAG,aAAa,CAAC,SAAS,CAAC;wBACtD,qBAAqB,CAAC,KAAK;wBAC3B,qBAAqB,CAAC,GAAG;qBACzB,CAAC,CAAC;oBACH,MAAM,mBAAmB,GAAG,aAAa,CAAC,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;oBAEzE,IAAI,mBAAmB,EAAE,CAAC;wBACzB,OAAO,IAAI,UAAU,EAAE,CAAC;oBACzB,CAAC;oBACD,MAAM,MAAM,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC;oBAEvG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC3B,OAAO,MAAM,CAAC;gBACf,CAAC;gBACD,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,YAAY,CAAC;gBAC/C,KAAK,EAAE,KAAK,CAAC,SAAS;aACK;YAC5B,iBAAiB;SACjB;QACD,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;KAC/B,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoggerService, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { Logger } from './logger';
|
|
2
|
+
import { Logger } from './logger/index.js';
|
|
3
3
|
export declare class NestWrappedLogger implements LoggerService, OnModuleInit {
|
|
4
4
|
protected readonly logger: Logger;
|
|
5
5
|
debug(message: any, context?: string): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest-wrapped.logger.d.ts","sourceRoot":"","sources":["../src/nest-wrapped.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"nest-wrapped.logger.d.ts","sourceRoot":"","sources":["../src/nest-wrapped.logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,aAAa,EACb,YAAY,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,qBAAa,iBAAkB,YAAW,aAAa,EAAE,YAAY;IAEpE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAE3B,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAK1C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAK1D,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAKxC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAK5C,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG;IAMnC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ1C,OAAO,CAAC,kBAAkB;CAG1B"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const logger_1 = require("./logger");
|
|
7
|
-
class NestWrappedLogger {
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Inject, Logger as NestLogger, } from '@nestjs/common';
|
|
3
|
+
import { Logger } from './logger/index.js';
|
|
4
|
+
export class NestWrappedLogger {
|
|
8
5
|
logger;
|
|
9
6
|
debug(message, context) {
|
|
10
7
|
this.setOptionalContext(context);
|
|
@@ -28,18 +25,17 @@ class NestWrappedLogger {
|
|
|
28
25
|
}
|
|
29
26
|
async onModuleInit() {
|
|
30
27
|
this.logger.setContext(null);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
NestLogger.overrideLogger(true);
|
|
29
|
+
NestLogger.overrideLogger(['debug', 'log', 'verbose', 'warn', 'error']);
|
|
30
|
+
NestLogger.overrideLogger(this);
|
|
31
|
+
NestLogger.flush();
|
|
35
32
|
}
|
|
36
33
|
setOptionalContext(context = null) {
|
|
37
34
|
this.logger.setContext(context);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
(
|
|
43
|
-
tslib_1.__metadata("design:type", logger_1.Logger)
|
|
37
|
+
__decorate([
|
|
38
|
+
Inject(),
|
|
39
|
+
__metadata("design:type", Logger)
|
|
44
40
|
], NestWrappedLogger.prototype, "logger", void 0);
|
|
45
41
|
//# sourceMappingURL=nest-wrapped.logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest-wrapped.logger.js","sourceRoot":"","sources":["../src/nest-wrapped.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nest-wrapped.logger.js","sourceRoot":"","sources":["../src/nest-wrapped.logger.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,MAAM,EACN,MAAM,IAAI,UAAU,GAGpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,MAAM,OAAO,iBAAiB;IAEV,MAAM,CAAS;IAE3B,KAAK,CAAC,OAAY,EAAE,OAAgB;QAC1C,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,OAAY,EAAE,KAAc,EAAE,OAAgB;QAC1D,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAEM,GAAG,CAAC,OAAY,EAAE,OAAgB;QACxC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAEM,OAAO,CAAC,OAAY,EAAE,OAAgB;QAC5C,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAEM,IAAI,CAAC,OAAY,EAAE,OAAgB;QACzC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAGM,KAAK,CAAC,YAAY;QACxB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7B,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAChC,UAAU,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACxE,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAChC,UAAU,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAEO,kBAAkB,CAAC,UAA4B,IAAI;QAC1D,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACD;AAvCmB;IADlB,MAAM,EAAE;8BACkB,MAAM;iDAAC"}
|
package/dist/trace.context.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TraceContext = void 0;
|
|
4
|
-
const async_context_1 = require("@hg-ts/async-context");
|
|
5
|
-
class TraceContext extends async_context_1.AsyncContextProvider {
|
|
1
|
+
import { AsyncContextProvider } from '@hg-ts/async-context';
|
|
2
|
+
export class TraceContext extends AsyncContextProvider {
|
|
6
3
|
}
|
|
7
|
-
exports.TraceContext = TraceContext;
|
|
8
4
|
//# sourceMappingURL=trace.context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.context.js","sourceRoot":"","sources":["../src/trace.context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trace.context.js","sourceRoot":"","sources":["../src/trace.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAM5D,MAAM,OAAO,YAAa,SAAQ,oBAA+B;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/logger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": "./dist/index.js"
|
|
7
8
|
},
|
|
@@ -15,11 +16,11 @@
|
|
|
15
16
|
"lint:ts:fix": "lint-ts --fix"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@hg-ts-config/typescript": "0.
|
|
19
|
-
"@hg-ts/async-context": "0.
|
|
20
|
-
"@hg-ts/execution-mode": "0.
|
|
21
|
-
"@hg-ts/linter": "0.
|
|
22
|
-
"@hg-ts/types": "0.
|
|
19
|
+
"@hg-ts-config/typescript": "0.4.1",
|
|
20
|
+
"@hg-ts/async-context": "0.4.1",
|
|
21
|
+
"@hg-ts/execution-mode": "0.4.1",
|
|
22
|
+
"@hg-ts/linter": "0.4.1",
|
|
23
|
+
"@hg-ts/types": "0.4.1",
|
|
23
24
|
"@nestjs/common": "11.1.0",
|
|
24
25
|
"@nestjs/core": "11.1.0",
|
|
25
26
|
"@types/node": "22.19.1",
|
package/tsconfig.json
CHANGED