@nest-boot/logger 7.3.7 → 8.0.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-boot/logger",
3
- "version": "7.3.7",
3
+ "version": "8.0.0-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nest-boot/nest-boot.git",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "homepage": "",
16
16
  "license": "MIT",
17
- "main": "dist/index.js",
18
- "types": "dist/index.d.ts",
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
19
  "directories": {
20
20
  "lib": "dist"
21
21
  },
@@ -23,40 +23,40 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "lodash": "^4.17.21",
26
+ "lodash-es": "^4.17.21",
27
27
  "pino": "^9.11.0",
28
28
  "pino-http": "^10.5.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@nestjs/common": "^11.1.11",
32
- "@nestjs/config": "^4.0.2",
33
- "@nestjs/core": "^11.1.11",
34
- "@nestjs/platform-express": "^11.1.11",
35
- "@nestjs/testing": "^11.1.11",
31
+ "@nestjs/common": "^12.0.1",
32
+ "@nestjs/config": "^12.0.0",
33
+ "@nestjs/core": "^12.0.1",
34
+ "@nestjs/platform-express": "^12.0.1",
35
+ "@nestjs/testing": "^12.0.1",
36
36
  "@types/express": "^5.0.3",
37
- "@types/jest": "^29.5.14",
38
- "@types/lodash": "^4.17.20",
39
- "@types/node": "^24.12.4",
37
+ "@types/lodash-es": "^4.17.12",
38
+ "@types/node": "^26.0.0",
39
+ "@vitest/coverage-v8": "^4.1.11",
40
40
  "eslint": "^9.39.3",
41
41
  "express": "^5.1.0",
42
- "jest": "^29.7.0",
43
42
  "reflect-metadata": "^0.2.2",
44
43
  "rxjs": "^7.8.2",
45
- "ts-jest": "^29.4.4",
46
- "typescript": "^5.9.3",
47
- "@nest-boot/eslint-config": "^7.3.5",
48
- "@nest-boot/eslint-plugin": "^7.2.5",
49
- "@nest-boot/request-context": "^7.7.6",
50
- "@nest-boot/tsconfig": "^7.3.5"
44
+ "typescript": "^6.0.3",
45
+ "vite-tsconfig-paths": "^5.1.4",
46
+ "vitest": "^4.1.11",
47
+ "@nest-boot/eslint-config": "^8.0.0-beta.1",
48
+ "@nest-boot/eslint-plugin": "^8.0.0-beta.1",
49
+ "@nest-boot/request-context": "^8.0.0-beta.1",
50
+ "@nest-boot/tsconfig": "^8.0.0-beta.1"
51
51
  },
52
52
  "peerDependencies": {
53
- "@nest-boot/request-context": "^7.4.3",
54
- "@nestjs/common": "^11.0.0",
55
- "@nestjs/config": "^4.0.0",
56
- "@nestjs/core": "^11.0.0",
53
+ "@nestjs/common": "^12.0.0",
54
+ "@nestjs/config": "^12.0.0",
55
+ "@nestjs/core": "^12.0.0",
57
56
  "express": "^5.0.0",
58
57
  "reflect-metadata": "^0.2.2",
59
- "rxjs": "^7.0.0"
58
+ "rxjs": "^7.0.0",
59
+ "@nest-boot/request-context": "^8.0.0-beta.1"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"
@@ -67,8 +67,16 @@
67
67
  "eslint --fix"
68
68
  ]
69
69
  },
70
- "volta": {
71
- "extends": "../../package.json"
70
+ "type": "module",
71
+ "engines": {
72
+ "node": ">=26.0.0"
73
+ },
74
+ "exports": {
75
+ ".": {
76
+ "types": "./dist/index.d.ts",
77
+ "import": "./dist/index.js"
78
+ },
79
+ "./package.json": "./package.json"
72
80
  },
73
81
  "scripts": {
74
82
  "build": "tsc -p tsconfig.build.json",
@@ -76,8 +84,10 @@
76
84
  "dev": "tsc -w -p tsconfig.build.json",
77
85
  "lint": "eslint \"{src,test}/**/*.ts\"",
78
86
  "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
79
- "test:watch": "jest --watch",
80
- "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
81
- "test:e2e": "jest --config test/jest-e2e.ts --runInBand"
87
+ "test:watch": "vitest",
88
+ "test:debug": "vitest --inspect-brk --no-file-parallelism",
89
+ "test:e2e": "vitest run --config ./vitest.config.e2e.ts",
90
+ "test": "vitest run",
91
+ "test:cov": "vitest run --coverage"
82
92
  }
83
93
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const testing_1 = require("@nestjs/testing");
4
- const rxjs_1 = require("rxjs");
5
- const logger_1 = require("./logger");
6
- const logger_interceptor_1 = require("./logger.interceptor");
7
- describe("LoggingInterceptor", () => {
8
- it("should assign route bindings for HTTP requests", async () => {
9
- function handler() {
10
- return undefined;
11
- }
12
- class TestController {
13
- }
14
- const assign = jest.fn();
15
- const handle = jest.fn(() => (0, rxjs_1.of)("ok"));
16
- const interceptor = await createInterceptor(assign);
17
- const next = {
18
- handle,
19
- };
20
- const context = {
21
- getClass: jest.fn(() => TestController),
22
- getHandler: jest.fn(() => handler),
23
- getType: jest.fn(() => "http"),
24
- switchToHttp: jest.fn(() => ({
25
- getRequest: () => ({
26
- route: {
27
- path: "/test",
28
- },
29
- }),
30
- })),
31
- };
32
- interceptor.intercept(context, next).subscribe();
33
- expect(assign).toHaveBeenCalledWith({
34
- route: {
35
- controller: "TestController",
36
- handler: "handler",
37
- path: "/test",
38
- },
39
- });
40
- expect(handle).toHaveBeenCalledTimes(1);
41
- });
42
- it("should skip route bindings for non-HTTP requests", async () => {
43
- const assign = jest.fn();
44
- const handle = jest.fn(() => (0, rxjs_1.of)("ok"));
45
- const interceptor = await createInterceptor(assign);
46
- const next = {
47
- handle,
48
- };
49
- const context = {
50
- getType: jest.fn(() => "rpc"),
51
- };
52
- interceptor.intercept(context, next);
53
- expect(assign).not.toHaveBeenCalled();
54
- expect(handle).toHaveBeenCalledTimes(1);
55
- });
56
- });
57
- async function createInterceptor(assign) {
58
- const moduleRef = await testing_1.Test.createTestingModule({
59
- providers: [
60
- logger_interceptor_1.LoggingInterceptor,
61
- {
62
- provide: logger_1.Logger,
63
- useValue: {
64
- assign,
65
- },
66
- },
67
- ],
68
- }).compile();
69
- return moduleRef.get(logger_interceptor_1.LoggingInterceptor);
70
- }
71
- //# sourceMappingURL=logger.interceptor.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.interceptor.spec.js","sourceRoot":"","sources":["../src/logger.interceptor.spec.ts"],"names":[],"mappings":";;AAAA,6CAAuC;AACvC,+BAA0B;AAE1B,qCAAkC;AAClC,6DAA0D;AAE1D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,SAAS,OAAO;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,cAAc;SAAG;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,IAAI,GAAG;YACX,MAAM;SACP,CAAC;QACF,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC;YACvC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;YAClC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;YAC9B,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;gBAC3B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;oBACjB,KAAK,EAAE;wBACL,IAAI,EAAE,OAAO;qBACd;iBACF,CAAC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MAAM;iBACP;aACF;SACF;KACF,CAAC,CAAC,OAAO,EAAE,CAAC;IAEb,OAAO,SAAS,CAAC,GAAG,CAAC,uCAAkB,CAAC,CAAC;AAC3C,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,277 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_context_1 = require("@nest-boot/request-context");
4
- const testing_1 = require("@nestjs/testing");
5
- const mockChildLogger = {
6
- ctx: "child",
7
- };
8
- const mockConfiguredPinoLogger = {
9
- child: jest.fn(() => mockChildLogger),
10
- };
11
- const mockPinoLogger = {
12
- child: jest.fn(() => mockChildLogger),
13
- };
14
- const mockPino = jest.fn(() => mockPinoLogger);
15
- const mockLoggerMiddleware = Object.assign(jest.fn((req) => {
16
- req.log = {
17
- child: jest.fn(() => mockChildLogger),
18
- };
19
- }), { logger: mockConfiguredPinoLogger });
20
- const mockPinoHttp = jest.fn(() => mockLoggerMiddleware);
21
- jest.mock("pino", () => ({
22
- __esModule: true,
23
- default: mockPino,
24
- }));
25
- jest.mock("pino-http", () => ({
26
- __esModule: true,
27
- default: mockPinoHttp,
28
- }));
29
- const logger_module_1 = require("./logger.module");
30
- const logger_module_definition_1 = require("./logger.module-definition");
31
- describe("LoggerModule", () => {
32
- afterEach(() => {
33
- jest.restoreAllMocks();
34
- jest.clearAllMocks();
35
- });
36
- it("should register synchronous and asynchronous options", () => {
37
- const options = {
38
- autoLogging: false,
39
- };
40
- const dynamicModule = logger_module_1.LoggerModule.register(options);
41
- const useFactory = () => options;
42
- const asyncModule = logger_module_1.LoggerModule.registerAsync({
43
- useFactory,
44
- });
45
- expect(dynamicModule.module).toBe(logger_module_1.LoggerModule);
46
- expect(dynamicModule.providers).toEqual(expect.arrayContaining([
47
- {
48
- provide: logger_module_definition_1.MODULE_OPTIONS_TOKEN,
49
- useValue: options,
50
- },
51
- ]));
52
- expect(asyncModule.providers).toEqual(expect.arrayContaining([
53
- {
54
- inject: [],
55
- provide: logger_module_definition_1.MODULE_OPTIONS_TOKEN,
56
- useFactory,
57
- },
58
- ]));
59
- });
60
- it("should expose only supported logger options", () => {
61
- expect(true).toBe(true);
62
- expect(true).toBe(true);
63
- expect(true).toBe(true);
64
- expect(true).toBe(true);
65
- expect(true).toBe(true);
66
- expect(true).toBe(true);
67
- expect(true).toBe(true);
68
- expect(true).toBe(true);
69
- expect(false).toBe(false);
70
- expect(false).toBe(false);
71
- expect(false).toBe(false);
72
- });
73
- it("should provide one configured pino-http middleware instance", async () => {
74
- const moduleRef = await testing_1.Test.createTestingModule({
75
- imports: [logger_module_1.LoggerModule.register({ enabled: false })],
76
- }).compile();
77
- expect(moduleRef.get(logger_module_definition_1.PINO_HTTP)).toBe(mockLoggerMiddleware);
78
- expect(mockPinoHttp).toHaveBeenCalledTimes(1);
79
- expect(mockPinoHttp).toHaveBeenCalledWith(expect.objectContaining({ enabled: false }));
80
- await moduleRef.close();
81
- });
82
- it("should ignore options outside the public whitelist at runtime", async () => {
83
- const customProps = jest.fn(() => ({ unsupported: true }));
84
- const customReceivedMessage = jest.fn(() => "unsupported-message");
85
- const moduleRef = await testing_1.Test.createTestingModule({
86
- imports: [
87
- logger_module_1.LoggerModule.register({
88
- customLevels: { audit: 35 },
89
- customProps,
90
- customReceivedMessage,
91
- enabled: false,
92
- level: "silent",
93
- transport: { target: "pino-pretty" },
94
- useOnlyCustomLevels: true,
95
- }),
96
- ],
97
- }).compile();
98
- const [options] = mockPinoHttp.mock.calls[0];
99
- expect(options.enabled).toBe(false);
100
- expect(options).not.toHaveProperty("customLevels");
101
- expect(options).not.toHaveProperty("level");
102
- expect(options).not.toHaveProperty("transport");
103
- expect(options).not.toHaveProperty("useOnlyCustomLevels");
104
- expect(options.customProps).not.toBe(customProps);
105
- expect(options.customReceivedMessage).not.toBe(customReceivedMessage);
106
- await moduleRef.close();
107
- });
108
- it("should create the configured middleware from asynchronous options", async () => {
109
- const useFactory = jest.fn(async () => {
110
- await Promise.resolve();
111
- return {
112
- enabled: false,
113
- timestamp: false,
114
- };
115
- });
116
- const moduleRef = await testing_1.Test.createTestingModule({
117
- imports: [logger_module_1.LoggerModule.registerAsync({ useFactory })],
118
- }).compile();
119
- expect(useFactory).toHaveBeenCalledTimes(1);
120
- expect(moduleRef.get(logger_module_definition_1.PINO_HTTP)).toBe(mockLoggerMiddleware);
121
- expect(mockPinoHttp).toHaveBeenCalledTimes(1);
122
- expect(mockPinoHttp).toHaveBeenCalledWith(expect.objectContaining({
123
- enabled: false,
124
- timestamp: false,
125
- }));
126
- await moduleRef.close();
127
- });
128
- it("should apply defaults while preserving supplied options", async () => {
129
- const genReqId = () => "custom-id";
130
- const ignore = () => false;
131
- const serializers = {
132
- secret: () => "hidden",
133
- };
134
- const module = await createLoggerModule({
135
- autoLogging: {
136
- ignore,
137
- },
138
- genReqId,
139
- serializers,
140
- timestamp: false,
141
- });
142
- const options = module.options;
143
- expect(options.redact).toEqual([
144
- "req.headers.authorization",
145
- "req.headers.cookie",
146
- ]);
147
- expect(options.autoLogging.ignore).toBe(ignore);
148
- expect(options.serializers).toBe(serializers);
149
- expect(options.timestamp).toBe(false);
150
- expect(options.genReqId).toBe(genReqId);
151
- expect(options.genReqId()).toBe("custom-id");
152
- expect(options.customReceivedMessage()).toBe("request received");
153
- expect(options.customProps()).toEqual({});
154
- });
155
- it("should configure default request id, props, and auto logging behavior", async () => {
156
- const module = await createLoggerModule();
157
- const options = module.options;
158
- jest.spyOn(request_context_1.RequestContext, "isActive").mockReturnValue(true);
159
- jest.spyOn(request_context_1.RequestContext, "get").mockReturnValue({
160
- tenantId: "tenant-1",
161
- });
162
- jest.spyOn(request_context_1.RequestContext, "id", "get").mockReturnValue("ctx-id");
163
- process.env.NODE_ENV = "test";
164
- expect(options.autoLogging.ignore({
165
- headers: {
166
- "x-logging": "false",
167
- },
168
- })).toBe(true);
169
- expect(options.autoLogging.ignore({
170
- headers: {},
171
- })).toBe(false);
172
- expect(options.genReqId()).toBe("ctx-id");
173
- expect(options.customProps()).toEqual({
174
- tenantId: "tenant-1",
175
- });
176
- });
177
- it("should cover fallback defaults for boolean auto logging and inactive context", async () => {
178
- const module = await createLoggerModule({
179
- autoLogging: false,
180
- });
181
- const options = module.options;
182
- jest.spyOn(request_context_1.RequestContext, "isActive").mockReturnValueOnce(false);
183
- jest
184
- .spyOn(request_context_1.RequestContext, "id", "get")
185
- .mockReturnValue(undefined);
186
- expect(options.autoLogging).toBe(false);
187
- expect(options.customProps()).toEqual({});
188
- expect(options.genReqId()).toEqual(expect.any(String));
189
- });
190
- it("should return empty custom props when bindings are not set", async () => {
191
- const module = await createLoggerModule();
192
- const options = module.options;
193
- jest.spyOn(request_context_1.RequestContext, "isActive").mockReturnValue(true);
194
- jest.spyOn(request_context_1.RequestContext, "get").mockReturnValue(undefined);
195
- expect(options.customProps()).toEqual({});
196
- });
197
- it("should emit decorator metadata when options exist at runtime", () => {
198
- jest.isolateModules(() => {
199
- jest.doMock("./logger-module-options.interface", () => {
200
- var _a;
201
- return ({
202
- LoggerModuleOptions: (_a = class LoggerModuleOptions {
203
- },
204
- _a.marker = true,
205
- _a),
206
- });
207
- });
208
- expect(jest.requireActual("./logger.module")
209
- .LoggerModule).toBeDefined();
210
- jest.dontMock("./logger-module-options.interface");
211
- });
212
- });
213
- it("should register pino logger middleware for requests", async () => {
214
- const module = await createLoggerModule();
215
- const registerMiddleware = jest
216
- .spyOn(request_context_1.RequestContext, "registerMiddleware")
217
- .mockImplementation();
218
- module.onModuleInit();
219
- const middleware = registerMiddleware.mock.calls[0][1];
220
- const req = {};
221
- const res = {};
222
- const ctx = {
223
- get: jest.fn((token) => {
224
- if (token === request_context_1.REQUEST)
225
- return req;
226
- if (token === request_context_1.RESPONSE)
227
- return res;
228
- return undefined;
229
- }),
230
- id: "ctx-id",
231
- set: jest.fn(),
232
- type: "http",
233
- };
234
- const next = jest.fn().mockResolvedValue("next-result");
235
- await expect(middleware(ctx, next)).resolves.toBe("next-result");
236
- expect(mockLoggerMiddleware).toHaveBeenCalledWith(req, res);
237
- expect(ctx.set).toHaveBeenCalledWith(logger_module_definition_1.PINO_LOGGER, mockChildLogger);
238
- });
239
- it("should use the configured pino logger without request objects", async () => {
240
- const module = await createLoggerModule();
241
- const registerMiddleware = jest
242
- .spyOn(request_context_1.RequestContext, "registerMiddleware")
243
- .mockImplementation();
244
- module.onModuleInit();
245
- const middleware = registerMiddleware.mock.calls[0][1];
246
- const ctx = {
247
- get: jest.fn(() => undefined),
248
- id: "ctx-id",
249
- set: jest.fn(),
250
- type: "job",
251
- };
252
- const next = jest.fn().mockResolvedValue("next-result");
253
- await expect(middleware(ctx, next)).resolves.toBe("next-result");
254
- expect(mockConfiguredPinoLogger.child).toHaveBeenCalledWith({
255
- ctx: {
256
- id: "ctx-id",
257
- type: "job",
258
- },
259
- });
260
- expect(mockPino).not.toHaveBeenCalled();
261
- expect(ctx.set).toHaveBeenCalledWith(logger_module_definition_1.PINO_LOGGER, mockChildLogger);
262
- });
263
- });
264
- async function createLoggerModule(options) {
265
- const providers = [logger_module_1.LoggerModule];
266
- if (typeof options !== "undefined") {
267
- providers?.push({
268
- provide: logger_module_definition_1.MODULE_OPTIONS_TOKEN,
269
- useValue: options,
270
- });
271
- }
272
- const moduleRef = await testing_1.Test.createTestingModule({
273
- providers,
274
- }).compile();
275
- return moduleRef.get(logger_module_1.LoggerModule);
276
- }
277
- //# sourceMappingURL=logger.module.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.module.spec.js","sourceRoot":"","sources":["../src/logger.module.spec.ts"],"names":[],"mappings":";;AAAA,gEAA+E;AAC/E,6CAAuC;AAEvC,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,OAAO;CACb,CAAC;AACF,MAAM,wBAAwB,GAAG;IAC/B,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC;CACtC,CAAC;AACF,MAAM,cAAc,GAAG;IACrB,KAAK,EAAE,IAAI,CAAC,EAAE,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AAI,CAAC,aAAa,CAAC,CAAC;QAE1E,MAAM,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC;YAC1D,GAAG,EAAE;gBACH,EAAE,EAAE,QAAQ;gBACZ,IAAI,EAAE,KAAK;aACZ;SACF,CAAC,CAAC;QACH,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,sCAAW,EAAE,eAAe,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,kBAAkB,CAAC,OAA6B;IAC7D,MAAM,SAAS,GACb,CAAC,4BAAY,CAAC,CAAC;IAEjB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,SAAS,EAAE,IAAI,CAAC;YACd,OAAO,EAAE,+CAAoB;YAC7B,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,cAAI,CAAC,mBAAmB,CAAC;QAC/C,SAAS;KACV,CAAC,CAAC,OAAO,EAAE,CAAC;IAEb,OAAO,SAAS,CAAC,GAAG,CAAC,4BAAY,CAAC,CAAC;AACrC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,164 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_context_1 = require("@nest-boot/request-context");
4
- const core_1 = require("@nestjs/core");
5
- const testing_1 = require("@nestjs/testing");
6
- const mockPinoLogger = {
7
- child: jest.fn(),
8
- debug: jest.fn(),
9
- error: jest.fn(),
10
- info: jest.fn(),
11
- trace: jest.fn(),
12
- warn: jest.fn(),
13
- };
14
- const mockPino = jest.fn(() => mockPinoLogger);
15
- const mockConfiguredPinoLogger = {
16
- debug: jest.fn(),
17
- error: jest.fn(),
18
- info: jest.fn(),
19
- trace: jest.fn(),
20
- warn: jest.fn(),
21
- };
22
- const mockLoggerMiddleware = {
23
- logger: mockConfiguredPinoLogger,
24
- };
25
- jest.mock("pino", () => ({
26
- __esModule: true,
27
- default: mockPino,
28
- }));
29
- const logger_1 = require("./logger");
30
- const logger_module_definition_1 = require("./logger.module-definition");
31
- class ParentService {
32
- }
33
- describe("Logger", () => {
34
- afterEach(() => {
35
- jest.restoreAllMocks();
36
- jest.clearAllMocks();
37
- });
38
- it("should default context to the parent class name and allow overriding it", async () => {
39
- const logger = await createLogger();
40
- expect(logger.getContext()).toBe("ParentService");
41
- logger.setContext("CustomContext");
42
- expect(logger.getContext()).toBe("CustomContext");
43
- });
44
- it("should merge bindings into request context", async () => {
45
- jest.spyOn(request_context_1.RequestContext, "get").mockReturnValue({
46
- requestId: "request-1",
47
- });
48
- const set = jest.spyOn(request_context_1.RequestContext, "set").mockImplementation();
49
- const logger = await createLogger();
50
- logger.assign({
51
- tenantId: "tenant-1",
52
- });
53
- expect(set).toHaveBeenCalledWith(logger_module_definition_1.BINDINGS, {
54
- requestId: "request-1",
55
- tenantId: "tenant-1",
56
- });
57
- });
58
- it("should assign bindings when request context has no existing bindings", async () => {
59
- jest.spyOn(request_context_1.RequestContext, "get").mockReturnValue(undefined);
60
- const set = jest.spyOn(request_context_1.RequestContext, "set").mockImplementation();
61
- const logger = await createLogger();
62
- logger.assign({
63
- tenantId: "tenant-1",
64
- });
65
- expect(set).toHaveBeenCalledWith(logger_module_definition_1.BINDINGS, {
66
- tenantId: "tenant-1",
67
- });
68
- });
69
- it("should log with the global pino logger when request context is inactive", async () => {
70
- jest.spyOn(request_context_1.RequestContext, "get").mockImplementation(() => {
71
- throw new Error("Request context is not active");
72
- });
73
- const logger = await createLogger();
74
- logger.verbose("trace message");
75
- logger.debug("debug message");
76
- logger.log("info message", { requestId: "request-1" }, "Override");
77
- logger.warn("warn message");
78
- logger.error("error message");
79
- expect(mockPino).toHaveBeenCalledTimes(1);
80
- expect(mockPinoLogger.trace).toHaveBeenCalledWith({
81
- context: "ParentService",
82
- }, "trace message");
83
- expect(mockPinoLogger.debug).toHaveBeenCalledWith({
84
- context: "ParentService",
85
- }, "debug message");
86
- expect(mockPinoLogger.info).toHaveBeenCalledWith({
87
- context: "Override",
88
- requestId: "request-1",
89
- }, "info message");
90
- expect(mockPinoLogger.warn).toHaveBeenCalledWith({
91
- context: "ParentService",
92
- }, "warn message");
93
- expect(mockPinoLogger.error).toHaveBeenCalledWith({
94
- context: "ParentService",
95
- }, "error message");
96
- });
97
- it("should use the module-configured logger when request context is inactive", async () => {
98
- jest.spyOn(request_context_1.RequestContext, "get").mockImplementation(() => {
99
- throw new Error("Request context is not active");
100
- });
101
- const logger = await createLogger(true);
102
- logger.log("configured message");
103
- expect(mockConfiguredPinoLogger.info).toHaveBeenCalledWith({
104
- context: "ParentService",
105
- }, "configured message");
106
- expect(mockPino).not.toHaveBeenCalled();
107
- });
108
- it("should log with request-scoped pino logger and bindings", async () => {
109
- const requestLogger = {
110
- warn: jest.fn(),
111
- };
112
- jest.spyOn(request_context_1.RequestContext, "get").mockImplementation((token) => {
113
- if (token === logger_module_definition_1.PINO_LOGGER)
114
- return requestLogger;
115
- if (token === logger_module_definition_1.BINDINGS) {
116
- return {
117
- requestId: "request-1",
118
- };
119
- }
120
- return undefined;
121
- });
122
- const logger = await createLogger();
123
- logger.warn("warn message");
124
- expect(requestLogger.warn).toHaveBeenCalledWith({
125
- context: "ParentService",
126
- requestId: "request-1",
127
- }, "warn message");
128
- });
129
- it("should log with empty bindings when request context has no bindings", async () => {
130
- const requestLogger = {
131
- debug: jest.fn(),
132
- };
133
- jest.spyOn(request_context_1.RequestContext, "get").mockImplementation((token) => {
134
- if (token === logger_module_definition_1.PINO_LOGGER)
135
- return requestLogger;
136
- return undefined;
137
- });
138
- const logger = await createLogger();
139
- logger.debug("debug message");
140
- expect(requestLogger.debug).toHaveBeenCalledWith({
141
- context: "ParentService",
142
- }, "debug message");
143
- });
144
- });
145
- async function createLogger(configured = false) {
146
- const providers = [
147
- logger_1.Logger,
148
- {
149
- provide: core_1.INQUIRER,
150
- useValue: new ParentService(),
151
- },
152
- ];
153
- if (configured) {
154
- providers?.push({
155
- provide: logger_module_definition_1.PINO_HTTP,
156
- useValue: mockLoggerMiddleware,
157
- });
158
- }
159
- const moduleRef = await testing_1.Test.createTestingModule({
160
- providers,
161
- }).compile();
162
- return await moduleRef.resolve(logger_1.Logger);
163
- }
164
- //# sourceMappingURL=logger.spec.js.map