@coast/service-common 2.0.51 → 2.0.53
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/context/AsyncContext.d.ts +4 -0
- package/dist/{trace/AsyncStoreTrace.js → context/AsyncContext.js} +1 -1
- package/dist/context/AsyncContext.js.map +1 -0
- package/dist/logger/PinoLogger.d.ts +4 -4
- package/dist/logger/PinoLogger.js +4 -4
- package/dist/logger/PinoLogger.js.map +1 -1
- package/dist/trace/TraceIdContext.d.ts +7 -0
- package/dist/trace/TraceIdContext.js +17 -0
- package/dist/trace/TraceIdContext.js.map +1 -0
- package/package.json +5 -5
- package/dist/trace/AsyncStoreTrace.d.ts +0 -4
- package/dist/trace/AsyncStoreTrace.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncContext.js","sourceRoot":"","sources":["../../lib/context/AsyncContext.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AsyncContext } from '../context/AsyncContext';
|
|
2
|
+
import { Trace } from '../trace/Trace';
|
|
3
3
|
import { CoastLogger } from './CoastLogger';
|
|
4
4
|
import { LoggerOptions } from './LoggerOptions';
|
|
5
5
|
export declare class PinoLogger extends CoastLogger {
|
|
6
|
-
private readonly
|
|
6
|
+
private readonly trace;
|
|
7
7
|
private readonly instance;
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(trace: AsyncContext<Trace> | undefined, options: LoggerOptions);
|
|
9
9
|
debug(message: unknown): void;
|
|
10
10
|
error(message: unknown, trace?: string): void;
|
|
11
11
|
log(message: unknown): void;
|
|
@@ -8,9 +8,9 @@ const pino_1 = __importDefault(require("pino"));
|
|
|
8
8
|
const CoastLogger_1 = require("./CoastLogger");
|
|
9
9
|
const LogLevel_1 = require("./LogLevel");
|
|
10
10
|
class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(trace, options) {
|
|
12
12
|
super();
|
|
13
|
-
this.
|
|
13
|
+
this.trace = trace;
|
|
14
14
|
const level = options.level ?? LogLevel_1.LogLevel.INFO;
|
|
15
15
|
const redact = [
|
|
16
16
|
'AWS_SECRET_ACCESS_KEY',
|
|
@@ -34,7 +34,7 @@ class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
34
34
|
const pino = options.pretty
|
|
35
35
|
? (0, pino_1.default)({
|
|
36
36
|
level,
|
|
37
|
-
mixin: () => this.
|
|
37
|
+
mixin: () => this.trace?.get() ?? {},
|
|
38
38
|
redact,
|
|
39
39
|
transport: {
|
|
40
40
|
options: {
|
|
@@ -46,7 +46,7 @@ class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
46
46
|
})
|
|
47
47
|
: (0, pino_1.default)({
|
|
48
48
|
level,
|
|
49
|
-
mixin: () => this.
|
|
49
|
+
mixin: () => this.trace?.get() ?? {},
|
|
50
50
|
redact,
|
|
51
51
|
});
|
|
52
52
|
this.instance = pino;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinoLogger.js","sourceRoot":"","sources":["../../lib/logger/PinoLogger.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"PinoLogger.js","sourceRoot":"","sources":["../../lib/logger/PinoLogger.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAIxB,+CAA4C;AAE5C,yCAAsC;AAEtC,MAAa,UAAW,SAAQ,yBAAW;IAGvC,YACqB,KAAsC,EACvD,OAAsB;QAEtB,KAAK,EAAE,CAAC;QAHS,UAAK,GAAL,KAAK,CAAiC;QAIvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,mBAAQ,CAAC,IAAI,CAAC;QAE7C,MAAM,MAAM,GAAG;YACX,uBAAuB;YACvB,0BAA0B;YAC1B,mCAAmC;YACnC,YAAY;YACZ,qBAAqB;YACrB,gBAAgB;YAChB,kBAAkB;YAClB,k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,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACJ;AAxED,gCAwEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AsyncContext } from '../context/AsyncContext';
|
|
2
|
+
import { Trace } from './Trace';
|
|
3
|
+
export declare class TraceIdContext implements AsyncContext<Trace> {
|
|
4
|
+
private readonly asyncContext;
|
|
5
|
+
get(): Trace | undefined;
|
|
6
|
+
initialize<U>(fn: () => U, context: Trace): U;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TraceIdContext = void 0;
|
|
4
|
+
const async_hooks_1 = require("async_hooks");
|
|
5
|
+
class TraceIdContext {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.asyncContext = new async_hooks_1.AsyncLocalStorage();
|
|
8
|
+
}
|
|
9
|
+
get() {
|
|
10
|
+
return this.asyncContext.getStore();
|
|
11
|
+
}
|
|
12
|
+
initialize(fn, context) {
|
|
13
|
+
return this.asyncContext.run(context, fn);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.TraceIdContext = TraceIdContext;
|
|
17
|
+
//# sourceMappingURL=TraceIdContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TraceIdContext.js","sourceRoot":"","sources":["../../lib/trace/TraceIdContext.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAQhD,MAAa,cAAc;IAA3B;QACqB,iBAAY,GAAG,IAAI,+BAAiB,EAAS,CAAC;IASnE,CAAC;IAPG,GAAG;QACC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACxC,CAAC;IAED,UAAU,CAAI,EAAW,EAAE,OAAc;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;CACJ;AAVD,wCAUC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coast/service-common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53",
|
|
4
4
|
"description": "Common service package",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.0.0"
|
|
7
7
|
},
|
|
8
8
|
"exports": {
|
|
9
9
|
"./*": {
|
|
10
|
-
"types": "./dist
|
|
11
|
-
"import": "./dist
|
|
12
|
-
"require": "./dist
|
|
10
|
+
"types": "./dist/*.d.ts",
|
|
11
|
+
"import": "./dist/*.js",
|
|
12
|
+
"require": "./dist/*.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"typesVersions": {
|
|
16
16
|
"*": {
|
|
17
17
|
"*": [
|
|
18
|
-
"./dist
|
|
18
|
+
"./dist/*"
|
|
19
19
|
]
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncStoreTrace.js","sourceRoot":"","sources":["../../lib/trace/AsyncStoreTrace.ts"],"names":[],"mappings":""}
|