@nathapp/nestjs-logging 2.1.5 → 3.0.0-rc.4

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.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +37 -0
  3. package/dist/config/config.resolver.js +26 -7
  4. package/dist/config/config.resolver.js.map +1 -1
  5. package/dist/config/logging.config.js +1 -1
  6. package/dist/config/logging.config.js.map +1 -1
  7. package/dist/constant/logging.constant.js +12 -0
  8. package/dist/constant/logging.constant.js.map +1 -1
  9. package/dist/interceptor/logging.interceptor.d.ts +0 -1
  10. package/dist/interceptor/logging.interceptor.js +20 -16
  11. package/dist/interceptor/logging.interceptor.js.map +1 -1
  12. package/dist/module/logging.interface.d.ts +1 -1
  13. package/dist/module/logging.module.d.ts +6 -3
  14. package/dist/module/logging.module.js +12 -4
  15. package/dist/module/logging.module.js.map +1 -1
  16. package/dist/provider/default-logger.service.d.ts +3 -2
  17. package/dist/provider/default-logger.service.js +2 -0
  18. package/dist/provider/default-logger.service.js.map +1 -1
  19. package/dist/provider/logger.service.d.ts +7 -3
  20. package/dist/provider/logger.service.js +0 -7
  21. package/dist/provider/logger.service.js.map +1 -1
  22. package/dist/provider/pino-logger.service.d.ts +3 -2
  23. package/dist/provider/pino-logger.service.js +5 -0
  24. package/dist/provider/pino-logger.service.js.map +1 -1
  25. package/dist/provider/provider.interface.d.ts +4 -15
  26. package/dist/provider/winston-logger.service.d.ts +4 -2
  27. package/dist/provider/winston-logger.service.js +36 -1
  28. package/dist/provider/winston-logger.service.js.map +1 -1
  29. package/dist/serialize/serializer.d.ts +21 -1
  30. package/dist/serialize/serializer.js +8 -1
  31. package/dist/serialize/serializer.js.map +1 -1
  32. package/dist/util/file-rotation.utils.d.ts +1 -1
  33. package/dist/util/file-rotation.utils.js +2 -4
  34. package/dist/util/file-rotation.utils.js.map +1 -1
  35. package/dist/util/options.util.d.ts +5 -5
  36. package/dist/util/options.util.js.map +1 -1
  37. package/docs/20260215-fix-plan-logging.md +177 -0
  38. package/docs/20260215-review-logging-deep.md +264 -0
  39. package/docs/20260215-test-plan-logging.md +37 -0
  40. package/package.json +3 -3
@@ -22,8 +22,9 @@ class WinstonLoggerService extends logger_service_1.Logger {
22
22
  transports.push(consoleTransport);
23
23
  }
24
24
  if ((_c = options.file) === null || _c === void 0 ? void 0 : _c.enabled) {
25
+ this.fileStream = (0, util_1.createRotatingStream)(options.file);
25
26
  const fileTransport = new winston.transports.Stream({
26
- stream: (0, util_1.createRotatingStream)(options.file),
27
+ stream: this.fileStream,
27
28
  });
28
29
  transports.push(fileTransport);
29
30
  }
@@ -82,6 +83,40 @@ class WinstonLoggerService extends logger_service_1.Logger {
82
83
  const contextData = this.getContext();
83
84
  this.logger[level]({ ...contextData, ...meta, message, level });
84
85
  }
86
+ async onModuleDestroy() {
87
+ return new Promise((resolve) => {
88
+ if (!this.logger) {
89
+ resolve();
90
+ return;
91
+ }
92
+ let finished = false;
93
+ const timeout = setTimeout(() => {
94
+ if (!finished) {
95
+ finished = true;
96
+ if (this.fileStream) {
97
+ this.fileStream.end();
98
+ }
99
+ resolve();
100
+ }
101
+ }, 2000);
102
+ const cleanup = () => {
103
+ if (!finished) {
104
+ finished = true;
105
+ clearTimeout(timeout);
106
+ if (this.fileStream) {
107
+ this.fileStream.end();
108
+ }
109
+ resolve();
110
+ }
111
+ };
112
+ this.logger.on('finish', cleanup);
113
+ this.logger.on('error', (err) => {
114
+ console.warn('[nestjs-logging] Error during Winston logger cleanup:', err.message);
115
+ cleanup();
116
+ });
117
+ this.logger.close();
118
+ });
119
+ }
85
120
  }
86
121
  exports.WinstonLoggerService = WinstonLoggerService;
87
122
  //# sourceMappingURL=winston-logger.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"winston-logger.service.js","sourceRoot":"","sources":["../../lib/provider/winston-logger.service.ts"],"names":[],"mappings":";;;AACA,8EAAqE;AACrE,qDAA0C;AAC1C,kCAAiE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AE,CAAC;oBACxB,CAAC;oBACD,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC;YAEF,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAQ,EAAE,EAAE;gBACnC,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;gBACnF,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAGH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5ID,oDA4IC"}
@@ -1,4 +1,24 @@
1
1
  import { LoggerHttpMeta } from "../provider";
2
2
  export type SerializeFunction = (meta: LoggerHttpMeta) => Record<string, any>;
3
3
  export type FormatterFunction = (meta: LoggerHttpMeta) => string;
4
- export declare function defaultSerializer(meta: LoggerHttpMeta): Record<string, any>;
4
+ export interface SerializedLogMetadata {
5
+ req: {
6
+ headers?: Record<string, string>;
7
+ userAgent?: string;
8
+ data?: Record<string, any>;
9
+ query?: Record<string, any>;
10
+ params?: Record<string, any>;
11
+ body?: Record<string, any>;
12
+ clientIp?: string;
13
+ method?: string;
14
+ url?: string;
15
+ };
16
+ res: {
17
+ statusCode?: number;
18
+ data?: Record<string, any>;
19
+ responseTime?: number;
20
+ error?: Record<string, any>;
21
+ };
22
+ stack?: string;
23
+ }
24
+ export declare function defaultSerializer(meta: LoggerHttpMeta): SerializedLogMetadata;
@@ -2,11 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultSerializer = defaultSerializer;
4
4
  function defaultSerializer(meta) {
5
- return {
5
+ const result = {
6
6
  req: {
7
7
  headers: meta.headers,
8
8
  userAgent: meta.userAgent,
9
9
  data: meta.requestData,
10
+ query: meta.query,
11
+ params: meta.params,
12
+ body: meta.body,
10
13
  clientIp: meta.clientIp,
11
14
  method: meta.method,
12
15
  url: meta.url,
@@ -18,5 +21,9 @@ function defaultSerializer(meta) {
18
21
  error: meta.error,
19
22
  },
20
23
  };
24
+ if (meta.stack) {
25
+ result.stack = meta.stack;
26
+ }
27
+ return result;
21
28
  }
22
29
  //# sourceMappingURL=serializer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../lib/serialize/serializer.ts"],"names":[],"mappings":";;AAMA,8CAiBC;AAjBD,SAAgB,iBAAiB,CAAC,IAAoB;IACpD,OAAO;QACL,GAAG,EAAE;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,YAAY;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;KACF,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../lib/serialize/serializer.ts"],"names":[],"mappings":";;AAwGA,8CA6BC;AA7BD,SAAgB,iBAAiB,CAAC,IAAoB;IACpD,MAAM,MAAM,GAA0B;QACpC,GAAG,EAAE;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd;QACD,GAAG,EAAE;YACH,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,YAAY;YAGvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;KACF,CAAC;IAGF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { Writable } from 'stream';
2
2
  import { FileLoggingOptions } from '../module/logging.interface';
3
- export declare const createRotatingStream: (options: FileLoggingOptions) => Writable;
3
+ export declare const createRotatingStream: (options: Partial<FileLoggingOptions>) => Writable;
@@ -28,10 +28,8 @@ const createRotatingStream = (options) => {
28
28
  const opt = Object.assign({}, defaultOptions, options);
29
29
  const { filename, datePattern, maxFiles, zippedArchive, interval, size, encoding, path: dir } = opt;
30
30
  const filenameGenerator = (time, index) => {
31
- if (!time) {
32
- return filename.replace('-%DATE%', '');
33
- }
34
- const formattedDate = formatDate(time, datePattern);
31
+ const actualTime = time || new Date();
32
+ const formattedDate = formatDate(actualTime, datePattern);
35
33
  const fn = filename.replace('%DATE%', formattedDate) + (index > 0 ? `-${index}` : '');
36
34
  return fn;
37
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"file-rotation.utils.js","sourceRoot":"","sources":["../../lib/util/file-rotation.utils.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AAKzB,MAAM,cAAc,GAAuB;IACzC,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,wBAAwB;IAClC,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,YAAY;IACzB,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,IAA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;QAEtD,MAAM,UAAU,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAEtC,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC1D,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtF,OAAO,EAAE,CAAC;IACZ,CAAC,CAAA;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;IAC7C,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAG1C,MAAM,GAAG,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAE5C,MAAM,UAAU,GAAG;QACjB,IAAI;QACJ,QAAQ;QACR,QAAQ;QACR,QAAQ,EAAE,aAAa;QACvB,QAAQ;QACR,IAAI,EAAE,MAAM;KACb,CAAA;IAID,IAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,CAAC,YAAY,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAA;AACxD,CAAC,CAAA;AApCY,QAAA,oBAAoB,wBAoChC"}
@@ -1,6 +1,6 @@
1
1
  import { ConsoleLoggerOptions, LogLevel } from "@nestjs/common";
2
2
  import { CentralizedLoggingOptions, LoggerLevel, LoggingModuleOptions } from "../module";
3
- import { DefaultLoggerOptions, PinoLoggerOptions, WinstonLoggerOptions } from "../provider";
3
+ import { LoggerProviderOptions } from "../provider";
4
4
  export declare const PinoLogLevelMaps: {
5
5
  fatal: string;
6
6
  error: string;
@@ -36,8 +36,8 @@ export declare const WinstonLogLevelMaps: {
36
36
  verbose: string;
37
37
  };
38
38
  export declare const resolveCentrilizedOptions: (options: LoggingModuleOptions) => CentralizedLoggingOptions;
39
- export declare const resolvePinoOptions: (options: LoggingModuleOptions) => PinoLoggerOptions;
40
- export declare const resolveWinstonOptions: (options: LoggingModuleOptions) => WinstonLoggerOptions;
41
- export declare const resolveDefaultLoggerOptions: (options: LoggingModuleOptions) => DefaultLoggerOptions;
39
+ export declare const resolvePinoOptions: (options: LoggingModuleOptions) => LoggerProviderOptions;
40
+ export declare const resolveWinstonOptions: (options: LoggingModuleOptions) => LoggerProviderOptions;
41
+ export declare const resolveDefaultLoggerOptions: (options: LoggingModuleOptions) => LoggerProviderOptions;
42
42
  export declare const resolveNestLogLevel: (level: LoggerLevel | string) => LogLevel[];
43
- export declare const resolveConsoleOptions: (options: LoggingModuleOptions | DefaultLoggerOptions) => ConsoleLoggerOptions;
43
+ export declare const resolveConsoleOptions: (options: LoggingModuleOptions | LoggerProviderOptions) => ConsoleLoggerOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"options.util.js","sourceRoot":"","sources":["../../lib/util/options.util.ts"],"names":[],"mappings":";;;AAKa,QAAA,gBAAgB,GAAG;IAC9B,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,OAAO;CACjB,CAAA;AAEY,QAAA,oBAAoB,GAAG;IAClC,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,OAAO;IACX,EAAE,EAAE,OAAO;CACZ,CAAA;AAGY,QAAA,gBAAgB,GAAG;IAC9B,MAAM,EAAE;QACN,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,OAAO,EA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AE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACtD,KAAK,OAAO,CAAC;QACb,KAAK,SAAS;YACV,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACjE;YACI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;AACL,CAAC,CAAA;AAlBY,QAAA,mBAAmB,uBAkB/B;AAEM,MAAM,qBAAqB,GAAG,CAAC,OAAqD,EAAwB,EAAE;;IACnH,OAAO;QACL,SAAS,EAAE,IAAA,2BAAmB,EAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,MAAM,CAAC;QACvD,IAAI,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,mCAAI,KAAK;KACrC,CAAC;AACJ,CAAC,CAAA;AALY,QAAA,qBAAqB,yBAKjC"}
@@ -0,0 +1,177 @@
1
+ # Fix Plan: nestjs-logging Enterprise Upgrade
2
+
3
+ **Date:** 2026-02-15
4
+ **Branch:** feat/monorepo-enterprise-upgrade
5
+ **Review:** `docs/20260215-review-logging-deep.md`
6
+ **Package:** `packages/nestjs-logging`
7
+
8
+ ---
9
+
10
+ ## Phase 1: Critical Security & Memory Fixes (P0)
11
+
12
+ ### Fix 1: SEC-1 — JSON.parse crash on malformed env vars
13
+ **File:** `lib/config/config.resolver.ts`
14
+ **Impact:** App crashes at startup if LOGGING_CENTRALIZED_LABELS or LOGGING_CENTRALIZED_HEADERS env vars contain malformed JSON.
15
+ **Change:**
16
+ - Wrap both `JSON.parse()` calls (lines 27 and 96) in try/catch blocks.
17
+ - On parse failure, log a warning to stderr and fall back to empty object `{}`.
18
+ - Example:
19
+ ```typescript
20
+ let additionalLabels = {};
21
+ try {
22
+ additionalLabels = process.env.LOGGING_CENTRALIZED_LABELS
23
+ ? JSON.parse(process.env.LOGGING_CENTRALIZED_LABELS)
24
+ : {};
25
+ } catch (e) {
26
+ console.warn('[nestjs-logging] Failed to parse LOGGING_CENTRALIZED_LABELS, using empty object:', e.message);
27
+ }
28
+ ```
29
+
30
+ ### Fix 2: SEC-2 — fast-redact mutates original request objects
31
+ **File:** `lib/interceptor/logging.interceptor.ts`
32
+ **Impact:** `fast-redact` with `serialize: false` mutates input objects in place. Original `req.body`, `req.query`, `req.headers` get their sensitive fields permanently replaced with `[REDACTED]`, corrupting data for downstream handlers.
33
+ **Change:**
34
+ - Clone objects before passing to `this.redact()`:
35
+ ```typescript
36
+ metadata.requestData = this.redact(structuredClone(body));
37
+ ```
38
+ - Apply to all redact calls: query (line 77), params (line 80), body (line 83), headers (line 87), error response (line 97), response (line 104).
39
+
40
+ ### Fix 3: SEC-3 — requestData overwritten (query → params → body)
41
+ **File:** `lib/interceptor/logging.interceptor.ts`
42
+ **Impact:** Only the last non-empty source is logged. Query params silently lost when body exists.
43
+ **Change:**
44
+ - Split into separate fields on metadata:
45
+ ```typescript
46
+ if (query && !isUndefinedOrNullOrEmpty(query)) {
47
+ metadata.query = this.redact(structuredClone(query));
48
+ }
49
+ if (params && !isUndefinedOrNullOrEmpty(params)) {
50
+ metadata.params = this.redact(structuredClone(params));
51
+ }
52
+ if (body && !isUndefinedOrNullOrEmpty(body)) {
53
+ metadata.body = this.redact(structuredClone(body));
54
+ }
55
+ ```
56
+ - Update `LoggerHttpMeta` interface to add `query?`, `params?`, `body?` fields. Keep `requestData?` as deprecated for backward compat.
57
+ - Update `defaultSerializer` in `lib/serialize/serializer.ts` to include the new fields.
58
+
59
+ ### Fix 4: MEM-1 — Transport cleanup on module destroy
60
+ **Files:** `lib/provider/winston-logger.service.ts`, `lib/provider/pino-logger.service.ts`, `lib/provider/default-logger.service.ts`, `lib/provider/logger.service.ts`
61
+ **Impact:** On module destroy / hot reload, transports (Loki HTTP connections, file streams, pino worker threads) stay alive, leaking memory and file handles.
62
+ **Change:**
63
+ - Add `OnModuleDestroy` interface to the abstract `Logger` class.
64
+ - Implement `async onModuleDestroy()` in each provider:
65
+ - **Winston:** Call `this.logger.close()` and wait for 'finish' event.
66
+ - **Pino:** Call `this.logger.flush()` then end the destination/transport.
67
+ - **Default:** No-op (ConsoleLogger has no cleanup needed).
68
+ - Store reference to rotating file streams in WinstonLoggerService for explicit cleanup.
69
+
70
+ ### Fix 5: MEM-2 — Rotating file stream reference
71
+ **File:** `lib/util/file-rotation.utils.ts` (no change needed — the stream is returned)
72
+ **Files:** `lib/provider/winston-logger.service.ts`, `lib/provider/pino-logger.service.ts`
73
+ **Impact:** File handles leak on shutdown.
74
+ **Change:** Already addressed by Fix 4 — the stream is returned from `createRotatingStream()` and the providers need to store and close it in `onModuleDestroy()`.
75
+
76
+ ---
77
+
78
+ ## Phase 2: Medium Bug Fixes & Quality (P1)
79
+
80
+ ### Fix 6: ENH-7 — Race condition on `this.context` in interceptor
81
+ **File:** `lib/interceptor/logging.interceptor.ts`
82
+ **Impact:** Concurrent requests overwrite each other's class context name.
83
+ **Change:**
84
+ - Remove `private context: string;` instance field.
85
+ - Pass context as a local variable through the pipe chain:
86
+ ```typescript
87
+ const context = executionContext.getClass().name || executionContext.constructor.name;
88
+ ```
89
+ - Pass `context` to `this.log()` instead of using `this.context`.
90
+
91
+ ### Fix 7: ENH-2 — Error stack traces not logged
92
+ **File:** `lib/interceptor/logging.interceptor.ts`
93
+ **Impact:** Production errors show status code but not stack trace.
94
+ **Change:**
95
+ - In the `catchError` handler, add:
96
+ ```typescript
97
+ if (error?.stack) {
98
+ metadata.stack = error.stack;
99
+ }
100
+ ```
101
+ - Add `stack?: string` to `LoggerHttpMeta` interface.
102
+
103
+ ### Fix 8: BUG-1 — NaN maxFiles
104
+ **File:** `lib/config/config.resolver.ts`
105
+ **Impact:** `parseInt(undefined)` returns NaN, potentially breaking file rotation.
106
+ **Change:**
107
+ ```typescript
108
+ maxFiles: process.env.LOGGING_FILE_MAX_FILES
109
+ ? parseInt(process.env.LOGGING_FILE_MAX_FILES, 10)
110
+ : undefined,
111
+ ```
112
+
113
+ ### Fix 9: PERF-1 — Double hrtime call
114
+ **File:** `lib/interceptor/logging.interceptor.ts`
115
+ **Impact:** Incorrect timing measurement.
116
+ **Change:**
117
+ ```typescript
118
+ const diff = process.hrtime(startAt);
119
+ metadata.responseTime = Number((diff[0] * 1e3 + diff[1] * 1e-6).toFixed(2));
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Phase 3: Cleanup & Polish (P2)
125
+
126
+ ### Fix 10: BUG-2 — basicAuth password validation
127
+ **File:** `lib/config/config.resolver.ts`
128
+ **Change:** Warn if username is set but password is missing. Still create the object (some systems allow empty password).
129
+
130
+ ### Fix 11: BUG-3 — Dead enrichContext method
131
+ **File:** `lib/provider/logger.service.ts`
132
+ **Change:** Remove `enrichContext()` — it's never called and returns an empty object.
133
+
134
+ ### Fix 12: ENH-5 — Wrong validator on LOGGING_TYPE
135
+ **File:** `lib/config/logging.config.ts`
136
+ **Change:** Replace `@IsBooleanString()` with `@IsOptional() @IsIn(['default', 'pino', 'winston'])`.
137
+
138
+ ### Fix 13: ENH-6 — Deduplicate provider interfaces
139
+ **File:** `lib/provider/provider.interface.ts`
140
+ **Change:** Replace three identical interfaces with a single `LoggerProviderOptions`.
141
+
142
+ ### Fix 14: TYPE-2 — Fix factory interface
143
+ **File:** `lib/module/logging.interface.ts`
144
+ **Change:** Add optional `AdditionalFactoryOptions` param to `LoggingModuleOptionsFactory.createOptions()`.
145
+
146
+ ### Fix 15: STYLE-1 — Typo "middlwareOptions"
147
+ **File:** `lib/module/logging.module.ts`
148
+ **Change:** Rename to `middlewareOptions`.
149
+
150
+ ### Fix 16: STYLE-3 — Remove TODO comment
151
+ **File:** `lib/provider/default-logger.service.ts`
152
+ **Change:** Replace TODO with `@design` remark or remove entirely.
153
+
154
+ ---
155
+
156
+ ## Test Strategy
157
+
158
+ - **Mode:** hybrid
159
+ - **TDD targets (test-first):**
160
+ - SEC-2: fast-redact cloning (verify original objects are not mutated)
161
+ - MEM-1: OnModuleDestroy cleanup (verify transports are closed)
162
+ - SEC-3: Request data separation (verify query, params, body logged independently)
163
+ - ENH-7: Concurrent request context (verify no race condition)
164
+ - **Test-after targets:**
165
+ - SEC-1: JSON.parse safety (config resolver tests)
166
+ - BUG-1: NaN maxFiles (config resolver tests)
167
+ - ENH-2: Error stack trace logging
168
+ - Serializer tests
169
+ - File rotation utility tests
170
+
171
+ ---
172
+
173
+ ## Commits
174
+
175
+ - Phase 1: `fix(nestjs-logging): critical security and memory leak fixes [SEC-1,SEC-2,SEC-3,MEM-1,MEM-2]`
176
+ - Phase 2: `fix(nestjs-logging): bug fixes and quality improvements [ENH-2,ENH-7,BUG-1,PERF-1]`
177
+ - Phase 3: `refactor(nestjs-logging): cleanup, dedup, and polish [BUG-2,BUG-3,ENH-5,ENH-6,TYPE-2,STYLE-*]`
@@ -0,0 +1,264 @@
1
+ # Deep Code Review: @nathapp/nestjs-logging
2
+
3
+ **Date:** 2026-02-15
4
+ **Reviewer:** Subrina (AI)
5
+ **Version:** 2.1.5
6
+ **Branch:** feat/monorepo-enterprise-upgrade
7
+ **Files:** 35 (lib: ~1480 LOC, test: ~380 LOC)
8
+ **Baseline:** 21 tests, 3 test files, 0% coverage reported (jest config issue)
9
+
10
+ ---
11
+
12
+ ## Overall Grade: C+ (72/100)
13
+
14
+ The package provides a solid multi-provider logging abstraction (default/pino/winston) with request context, auto-logging interceptor, and centralized logging support. However, it has significant issues in security, memory safety, type safety, and test coverage.
15
+
16
+ ---
17
+
18
+ ## Findings
19
+
20
+ ### 🔴 CRITICAL
21
+
22
+ #### SEC-1: JSON.parse on env vars without try/catch (config.resolver.ts:27, 96)
23
+ **Severity:** CRITICAL | **Category:** Security/Stability
24
+ ```typescript
25
+ // Line 27 - crashes if malformed
26
+ const additionalLabels = process.env.LOGGING_CENTRALIZED_LABELS
27
+ ? JSON.parse(process.env.LOGGING_CENTRALIZED_LABELS)
28
+ : {};
29
+
30
+ // Line 96 - crashes if malformed
31
+ headers: process.env.LOGGING_CENTRALIZED_HEADERS
32
+ ? JSON.parse(process.env.LOGGING_CENTRALIZED_HEADERS)
33
+ : {},
34
+ ```
35
+ **Risk:** Malformed JSON in an environment variable will crash the entire application at startup. No error handling, no fallback.
36
+ **Fix:** Wrap in try/catch, log a warning, and fall back to empty object.
37
+
38
+ #### SEC-2: fast-redact mutates objects in place (logging.interceptor.ts:76-87)
39
+ **Severity:** CRITICAL | **Category:** Security/Data Corruption
40
+ ```typescript
41
+ if (body && !isUndefinedOrNullOrEmpty(body)) {
42
+ metadata.requestData = this.redact(body); // MUTATES the original request body!
43
+ }
44
+ ```
45
+ **Risk:** `fast-redact` with `serialize: false` **mutates the original object**. This means the actual `req.body` gets its sensitive fields permanently replaced with `[REDACTED]`, breaking downstream handlers, validation pipes, and any middleware that reads the body after the interceptor.
46
+ **Fix:** Clone before redacting: `this.redact(structuredClone(body))` or use `serialize: (value) => JSON.parse(JSON.stringify(value))`.
47
+
48
+ #### MEM-1: Winston/Pino transports never destroyed (winston-logger.service.ts, pino-logger.service.ts)
49
+ **Severity:** CRITICAL | **Category:** Memory Leak
50
+ Neither `WinstonLoggerService` nor `PinoLoggerService` implements `OnModuleDestroy`. When the module is destroyed (hot reload, graceful shutdown):
51
+ - Winston Loki transport keeps HTTP connections open
52
+ - Pino Loki transport keeps batching timers alive
53
+ - Rotating file streams keep file handles open
54
+ - Pino worker threads stay alive
55
+
56
+ **Fix:** Implement `OnModuleDestroy` on both services. Call `winston.close()`, `pino.destination.end()`, or equivalent cleanup.
57
+
58
+ #### MEM-2: Rotating file stream never closed (file-rotation.utils.ts)
59
+ **Severity:** CRITICAL | **Category:** Memory Leak
60
+ ```typescript
61
+ export const createRotatingStream = (options: FileLoggingOptions): Writable => {
62
+ // Creates a stream but there's no cleanup mechanism
63
+ return rfs.createStream(filenameGenerator, rfsOptions);
64
+ }
65
+ ```
66
+ The rotating file stream is created but never stored in a way that allows cleanup. On app shutdown or hot reload, file handles leak.
67
+
68
+ #### SEC-3: requestData overwritten by params then body (logging.interceptor.ts:76-83)
69
+ **Severity:** HIGH | **Category:** Bug
70
+ ```typescript
71
+ if (query && !isUndefinedOrNullOrEmpty(query)) {
72
+ metadata.requestData = this.redact(query); // set to query
73
+ }
74
+ if (params && !isUndefinedOrNullOrEmpty(params)) {
75
+ metadata.requestData = this.redact(params); // OVERWRITTEN by params
76
+ }
77
+ if (body && !isUndefinedOrNullOrEmpty(body)) {
78
+ metadata.requestData = this.redact(body); // OVERWRITTEN by body
79
+ }
80
+ ```
81
+ Only the last non-empty source wins. If a request has both query params and a body, only the body is logged. Query and params data is silently lost.
82
+ **Fix:** Use separate fields: `metadata.query`, `metadata.params`, `metadata.body`.
83
+
84
+ ---
85
+
86
+ ### 🟡 MEDIUM
87
+
88
+ #### BUG-1: `file.maxFiles` is NaN when env var is not set (config.resolver.ts:87)
89
+ **Severity:** MEDIUM | **Category:** Bug
90
+ ```typescript
91
+ maxFiles: parseInt(process.env.LOGGING_FILE_MAX_FILES), // NaN if undefined
92
+ ```
93
+ `parseInt(undefined)` returns `NaN`. This gets passed to the file rotation library and may cause unexpected behavior.
94
+ **Fix:** `parseInt(process.env.LOGGING_FILE_MAX_FILES) || undefined`
95
+
96
+ #### BUG-2: `basicAuth.password` can be undefined (config.resolver.ts:48-52)
97
+ **Severity:** MEDIUM | **Category:** Bug
98
+ ```typescript
99
+ if(basicAuthUsername) {
100
+ basicAuth = {
101
+ username: basicAuthUsername,
102
+ password: basicAuthPassword // undefined if env var not set
103
+ }
104
+ }
105
+ ```
106
+ If username is set but password isn't, the basicAuth object has `password: undefined`, which may cause authentication failures at the Loki endpoint.
107
+ **Fix:** Require both or neither. Warn if only one is set.
108
+
109
+ #### BUG-3: `enrichContext` always returns empty object (logger.service.ts:57-63)
110
+ **Severity:** MEDIUM | **Category:** Dead Code
111
+ ```typescript
112
+ protected enrichContext(meta: Record<string, any>) {
113
+ if(this.contextService && !isUndefinedOrNullOrEmpty(meta)) {
114
+ this.contextService.updateContext(meta)
115
+ }
116
+ return {} // Always returns empty - what's the point?
117
+ }
118
+ ```
119
+ This method updates context as a side effect but always returns `{}`. It's never called from any subclass either. Dead code that indicates an incomplete feature.
120
+
121
+ #### TYPE-1: Logger services not typed (pino-logger.service.ts:24, winston-logger.service.ts:12)
122
+ **Severity:** MEDIUM | **Category:** Type Safety
123
+ ```typescript
124
+ private readonly logger: any; // Both Pino and Winston loggers are typed as `any`
125
+ ```
126
+ **Fix:** Use proper types: `import pino from 'pino'` → `pino.Logger`, or at minimum define a minimal interface.
127
+
128
+ #### TYPE-2: LoggingModuleOptionsFactory missing AdditionalFactoryOptions param (logging.interface.ts:89)
129
+ **Severity:** MEDIUM | **Category:** API Inconsistency
130
+ ```typescript
131
+ export interface LoggingModuleOptionsFactory {
132
+ createOptions(): Promise<LoggingModuleOptions> | LoggingModuleOptions;
133
+ }
134
+ ```
135
+ But `DefaultLoggingModuleOptionsFactory` implements:
136
+ ```typescript
137
+ createOptions(options?: AdditionalFactoryOptions): LoggingModuleOptions
138
+ ```
139
+ The interface doesn't declare the optional parameter.
140
+
141
+ #### PERF-1: process.hrtime called twice in log() (logging.interceptor.ts:103)
142
+ **Severity:** LOW | **Category:** Performance
143
+ ```typescript
144
+ metadata.responseTime = Number(
145
+ (process.hrtime(startAt)[0] * 1e3 + process.hrtime(startAt)[1] * 1e-6).toFixed(2)
146
+ );
147
+ ```
148
+ `process.hrtime(startAt)` is called twice, giving slightly different values for seconds and nanoseconds. Should capture once:
149
+ ```typescript
150
+ const diff = process.hrtime(startAt);
151
+ metadata.responseTime = Number((diff[0] * 1e3 + diff[1] * 1e-6).toFixed(2));
152
+ ```
153
+
154
+ #### ENH-1: Default redact paths only go 3 levels deep (logging.constant.ts)
155
+ **Severity:** MEDIUM | **Category:** Security
156
+ ```typescript
157
+ 'password', '*.password', '*.*.password' // Only 3 levels
158
+ ```
159
+ Nested objects deeper than 3 levels won't be redacted. This is a common surprise for developers.
160
+ **Fix:** Use `fast-redact` wildcard patterns if supported, or document the limitation clearly. Consider adding `**.password` style patterns.
161
+
162
+ #### ENH-2: No structured error logging (interceptor catches error but loses context)
163
+ **Severity:** MEDIUM | **Category:** Best Practice
164
+ ```typescript
165
+ catchError(async (error: any) => {
166
+ metadata.statusCode = error?.status || 500;
167
+ if(this.loggingOptions.error) {
168
+ const errorResponse = error?.response;
169
+ metadata.error = typeof errorResponse === 'object' ? ... : errorResponse;
170
+ }
171
+ // Stack trace is NOT captured!
172
+ this.log(metadata, 'error', startAt);
173
+ throw error;
174
+ })
175
+ ```
176
+ The error stack trace is never logged. In production, you get "500 Internal Server Error" but not where it happened.
177
+ **Fix:** Add `metadata.stack = error?.stack` when error logging is enabled.
178
+
179
+ #### ENH-3: No `onApplicationShutdown` or graceful drain
180
+ **Severity:** MEDIUM | **Category:** Enterprise
181
+ Centralized logging (Loki) with batching may lose the final batch of logs on shutdown. There's no flush/drain mechanism.
182
+ **Fix:** Implement `OnApplicationShutdown` to flush pending logs before exit.
183
+
184
+ ---
185
+
186
+ ### 🟢 LOW / IMPROVEMENTS
187
+
188
+ #### STYLE-1: Typo "middlwareOptions" (logging.module.ts:72)
189
+ ```typescript
190
+ const middlwareOptions = this.options.middleware; // Should be: middlewareOptions
191
+ ```
192
+
193
+ #### STYLE-2: Inconsistent spacing and formatting throughout
194
+ Mixed use of `if(` vs `if (`, inconsistent semicolons, and non-standard whitespace.
195
+
196
+ #### STYLE-3: TODO left in default-logger.service.ts:18
197
+ ```typescript
198
+ /**
199
+ * TODO: Implement as async console logger
200
+ */
201
+ ```
202
+
203
+ #### ENH-4: No JSDoc on public APIs
204
+ Most public classes, methods, and interfaces lack documentation. Critical for a library package.
205
+
206
+ #### ENH-5: `LoggingConfigSchema` uses `@IsBooleanString` for `LOGGING_TYPE` (logging.config.ts:21)
207
+ ```typescript
208
+ @IsBooleanString() // LOGGING_TYPE is 'pino' | 'winston' | 'default', not a boolean!
209
+ LOGGING_TYPE: string;
210
+ ```
211
+
212
+ #### ENH-6: Provider interface duplication (provider.interface.ts)
213
+ `DefaultLoggerOptions`, `PinoLoggerOptions`, and `WinstonLoggerOptions` are identical interfaces. Should be a single `LoggerProviderOptions` type.
214
+
215
+ #### ENH-7: `context` field clobbered on each interceptor call (logging.interceptor.ts:55)
216
+ ```typescript
217
+ this.context = context.getClass().name || context.constructor.name;
218
+ ```
219
+ This is an instance field set on each request. If concurrent requests hit, they'll overwrite each other's context name. Should be a local variable instead.
220
+
221
+ #### ENH-8: No test for LoggingInterceptor, ContextMiddleware, serializer, or file rotation
222
+ Coverage is effectively 0% for the most critical code paths. Only module registration is tested.
223
+
224
+ #### ENH-9: Missing `@Global()` option
225
+ Unlike other NestJS logging libraries (e.g., nestjs-pino), there's no way to make the module global. Consumers must import in every module.
226
+
227
+ ---
228
+
229
+ ## Priority Fix Order
230
+
231
+ | Priority | ID | Effort | Description |
232
+ |:---|:---|:---|:---|
233
+ | P0 | SEC-2 | S | fast-redact object mutation (data corruption) |
234
+ | P0 | MEM-1 | M | Transport cleanup on destroy |
235
+ | P0 | MEM-2 | S | Rotating stream cleanup |
236
+ | P0 | SEC-1 | S | JSON.parse crash on malformed env |
237
+ | P1 | SEC-3 | S | requestData overwrite bug |
238
+ | P1 | ENH-2 | S | Error stack trace logging |
239
+ | P1 | ENH-7 | S | Race condition on context field |
240
+ | P1 | BUG-1 | S | NaN maxFiles |
241
+ | P1 | PERF-1 | S | Double hrtime call |
242
+ | P2 | BUG-2 | S | basicAuth password validation |
243
+ | P2 | BUG-3 | S | Dead enrichContext method |
244
+ | P2 | TYPE-1 | M | Type the logger instances |
245
+ | P2 | TYPE-2 | S | Fix factory interface |
246
+ | P2 | ENH-1 | S | Document redact depth limitation |
247
+ | P2 | ENH-3 | M | Graceful shutdown flush |
248
+ | P2 | ENH-5 | S | Fix LOGGING_TYPE validator |
249
+ | P2 | ENH-6 | S | Deduplicate provider interfaces |
250
+ | P3 | ENH-4 | L | JSDoc documentation |
251
+ | P3 | ENH-8 | L | Test coverage (target 80%+) |
252
+ | P3 | ENH-9 | S | Global module option |
253
+ | P3 | STYLE-* | S | Formatting cleanup |
254
+
255
+ **S** = Small (<30 min), **M** = Medium (30-120 min), **L** = Large (2+ hours)
256
+
257
+ ---
258
+
259
+ ## Recommendations
260
+
261
+ 1. **Immediate**: Fix SEC-2 (data corruption) and MEM-1/MEM-2 (memory leaks) — these are production-impacting.
262
+ 2. **Before 3.0.0**: Fix all P0 and P1 items. This is a logging library — silent data loss and memory leaks undermine its core purpose.
263
+ 3. **Test coverage**: Currently at effectively 0% for business logic. The interceptor, middleware, serializer, and file rotation are completely untested. Target 80%+ for 3.0.0.
264
+ 4. **Consider**: Breaking the provider options interface duplication to simplify maintenance.