@hg-ts/logger 0.2.30 → 0.3.2
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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger/base.logger.d.ts +3 -1
- package/dist/logger/base.logger.d.ts.map +1 -1
- package/dist/logger/base.logger.js +4 -1
- package/dist/logger/base.logger.js.map +1 -1
- package/dist/logger/console.logger.d.ts +2 -1
- package/dist/logger/console.logger.d.ts.map +1 -1
- package/dist/logger/console.logger.js +10 -3
- package/dist/logger/console.logger.js.map +1 -1
- package/dist/logger/json.logger.d.ts +2 -1
- package/dist/logger/json.logger.d.ts.map +1 -1
- package/dist/logger/json.logger.js +2 -2
- package/dist/logger/json.logger.js.map +1 -1
- package/dist/logger.module.d.ts.map +1 -1
- package/dist/logger.module.js +6 -4
- package/dist/logger.module.js.map +1 -1
- package/dist/trace.context.d.ts +7 -0
- package/dist/trace.context.d.ts.map +1 -0
- package/dist/trace.context.js +8 -0
- package/dist/trace.context.js.map +1 -0
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
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,UAAU,CAAC;AAClB,cAAc,iBAAiB,CAAC"}
|
|
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,UAAU,CAAC;AAClB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,4 +8,5 @@ Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: functio
|
|
|
8
8
|
Object.defineProperty(exports, "JSONLogger", { enumerable: true, get: function () { return logger_1.JSONLogger; } });
|
|
9
9
|
Object.defineProperty(exports, "MockLogger", { enumerable: true, get: function () { return logger_1.MockLogger; } });
|
|
10
10
|
tslib_1.__exportStar(require("./logger.module"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./trace.context"), exports);
|
|
11
12
|
//# 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":";;;;AAAA,mCAKkB;AAJjB,gGAAA,MAAM,OAAA;AACN,uGAAA,aAAa,OAAA;AACb,oGAAA,UAAU,OAAA;AACV,oGAAA,UAAU,OAAA;AAEX,0DAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mCAKkB;AAJjB,gGAAA,MAAM,OAAA;AACN,uGAAA,aAAa,OAAA;AACb,oGAAA,UAAU,OAAA;AACV,oGAAA,UAAU,OAAA;AAEX,0DAAgC;AAChC,0DAAgC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
|
+
import { TraceContext } from '../trace.context';
|
|
2
3
|
import { Logger } from './logger';
|
|
3
4
|
type Transport = winston.Logger['add'] extends (transport: infer R) => void ? R : never;
|
|
4
5
|
export type LogLevel = keyof Omit<Logger, 'setContext'>;
|
|
@@ -7,7 +8,8 @@ export declare const loggerToSyslogMap: Map<"debug" | "info" | "notice" | "warni
|
|
|
7
8
|
export declare abstract class BaseLogger implements Logger {
|
|
8
9
|
protected context: Nullable<string>;
|
|
9
10
|
private readonly logger;
|
|
10
|
-
|
|
11
|
+
private readonly traceContext;
|
|
12
|
+
protected constructor(logLevel: LogLevel, context: string, traceContext: TraceContext);
|
|
11
13
|
debug(...messages: unknown[]): void;
|
|
12
14
|
info(...messages: unknown[]): void;
|
|
13
15
|
notice(...messages: unknown[]): void;
|
|
@@ -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;
|
|
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,kBAAkB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,KAAK,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;AAExF,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,iBAAiB,qGAEL,CAAC;AAE1B,eAAO,MAAM,iBAAiB,qGAEL,CAAC;AAG1B,8BAAsB,UAAW,YAAW,MAAM;IACjD,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,SAAS,aAAa,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY;IAc9E,KAAK,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGnC,IAAI,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGlC,MAAM,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGpC,OAAO,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGrC,KAAK,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGnC,QAAQ,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGtC,KAAK,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAGnC,SAAS,CAAC,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAIvC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI;IAIlD,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIlD,OAAO,CAAC,GAAG;CAWX"}
|
|
@@ -13,8 +13,10 @@ exports.loggerToSyslogMap = new Map()
|
|
|
13
13
|
class BaseLogger {
|
|
14
14
|
context = null;
|
|
15
15
|
logger;
|
|
16
|
-
|
|
16
|
+
traceContext;
|
|
17
|
+
constructor(logLevel, context, traceContext) {
|
|
17
18
|
this.context = context;
|
|
19
|
+
this.traceContext = traceContext;
|
|
18
20
|
this.logger = winston_1.default.createLogger({
|
|
19
21
|
level: logLevel,
|
|
20
22
|
levels: winston_1.default.config.syslog.levels,
|
|
@@ -61,6 +63,7 @@ class BaseLogger {
|
|
|
61
63
|
message: (0, node_util_1.format)(...messages),
|
|
62
64
|
items: messages,
|
|
63
65
|
context: this.context,
|
|
66
|
+
traceId: this.traceContext.get()?.traceId,
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../../src/logger/base.logger.ts"],"names":[],"mappings":";;;;AAAA,yCAAmC;AACnC,8DAA8B;
|
|
1
|
+
{"version":3,"file":"base.logger.js","sourceRoot":"","sources":["../../src/logger/base.logger.ts"],"names":[],"mappings":";;;;AAAA,yCAAmC;AACnC,8DAA8B;AASjB,QAAA,iBAAiB,GAAG,IAAI,GAAG,EAAoB;KAC1D,GAAG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AC;IACM,QAAQ,CAAC,GAAG,QAAmB;QACrC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAChC,CAAC;IACM,KAAK,CAAC,GAAG,QAAmB;QAClC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;IACM,SAAS,CAAC,GAAG,QAAmB;QACtC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;IAEM,UAAU,CAAC,OAAyB;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAES,YAAY,CAAC,SAAoB;QAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAEO,GAAG,CAAC,KAAe,EAAE,QAAmB;QAC/C,MAAM,WAAW,GAAG,yBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;QAE1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YACf,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,IAAA,kBAAM,EAAC,GAAG,QAAQ,CAAC;YAC5B,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,OAAO;SACzC,CAAC,CAAC;IACJ,CAAC;CACD;AA/DD,gCA+DC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { TraceContext } from '../trace.context';
|
|
1
2
|
import { BaseLogger } from './base.logger';
|
|
2
3
|
import { COLOR } from './colors';
|
|
3
4
|
export declare const colorsMap: Map<"debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency", COLOR>;
|
|
4
5
|
export declare class ConsoleLogger extends BaseLogger {
|
|
5
|
-
constructor();
|
|
6
|
+
constructor(traceContext: TraceContext);
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=console.logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.logger.d.ts","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"console.logger.d.ts","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMhD,OAAO,EACN,UAAU,EAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,KAAK,EAEL,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,SAAS,oGAQc,CAAC;AAiErC,qBAAa,aAAc,SAAQ,UAAU;gBACzB,YAAY,EAAE,YAAY;CAK7C"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConsoleLogger = exports.colorsMap = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const winston_1 = tslib_1.__importDefault(require("winston"));
|
|
6
5
|
const triple_beam_1 = require("triple-beam");
|
|
6
|
+
const winston_1 = tslib_1.__importDefault(require("winston"));
|
|
7
7
|
const base_formatter_1 = require("./base.formatter");
|
|
8
8
|
const base_logger_1 = require("./base.logger");
|
|
9
9
|
const colors_1 = require("./colors");
|
|
@@ -36,6 +36,9 @@ function formatProcess(process) {
|
|
|
36
36
|
}
|
|
37
37
|
return `[pid: ${process.pid}]`;
|
|
38
38
|
}
|
|
39
|
+
function formatTraceId(traceId) {
|
|
40
|
+
return `[traceId: ${traceId}]`;
|
|
41
|
+
}
|
|
39
42
|
function formatTime(time) {
|
|
40
43
|
return time.toLocaleString('ru-RU');
|
|
41
44
|
}
|
|
@@ -45,7 +48,11 @@ const customFormat = (0, base_formatter_1.createFormatter)(info => {
|
|
|
45
48
|
const context = colorizeContext(info.context);
|
|
46
49
|
const level = colorizeLevel(info.level);
|
|
47
50
|
const message = colorizeMessage(info.level, info.message);
|
|
51
|
+
const traceId = info['traceId'] ? formatTraceId(info['traceId']) : null;
|
|
48
52
|
const metaInfoItems = [timestamp, context, level, process];
|
|
53
|
+
if (traceId) {
|
|
54
|
+
metaInfoItems.push(traceId);
|
|
55
|
+
}
|
|
49
56
|
const metaInfo = metaInfoItems.join(' ');
|
|
50
57
|
info[triple_beam_1.MESSAGE] = `${metaInfo}: ${message}`;
|
|
51
58
|
return info;
|
|
@@ -54,8 +61,8 @@ const consoleTransport = new winston_1.default.transports.Console({
|
|
|
54
61
|
format: winston_1.default.format.combine((0, base_formatter_1.baseFormatter)(), customFormat()),
|
|
55
62
|
});
|
|
56
63
|
class ConsoleLogger extends base_logger_1.BaseLogger {
|
|
57
|
-
constructor() {
|
|
58
|
-
super('debug', 'test');
|
|
64
|
+
constructor(traceContext) {
|
|
65
|
+
super('debug', 'test', traceContext);
|
|
59
66
|
this.addTransport(consoleTransport);
|
|
60
67
|
}
|
|
61
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.logger.js","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"console.logger.js","sourceRoot":"","sources":["../../src/logger/console.logger.ts"],"names":[],"mappings":";;;;AAAA,6CAAsC;AACtC,8DAA8B;AAE9B,qDAI0B;AAC1B,+CAGuB;AACvB,qCAGkB;AAEL,QAAA,SAAS,GAAG,IAAI,GAAG,EAAmB;KACjD,GAAG,CAAC,WAAW,EAAE,cAAK,CAAC,GAAG,CAAC;KAC3B,GAAG,CAAC,OAAO,EAAE,cAAK,CAAC,GAAG,CAAC;KACvB,GAAG,CAAC,UAAU,EAAE,cAAK,CAAC,GAAG,CAAC;KAC1B,GAAG,CAAC,OAAO,EAAE,cAAK,CAAC,GAAG,CAAC;KACvB,GAAG,CAAC,SAAS,EAAE,cAAK,CAAC,MAAM,CAAC;KAC5B,GAAG,CAAC,QAAQ,EAAE,cAAK,CAAC,K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logger/json.logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.logger.d.ts","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAS3C,qBAAa,UAAW,SAAQ,UAAU;gBACtB,YAAY,EAAE,YAAY;CAK7C"}
|
|
@@ -9,8 +9,8 @@ const jsonTransport = new winston_1.default.transports.Console({
|
|
|
9
9
|
format: winston_1.default.format.combine((0, base_formatter_1.baseFormatter)(), winston_1.default.format.json()),
|
|
10
10
|
});
|
|
11
11
|
class JSONLogger extends base_logger_1.BaseLogger {
|
|
12
|
-
constructor() {
|
|
13
|
-
super('debug', 'test');
|
|
12
|
+
constructor(traceContext) {
|
|
13
|
+
super('debug', 'test', traceContext);
|
|
14
14
|
this.addTransport(jsonTransport);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.logger.js","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":";;;;AAAA,8DAA8B;
|
|
1
|
+
{"version":3,"file":"json.logger.js","sourceRoot":"","sources":["../../src/logger/json.logger.ts"],"names":[],"mappings":";;;;AAAA,8DAA8B;AAE9B,qDAAiD;AACjD,+CAA2C;AAE3C,MAAM,aAAa,GAAG,IAAI,iBAAO,CAAC,UAAU,CAAC,OAAO,CAAC;IACpD,MAAM,EAAE,iBAAO,CAAC,MAAM,CAAC,OAAO,CAC7B,IAAA,8BAAa,GAAE,EACf,iBAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CACrB;CACD,CAAC,CAAC;AAEH,MAAa,UAAW,SAAQ,wBAAU;IACzC,YAAmB,YAA0B;QAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAErC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;CACD;AAND,gCAMC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.module.d.ts","sourceRoot":"","sources":["../src/logger.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.module.d.ts","sourceRoot":"","sources":["../src/logger.module.ts"],"names":[],"mappings":"AAuBA,qBA8Ba,YAAY;CAAG"}
|
package/dist/logger.module.js
CHANGED
|
@@ -7,6 +7,7 @@ const common_1 = require("@nestjs/common");
|
|
|
7
7
|
const core_1 = require("@nestjs/core");
|
|
8
8
|
const logger_1 = require("./logger");
|
|
9
9
|
const nest_wrapped_logger_1 = require("./nest-wrapped.logger");
|
|
10
|
+
const trace_context_1 = require("./trace.context");
|
|
10
11
|
let LoggerModule = class LoggerModule {
|
|
11
12
|
};
|
|
12
13
|
exports.LoggerModule = LoggerModule;
|
|
@@ -15,9 +16,10 @@ exports.LoggerModule = LoggerModule = tslib_1.__decorate([
|
|
|
15
16
|
(0, common_1.Module)({
|
|
16
17
|
imports: [execution_mode_1.ExecutionModeModule],
|
|
17
18
|
providers: [
|
|
19
|
+
trace_context_1.TraceContext,
|
|
18
20
|
{
|
|
19
21
|
provide: logger_1.Logger,
|
|
20
|
-
useFactory(parent, executionMode) {
|
|
22
|
+
useFactory(parent, executionMode, traceContext) {
|
|
21
23
|
const context = (parent && Object.getPrototypeOf(parent)?.constructor.name) ?? null;
|
|
22
24
|
const shouldUseConsoleLogger = executionMode.isValueIn([
|
|
23
25
|
execution_mode_1.ExecutionModeVariants.DEBUG,
|
|
@@ -27,16 +29,16 @@ exports.LoggerModule = LoggerModule = tslib_1.__decorate([
|
|
|
27
29
|
if (shouldUseMockLogger) {
|
|
28
30
|
return new logger_1.MockLogger();
|
|
29
31
|
}
|
|
30
|
-
const logger = shouldUseConsoleLogger ? new logger_1.ConsoleLogger() : new logger_1.JSONLogger();
|
|
32
|
+
const logger = shouldUseConsoleLogger ? new logger_1.ConsoleLogger(traceContext) : new logger_1.JSONLogger(traceContext);
|
|
31
33
|
logger.setContext(context);
|
|
32
34
|
return logger;
|
|
33
35
|
},
|
|
34
|
-
inject: [core_1.INQUIRER, execution_mode_1.ExecutionMode],
|
|
36
|
+
inject: [core_1.INQUIRER, execution_mode_1.ExecutionMode, trace_context_1.TraceContext],
|
|
35
37
|
scope: common_1.Scope.TRANSIENT,
|
|
36
38
|
},
|
|
37
39
|
nest_wrapped_logger_1.NestWrappedLogger,
|
|
38
40
|
],
|
|
39
|
-
exports: [logger_1.Logger],
|
|
41
|
+
exports: [logger_1.Logger, trace_context_1.TraceContext],
|
|
40
42
|
})
|
|
41
43
|
], LoggerModule);
|
|
42
44
|
//# sourceMappingURL=logger.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../src/logger.module.ts"],"names":[],"mappings":";;;;AAAA,0DAI+B;AAE/B,2CAKwB;AACxB,uCAAwC;AAExC,qCAKkB;AAClB,+DAA0D;
|
|
1
|
+
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../src/logger.module.ts"],"names":[],"mappings":";;;;AAAA,0DAI+B;AAE/B,2CAKwB;AACxB,uCAAwC;AAExC,qCAKkB;AAClB,+DAA0D;AAC1D,mDAA+C;AAgCxC,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IA9BxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,oCAAmB,CAAC;QAC9B,SAAS,EAAE;YACV,4BAAY;YACZ;gBACC,OAAO,EAAE,eAAM;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,sCAAqB,CAAC,KAAK;wBAC3B,sCAAqB,CAAC,GAAG;qBACzB,CAAC,CAAC;oBACH,MAAM,mBAAmB,GAAG,aAAa,CAAC,EAAE,CAAC,sCAAqB,CAAC,IAAI,CAAC,CAAC;oBAEzE,IAAI,mBAAmB,EAAE,CAAC;wBACzB,OAAO,IAAI,mBAAU,EAAE,CAAC;oBACzB,CAAC;oBACD,MAAM,MAAM,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,sBAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAU,CAAC,YAAY,CAAC,CAAC;oBAEvG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAC3B,OAAO,MAAM,CAAC;gBACf,CAAC;gBACD,MAAM,EAAE,CAAC,eAAQ,EAAE,8BAAa,EAAE,4BAAY,CAAC;gBAC/C,KAAK,EAAE,cAAK,CAAC,SAAS;aACK;YAC5B,uCAAiB;SACjB;QACD,OAAO,EAAE,CAAC,eAAM,EAAE,4BAAY,CAAC;KAC/B,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.context.d.ts","sourceRoot":"","sources":["../src/trace.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,YAAa,SAAQ,oBAAoB,CAAC,SAAS,CAAC;CAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TraceContext = void 0;
|
|
4
|
+
const async_context_1 = require("@hg-ts/async-context");
|
|
5
|
+
class TraceContext extends async_context_1.AsyncContextProvider {
|
|
6
|
+
}
|
|
7
|
+
exports.TraceContext = TraceContext;
|
|
8
|
+
//# sourceMappingURL=trace.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.context.js","sourceRoot":"","sources":["../src/trace.context.ts"],"names":[],"mappings":";;;AAAA,wDAA4D;AAM5D,MAAa,YAAa,SAAQ,oCAA+B;CAAG;AAApE,oCAAoE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/logger",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
"lint:ts:fix": "lint-ts --fix"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@hg-ts-config/typescript": "0.2
|
|
19
|
-
"@hg-ts/
|
|
20
|
-
"@hg-ts/
|
|
21
|
-
"@hg-ts/
|
|
18
|
+
"@hg-ts-config/typescript": "0.3.2",
|
|
19
|
+
"@hg-ts/async-context": "0.3.2",
|
|
20
|
+
"@hg-ts/execution-mode": "0.3.2",
|
|
21
|
+
"@hg-ts/linter": "0.3.2",
|
|
22
|
+
"@hg-ts/types": "0.3.2",
|
|
22
23
|
"@nestjs/common": "11.1.0",
|
|
23
24
|
"@nestjs/core": "11.1.0",
|
|
24
|
-
"@types/node": "22.
|
|
25
|
+
"@types/node": "22.19.1",
|
|
25
26
|
"@types/triple-beam": "1.3.5",
|
|
26
27
|
"eslint": "9.18.0",
|
|
27
28
|
"reflect-metadata": "0.2.2",
|
|
@@ -31,7 +32,8 @@
|
|
|
31
32
|
"typescript": "5.7.3"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
|
-
"@hg-ts/
|
|
35
|
+
"@hg-ts/async-context": "*",
|
|
36
|
+
"@hg-ts/execution-mode": "*",
|
|
35
37
|
"@hg-ts/types": "*",
|
|
36
38
|
"@nestjs/common": "*",
|
|
37
39
|
"@nestjs/core": "*",
|