@coast/service-common 1.0.10 → 1.0.12
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.
|
@@ -17,7 +17,7 @@ let CoastApiModule = CoastApiModule_1 = class CoastApiModule {
|
|
|
17
17
|
static forRootAsync(options) {
|
|
18
18
|
const asyncProvider = CoastApiModule_1.createAsyncOptionsProvider(options);
|
|
19
19
|
const coastClient = {
|
|
20
|
-
inject: [Constants_1.Constants.COAST_API_OPTIONS
|
|
20
|
+
inject: [CoastLogger_1.CoastLogger, Constants_1.Constants.COAST_API_OPTIONS],
|
|
21
21
|
provide: CoastApiClient_1.CoastApiClient,
|
|
22
22
|
useFactory: (logger, options) => new CoastApiClient_1.CoastApiClient(logger, options),
|
|
23
23
|
};
|
|
@@ -30,7 +30,7 @@ let LoggerModule = LoggerModule_1 = class LoggerModule {
|
|
|
30
30
|
static forRootAsync(options) {
|
|
31
31
|
const asyncProvider = LoggerModule_1.createAsyncOptionsProvider(options);
|
|
32
32
|
const coastLogger = {
|
|
33
|
-
inject: [Constants_1.Constants.LOGGER_OPTIONS
|
|
33
|
+
inject: [TraceManager_1.TraceManager, Constants_1.Constants.LOGGER_OPTIONS],
|
|
34
34
|
provide: CoastLogger_1.CoastLogger,
|
|
35
35
|
useFactory: (traceManager, options) => new PinoLogger_1.PinoLogger(traceManager, options),
|
|
36
36
|
};
|
|
@@ -2,8 +2,8 @@ import { LoggerOptions } from '../../models/logger/LoggerOptions';
|
|
|
2
2
|
import { TraceManager } from '../trace/TraceManager';
|
|
3
3
|
import { CoastLogger } from './CoastLogger';
|
|
4
4
|
export declare class PinoLogger extends CoastLogger {
|
|
5
|
+
private readonly traceManager;
|
|
5
6
|
private readonly instance;
|
|
6
|
-
private readonly traceManager?;
|
|
7
7
|
constructor(traceManager: TraceManager, options: LoggerOptions);
|
|
8
8
|
debug(message: unknown): void;
|
|
9
9
|
error(message: unknown, trace?: string): void;
|
|
@@ -25,6 +25,7 @@ const CoastLogger_1 = require("./CoastLogger");
|
|
|
25
25
|
let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
26
26
|
constructor(traceManager, options) {
|
|
27
27
|
super();
|
|
28
|
+
this.traceManager = traceManager;
|
|
28
29
|
const level = options.level ?? LogLevel_1.LogLevel.INFO;
|
|
29
30
|
const redact = [
|
|
30
31
|
'MYSQL_PASSWORD',
|
|
@@ -39,7 +40,7 @@ let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
39
40
|
const pino = options.pretty
|
|
40
41
|
? (0, pino_1.default)({
|
|
41
42
|
level,
|
|
42
|
-
mixin: () => this.traceManager
|
|
43
|
+
mixin: () => this.traceManager.getTrace() ?? {},
|
|
43
44
|
redact,
|
|
44
45
|
transport: {
|
|
45
46
|
options: {
|
|
@@ -51,11 +52,10 @@ let PinoLogger = class PinoLogger extends CoastLogger_1.CoastLogger {
|
|
|
51
52
|
})
|
|
52
53
|
: (0, pino_1.default)({
|
|
53
54
|
level,
|
|
54
|
-
mixin: () => this.traceManager
|
|
55
|
+
mixin: () => this.traceManager.getTrace() ?? {},
|
|
55
56
|
redact,
|
|
56
57
|
});
|
|
57
58
|
this.instance = pino;
|
|
58
|
-
this.traceManager = traceManager;
|
|
59
59
|
}
|
|
60
60
|
debug(message) {
|
|
61
61
|
this.instance.debug(message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coast/service-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Common service package",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.0.0"
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
"./*": {
|
|
10
10
|
"types": "./dist/lib/*.d.ts",
|
|
11
|
-
"import": "./dist/lib/*"
|
|
11
|
+
"import": "./dist/lib/*",
|
|
12
|
+
"require": "./dist/lib/*"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"typesVersions": {
|