logixia 2.0.0 → 2.0.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 (231) hide show
  1. package/README.md +46 -29
  2. package/dist/async-context-B05ArHgM.mjs +134 -0
  3. package/dist/async-context-B05ArHgM.mjs.map +1 -0
  4. package/dist/async-context-DTQgi8f7.js +150 -0
  5. package/dist/async-context-DTQgi8f7.js.map +1 -0
  6. package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
  7. package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
  8. package/dist/{azure-monitor.transport-Cn_3Usvu.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
  9. package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
  10. package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
  11. package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
  12. package/dist/{azure-monitor.transport-D7Da4RAb.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
  13. package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
  14. package/dist/azure.d.mts +1 -2
  15. package/dist/azure.d.ts +1 -2
  16. package/dist/azure.js +3 -6
  17. package/dist/azure.mjs +1 -6
  18. package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
  19. package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
  20. package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
  21. package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
  22. package/dist/browser.d.mts +45 -25
  23. package/dist/browser.d.mts.map +1 -1
  24. package/dist/browser.d.ts +45 -25
  25. package/dist/browser.d.ts.map +1 -1
  26. package/dist/browser.js +420 -53
  27. package/dist/browser.js.map +1 -1
  28. package/dist/browser.mjs +421 -56
  29. package/dist/browser.mjs.map +1 -1
  30. package/dist/{builder-0gEzRopq.mjs → builder-D70z6kjj.mjs} +212 -104
  31. package/dist/builder-D70z6kjj.mjs.map +1 -0
  32. package/dist/{builder-D44QktIo.js → builder-M7NoaugM.js} +355 -249
  33. package/dist/builder-M7NoaugM.js.map +1 -0
  34. package/dist/cli/index.js +59 -59
  35. package/dist/cloudwatch.d.mts +1 -2
  36. package/dist/cloudwatch.d.ts +1 -2
  37. package/dist/cloudwatch.js +3 -7
  38. package/dist/cloudwatch.mjs +1 -7
  39. package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
  40. package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
  41. package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
  42. package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
  43. package/dist/{cloudwatch.transport-DsEq633o.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
  44. package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
  45. package/dist/{cloudwatch.transport-UlyZFWMn.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
  46. package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
  47. package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
  48. package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
  49. package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
  50. package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
  51. package/dist/correlation.d.mts +13 -16
  52. package/dist/correlation.d.mts.map +1 -1
  53. package/dist/correlation.d.ts +13 -16
  54. package/dist/correlation.d.ts.map +1 -1
  55. package/dist/correlation.js +58 -9
  56. package/dist/correlation.js.map +1 -1
  57. package/dist/correlation.mjs +56 -6
  58. package/dist/correlation.mjs.map +1 -1
  59. package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
  60. package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
  61. package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
  62. package/dist/entry-fields-RLd1jCoR.js.map +1 -0
  63. package/dist/gcp.d.mts +1 -2
  64. package/dist/gcp.d.ts +1 -2
  65. package/dist/gcp.js +3 -7
  66. package/dist/gcp.mjs +1 -7
  67. package/dist/{gcp.transport-B7oc97sG.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
  68. package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
  69. package/dist/{gcp.transport-GrJurKo8.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
  70. package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
  71. package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
  72. package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
  73. package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
  74. package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
  75. package/dist/{index-DhIoploR.d.ts → index-DwozbmB4.d.ts} +3 -8
  76. package/dist/index-DwozbmB4.d.ts.map +1 -0
  77. package/dist/{index-3mw5gaCw.d.mts → index-xqaJtAZn.d.mts} +3 -8
  78. package/dist/index-xqaJtAZn.d.mts.map +1 -0
  79. package/dist/index.d.mts +106 -165
  80. package/dist/index.d.mts.map +1 -1
  81. package/dist/index.d.ts +105 -164
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +164 -261
  84. package/dist/index.js.map +1 -1
  85. package/dist/index.mjs +147 -243
  86. package/dist/index.mjs.map +1 -1
  87. package/dist/internal-log-b0Vp4qrB.js +183 -0
  88. package/dist/internal-log-b0Vp4qrB.js.map +1 -0
  89. package/dist/internal-log-uCSd1PMc.mjs +142 -0
  90. package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
  91. package/dist/{logitron-logger-UVeN-mQm.d.ts → logitron-logger-D2B75Oc7.d.ts} +116 -8
  92. package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
  93. package/dist/{logitron-logger-BFDSO8Io.d.mts → logitron-logger-oEd6wNhf.d.mts} +116 -8
  94. package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
  95. package/dist/middleware.d.mts +10 -12
  96. package/dist/middleware.d.mts.map +1 -1
  97. package/dist/middleware.d.ts +10 -12
  98. package/dist/middleware.d.ts.map +1 -1
  99. package/dist/middleware.js +16 -47
  100. package/dist/middleware.js.map +1 -1
  101. package/dist/middleware.mjs +13 -45
  102. package/dist/middleware.mjs.map +1 -1
  103. package/dist/nest.d.mts +26 -44
  104. package/dist/nest.d.mts.map +1 -1
  105. package/dist/nest.d.ts +26 -44
  106. package/dist/nest.d.ts.map +1 -1
  107. package/dist/nest.js +116 -132
  108. package/dist/nest.js.map +1 -1
  109. package/dist/nest.mjs +59 -73
  110. package/dist/nest.mjs.map +1 -1
  111. package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
  112. package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
  113. package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
  114. package/dist/request-trace-wTJdKp6-.js.map +1 -0
  115. package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
  116. package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
  117. package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
  118. package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
  119. package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
  120. package/dist/{search-CNh9uVwR.d.ts → search-BH33XhuU.d.mts} +2 -22
  121. package/dist/search-BH33XhuU.d.mts.map +1 -0
  122. package/dist/{search-BFbu_oVn.mjs → search-CWMVYC-R.mjs} +22 -39
  123. package/dist/search-CWMVYC-R.mjs.map +1 -0
  124. package/dist/{search-DXANsQ2n.d.mts → search-CazwyX5Z.d.ts} +2 -22
  125. package/dist/search-CazwyX5Z.d.ts.map +1 -0
  126. package/dist/{search-C4V0OMEn.js → search-DUfWuzFP.js} +52 -69
  127. package/dist/search-DUfWuzFP.js.map +1 -0
  128. package/dist/search.d.mts +2 -4
  129. package/dist/search.d.ts +2 -4
  130. package/dist/search.js +3 -4
  131. package/dist/search.mjs +1 -4
  132. package/dist/secret-config-BegMLkYl.mjs +209 -0
  133. package/dist/secret-config-BegMLkYl.mjs.map +1 -0
  134. package/dist/secret-config-CBZBs0p1.js +271 -0
  135. package/dist/secret-config-CBZBs0p1.js.map +1 -0
  136. package/dist/{slack.transport-Bzw7sucI.mjs → slack.transport-Ce96JBDk.mjs} +212 -31
  137. package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
  138. package/dist/{slack.transport-BfJRouB2.js → slack.transport-Dlx3xvb7.js} +234 -41
  139. package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
  140. package/dist/{slack.transport-BZzoXDPn.d.mts → slack.transport-DrirgDNy.d.ts} +56 -9
  141. package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
  142. package/dist/{slack.transport-CXjQYOes.d.ts → slack.transport-DxHOXlLu.d.mts} +56 -9
  143. package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
  144. package/dist/testing.d.mts +3 -8
  145. package/dist/testing.d.mts.map +1 -1
  146. package/dist/testing.d.ts +3 -8
  147. package/dist/testing.d.ts.map +1 -1
  148. package/dist/testing.js +3 -4
  149. package/dist/testing.js.map +1 -1
  150. package/dist/testing.mjs +2 -3
  151. package/dist/testing.mjs.map +1 -1
  152. package/dist/{transport.manager-CXbKKdVE.js → transport.manager-DkcEOlqV.js} +164 -160
  153. package/dist/transport.manager-DkcEOlqV.js.map +1 -0
  154. package/dist/{transport.manager-BiuCAJd2.mjs → transport.manager-eZ_EeC00.mjs} +108 -99
  155. package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
  156. package/dist/{transport.types-CGoHpWQR.d.ts → transport.types-BJVL1QQl.d.mts} +1 -3
  157. package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
  158. package/dist/{transport.types-BMnurPcc.d.mts → transport.types-BJVL1QQl.d.ts} +1 -3
  159. package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
  160. package/dist/transports.d.mts +22 -36
  161. package/dist/transports.d.mts.map +1 -1
  162. package/dist/transports.d.ts +22 -36
  163. package/dist/transports.d.ts.map +1 -1
  164. package/dist/transports.js +10 -13
  165. package/dist/transports.mjs +7 -13
  166. package/dist/worker-entry.js +337 -87
  167. package/dist/worker.d.mts +1 -2
  168. package/dist/worker.d.ts +1 -2
  169. package/dist/worker.js +3 -4
  170. package/dist/worker.mjs +1 -4
  171. package/dist/{worker.transport-CdzSZJmw.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
  172. package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
  173. package/dist/{worker.transport-BdPxu3PN.js → worker.transport-C6GNl_r2.js} +44 -14
  174. package/dist/worker.transport-C6GNl_r2.js.map +1 -0
  175. package/dist/{worker.transport-lPxO2MVL.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
  176. package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
  177. package/dist/{worker.transport-JvGPog3C.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
  178. package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
  179. package/package.json +19 -11
  180. package/dist/async-context-BzJrbfQs.mjs +0 -72
  181. package/dist/async-context-BzJrbfQs.mjs.map +0 -1
  182. package/dist/async-context-DyQQYq3I.js +0 -92
  183. package/dist/async-context-DyQQYq3I.js.map +0 -1
  184. package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
  185. package/dist/azure-monitor.transport-Cn_3Usvu.d.ts.map +0 -1
  186. package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
  187. package/dist/azure-monitor.transport-D7Da4RAb.d.mts.map +0 -1
  188. package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
  189. package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
  190. package/dist/builder-0gEzRopq.mjs.map +0 -1
  191. package/dist/builder-D44QktIo.js.map +0 -1
  192. package/dist/chunk-DLSkYcPk.mjs +0 -7
  193. package/dist/chunk-nOFOJqeH.js +0 -30
  194. package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
  195. package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
  196. package/dist/cloudwatch.transport-DsEq633o.d.ts.map +0 -1
  197. package/dist/cloudwatch.transport-UlyZFWMn.d.mts.map +0 -1
  198. package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
  199. package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
  200. package/dist/gcp.transport-B7oc97sG.d.ts.map +0 -1
  201. package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
  202. package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
  203. package/dist/gcp.transport-GrJurKo8.d.mts.map +0 -1
  204. package/dist/index-3mw5gaCw.d.mts.map +0 -1
  205. package/dist/index-DhIoploR.d.ts.map +0 -1
  206. package/dist/internal-log-BUJYMZbE.js +0 -70
  207. package/dist/internal-log-BUJYMZbE.js.map +0 -1
  208. package/dist/internal-log-Cm8SOWSV.mjs +0 -52
  209. package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
  210. package/dist/logitron-logger-BFDSO8Io.d.mts.map +0 -1
  211. package/dist/logitron-logger-UVeN-mQm.d.ts.map +0 -1
  212. package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
  213. package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
  214. package/dist/search-BFbu_oVn.mjs.map +0 -1
  215. package/dist/search-C4V0OMEn.js.map +0 -1
  216. package/dist/search-CNh9uVwR.d.ts.map +0 -1
  217. package/dist/search-DXANsQ2n.d.mts.map +0 -1
  218. package/dist/slack.transport-BZzoXDPn.d.mts.map +0 -1
  219. package/dist/slack.transport-BfJRouB2.js.map +0 -1
  220. package/dist/slack.transport-Bzw7sucI.mjs.map +0 -1
  221. package/dist/slack.transport-CXjQYOes.d.ts.map +0 -1
  222. package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
  223. package/dist/trace.utils-DpBOLDtq.js.map +0 -1
  224. package/dist/transport.manager-BiuCAJd2.mjs.map +0 -1
  225. package/dist/transport.manager-CXbKKdVE.js.map +0 -1
  226. package/dist/transport.types-BMnurPcc.d.mts.map +0 -1
  227. package/dist/transport.types-CGoHpWQR.d.ts.map +0 -1
  228. package/dist/worker.transport-BdPxu3PN.js.map +0 -1
  229. package/dist/worker.transport-CdzSZJmw.d.ts.map +0 -1
  230. package/dist/worker.transport-JvGPog3C.d.mts.map +0 -1
  231. package/dist/worker.transport-lPxO2MVL.mjs.map +0 -1
@@ -1,16 +1,14 @@
1
- const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const require_internal_log = require('./internal-log-BUJYMZbE.js');
3
- const require_safe_stringify = require('./safe-stringify-DWo3aZp_.js');
4
- const require_trace_utils = require('./trace.utils-DpBOLDtq.js');
5
- const require_async_context = require('./async-context-DyQQYq3I.js');
6
- const require_coerce_utils = require('./coerce.utils-B-LilukN.js');
7
- const require_transport_manager = require('./transport.manager-CXbKKdVE.js');
8
- let node_os = require("node:os");
9
- node_os = require_chunk.__toESM(node_os);
1
+ const require_secret_config = require("./secret-config-CBZBs0p1.js");
2
+ const require_request_trace = require("./request-trace-wTJdKp6-.js");
3
+ const require_async_context = require("./async-context-DTQgi8f7.js");
4
+ const require_internal_log = require("./internal-log-b0Vp4qrB.js");
5
+ const require_coerce_utils = require("./coerce.utils-C1C5sIX0.js");
6
+ const require_safe_stringify = require("./safe-stringify-DLz1Kz3o.js");
7
+ const require_transport_manager = require("./transport.manager-DkcEOlqV.js");
10
8
  let fast_json_stringify = require("fast-json-stringify");
11
- fast_json_stringify = require_chunk.__toESM(fast_json_stringify);
12
-
13
- //#region src/types/index.ts
9
+ fast_json_stringify = require_secret_config.__toESM(fast_json_stringify);
10
+ let node_os = require("node:os");
11
+ // src/types/index.ts
14
12
  const LogLevel = {
15
13
  ERROR: "error",
16
14
  WARN: "warn",
@@ -35,9 +33,7 @@ const DEFAULT_LOG_COLORS = {
35
33
  trace: "magenta",
36
34
  verbose: "cyan"
37
35
  };
38
-
39
- //#endregion
40
- //#region src/core/default-config.ts
36
+ // src/core/default-config.ts
41
37
  /**
42
38
  * Default configuration for Logixia logger
43
39
  */
@@ -81,9 +77,7 @@ const DEFAULT_CONFIG = {
81
77
  },
82
78
  outputs: ["console"]
83
79
  };
84
-
85
- //#endregion
86
- //#region src/plugin.ts
80
+ // src/plugin.ts
87
81
  /**
88
82
  * Holds an ordered list of `LogixiaPlugin` instances and dispatches lifecycle
89
83
  * events to them. One registry is created per logger instance; a global
@@ -188,9 +182,7 @@ const globalPluginRegistry = new PluginRegistry();
188
182
  function usePlugin(plugin) {
189
183
  globalPluginRegistry.register(plugin);
190
184
  }
191
-
192
- //#endregion
193
- //#region src/utils/error.utils.ts
185
+ // src/utils/error.utils.ts
194
186
  const EXTRA_FIELDS = [
195
187
  "code",
196
188
  "statusCode",
@@ -232,13 +224,15 @@ function _serializeError(error, includeStack, maxDepth, excludeFields, depth, se
232
224
  };
233
225
  if (includeStack && error.stack) serialized.stack = error.stack;
234
226
  const errorWithCause = error;
235
- if (errorWithCause.cause !== void 0) if (errorWithCause.cause instanceof Error) serialized.cause = _serializeError(errorWithCause.cause, includeStack, maxDepth, excludeFields, depth + 1, seen);
236
- else serialized.cause = serializeValue(errorWithCause.cause, maxDepth - depth - 1, seen);
227
+ if (errorWithCause.cause !== void 0) {
228
+ if (errorWithCause.cause instanceof Error) serialized.cause = _serializeError(errorWithCause.cause, includeStack, maxDepth, excludeFields, depth + 1, seen);
229
+ else serialized.cause = serializeValue(errorWithCause.cause, maxDepth - depth - 1, seen);
230
+ }
237
231
  const aggregateError = error;
238
232
  if (Array.isArray(aggregateError.errors)) serialized.errors = aggregateError.errors.map((e) => e instanceof Error ? _serializeError(e, includeStack, maxDepth, excludeFields, depth + 1, seen) : serializeValue(e, maxDepth - depth - 1, seen));
239
233
  const errorRecord = error;
240
234
  for (const field of EXTRA_FIELDS) if (!excludeFields.includes(field) && field in error && errorRecord[field] !== void 0) serialized[field] = errorRecord[field];
241
- const skip = new Set([
235
+ const skip = /* @__PURE__ */ new Set([
242
236
  "name",
243
237
  "message",
244
238
  "stack",
@@ -320,9 +314,7 @@ function normalizeError(error) {
320
314
  }
321
315
  return new Error(String(error));
322
316
  }
323
-
324
- //#endregion
325
- //#region src/utils/otel.ts
317
+ // src/utils/otel.ts
326
318
  let _otelApi;
327
319
  function tryLoadOtelApi() {
328
320
  if (_otelApi !== void 0) return _otelApi;
@@ -427,9 +419,7 @@ function _getOtelPayloadIfEnabled() {
427
419
  function disableOtelBridge() {
428
420
  _bridgeOptions = null;
429
421
  }
430
-
431
- //#endregion
432
- //#region src/utils/redact.utils.ts
422
+ // src/utils/redact.utils.ts
433
423
  const DEFAULT_CENSOR = "[REDACTED]";
434
424
  /** Maximum nesting depth walked; deeper values are replaced with a marker. */
435
425
  const MAX_DEPTH = 32;
@@ -458,34 +448,7 @@ const PII_CONSERVATIVE_PATTERNS = [
458
448
  /**
459
449
  * Conservative field-name paths auto-redacted by name regardless of value.
460
450
  */
461
- const PII_CONSERVATIVE_PATHS = [
462
- "**.password",
463
- "**.passwd",
464
- "**.secret",
465
- "**.token",
466
- "**.apiKey",
467
- "**.api_key",
468
- "**.accessToken",
469
- "**.access_token",
470
- "**.refreshToken",
471
- "**.refresh_token",
472
- "**.authorization",
473
- "**.credentials",
474
- "**.privateKey",
475
- "**.private_key",
476
- "**.clientSecret",
477
- "**.client_secret",
478
- "**.cookie",
479
- "**.set-cookie",
480
- "**.x-api-key",
481
- "**.session",
482
- "**.proxy-authorization",
483
- "**.x-auth-token",
484
- "**.x-access-token",
485
- "**.aws_secret_access_key",
486
- "**.awsSecretAccessKey",
487
- "**.secretAccessKey"
488
- ];
451
+ const PII_CONSERVATIVE_PATHS = require_internal_log.SENSITIVE_KEY_NAMES.map((name) => `**.${name}`);
489
452
  /**
490
453
  * Aggressive patterns: also catch personal data that could identify a person.
491
454
  * Applied when `autoDetect: 'aggressive'`.
@@ -697,7 +660,7 @@ function walkToJSON(obj, state, fullPath, bare, depth) {
697
660
  function redactObject(obj, config, _currentPath = "") {
698
661
  const result = walkRecord(obj, {
699
662
  config,
700
- ancestors: new Set([obj]),
663
+ ancestors: /* @__PURE__ */ new Set([obj]),
701
664
  nodes: 0
702
665
  }, _currentPath, _currentPath, 0);
703
666
  return result === obj ? { ...obj } : result;
@@ -746,10 +709,8 @@ function isPlainObject(value) {
746
709
  if (ArrayBuffer.isView(value)) return false;
747
710
  return !OPAQUE_BUILTINS.some((ctor) => value instanceof ctor);
748
711
  }
749
-
750
- //#endregion
751
- //#region src/utils/sampling.utils.ts
752
- const ALWAYS_EMIT_LEVELS = new Set([
712
+ // src/utils/sampling.utils.ts
713
+ const ALWAYS_EMIT_LEVELS = /* @__PURE__ */ new Set([
753
714
  "error",
754
715
  "warn",
755
716
  "fatal"
@@ -767,8 +728,8 @@ var Sampler = class {
767
728
  constructor(config, onStats) {
768
729
  this.traceDecisions = /* @__PURE__ */ new Map();
769
730
  this.maxTrackedTraces = 1e5;
770
- this.traceTtlMs = 5 * 6e4;
771
- this.traceMaxLifetimeMs = 60 * 6e4;
731
+ this.traceTtlMs = 3e5;
732
+ this.traceMaxLifetimeMs = 36e5;
772
733
  this._tokenBucket = 0;
773
734
  this._lastRefillMs = Date.now();
774
735
  this._adaptiveWindow = [];
@@ -947,9 +908,14 @@ var Sampler = class {
947
908
  this._stats.dropped++;
948
909
  }
949
910
  };
950
-
951
- //#endregion
952
- //#region src/utils/shutdown.utils.ts
911
+ // src/utils/shutdown.utils.ts
912
+ /**
913
+ * Graceful shutdown utilities for Logixia
914
+ *
915
+ * Ensures all in-flight logs are flushed to every transport before the process
916
+ * exits on SIGTERM / SIGINT — solving the "last N seconds of logs are lost on
917
+ * deployment" problem reported in Pino issue #2002 and LogDNA issue #15.
918
+ */
953
919
  const MAX_BEFORE_EXIT_FLUSHES = 5;
954
920
  /** Module-level registry of all logger instances that have opted into graceful shutdown */
955
921
  const registry = /* @__PURE__ */ new Set();
@@ -1069,9 +1035,17 @@ function resetShutdownHandlers() {
1069
1035
  shutdownHandlerRegistered = false;
1070
1036
  shutdownInProgress = false;
1071
1037
  }
1072
-
1073
- //#endregion
1074
- //#region src/core/logitron-logger.ts
1038
+ // src/core/logitron-logger.ts
1039
+ /**
1040
+ * Core Logixia Logger implementation
1041
+ *
1042
+ * v1.1 additions:
1043
+ * - Feature 1: Graceful shutdown / flushOnExit (auto-registered via config)
1044
+ * - Feature 2: Built-in log redaction (path-based + regex)
1045
+ * - Feature 3: Per-namespace log levels + LOGIXIA_LEVEL* ENV overrides
1046
+ * - Feature 4: Cause-chain error serialization (handled in error.utils)
1047
+ * - Feature 5: Adaptive log level based on NODE_ENV / CI detection
1048
+ */
1075
1049
  const _fastStringifyEntry = (0, fast_json_stringify.default)({
1076
1050
  type: "object",
1077
1051
  properties: {
@@ -1101,7 +1075,7 @@ function nowIso() {
1101
1075
  }
1102
1076
  function namespacePatternToRegex(pattern) {
1103
1077
  const escaped = pattern.split(".").map((s) => s === "*" ? "[^.]+" : s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("\\.");
1104
- return /* @__PURE__ */ new RegExp(`^${escaped}$`);
1078
+ return new RegExp(`^${escaped}$`);
1105
1079
  }
1106
1080
  /** Max compiled patterns to keep in memory. Oldest entry is evicted when full. */
1107
1081
  const _NS_CACHE_MAX = 1e3;
@@ -1143,7 +1117,7 @@ function canonicalLevel(level, known) {
1143
1117
  function resolveInitialLevel(config) {
1144
1118
  var _config$levelOptions, _config$levelOptions2;
1145
1119
  const envLevel = process.env["LOGIXIA_LEVEL"];
1146
- const knownLevels = new Set([...Object.values(LogLevel), ...Object.keys(((_config$levelOptions = config.levelOptions) === null || _config$levelOptions === void 0 ? void 0 : _config$levelOptions.levels) ?? {})]);
1120
+ const knownLevels = /* @__PURE__ */ new Set([...Object.values(LogLevel), ...Object.keys(((_config$levelOptions = config.levelOptions) === null || _config$levelOptions === void 0 ? void 0 : _config$levelOptions.levels) ?? {})]);
1147
1121
  if (envLevel && canonicalLevel(envLevel, knownLevels)) return envLevel;
1148
1122
  if ((_config$levelOptions2 = config.levelOptions) === null || _config$levelOptions2 === void 0 ? void 0 : _config$levelOptions2.level) return config.levelOptions.level;
1149
1123
  const nodeEnv = process.env["NODE_ENV"];
@@ -1153,12 +1127,25 @@ function resolveInitialLevel(config) {
1153
1127
  if (process.env["CI"]) return LogLevel.INFO;
1154
1128
  return LogLevel.INFO;
1155
1129
  }
1130
+ /**
1131
+ * The logixia logger. Create instances with {@link createLogger} so that custom
1132
+ * levels from `levelOptions.levels` also become methods.
1133
+ *
1134
+ * @example
1135
+ * ```ts
1136
+ * const logger = createLogger({ appName: 'api', environment: 'production' });
1137
+ * await logger.info('Server started', { port: 3000 });
1138
+ * const req = logger.child('RequestHandler', { requestId: 'r-1' });
1139
+ * await req.error(new Error('boom'));
1140
+ * await logger.close(); // flush buffered transports before exit
1141
+ * ```
1142
+ */
1156
1143
  var LogixiaLogger = class LogixiaLogger {
1157
1144
  constructor(config, context, parent) {
1158
1145
  this.timers = /* @__PURE__ */ new Map();
1159
1146
  this.contextData = {};
1160
1147
  this.fieldState = /* @__PURE__ */ new Map();
1161
- this.fallbackTraceId = require_trace_utils.TraceContext.instance.generate();
1148
+ this.fallbackTraceId = require_request_trace.TraceContext.instance.generate();
1162
1149
  this._levelValues = /* @__PURE__ */ new Map();
1163
1150
  this._minLevelValue = 2;
1164
1151
  this._warnedInvalidLevels = /* @__PURE__ */ new Set();
@@ -1170,7 +1157,7 @@ var LogixiaLogger = class LogixiaLogger {
1170
1157
  this._hasRedact = false;
1171
1158
  this._parent = parent;
1172
1159
  this._pluginRegistry = parent ? parent._pluginRegistry : new PluginRegistry();
1173
- this.config = {
1160
+ const defaultConfig = {
1174
1161
  appName: "App",
1175
1162
  environment: "development",
1176
1163
  traceId: true,
@@ -1198,7 +1185,10 @@ var LogixiaLogger = class LogixiaLogger {
1198
1185
  [LogLevel.TRACE]: "gray",
1199
1186
  [LogLevel.VERBOSE]: "cyan"
1200
1187
  }
1201
- },
1188
+ }
1189
+ };
1190
+ this.config = {
1191
+ ...defaultConfig,
1202
1192
  ...config
1203
1193
  };
1204
1194
  const resolvedLevel = resolveInitialLevel(this.config);
@@ -1216,6 +1206,7 @@ var LogixiaLogger = class LogixiaLogger {
1216
1206
  timeTaken: "[time_taken_MS]"
1217
1207
  };
1218
1208
  this.context = context ?? "";
1209
+ require_secret_config.protectSecrets(this, ["config"]);
1219
1210
  if (parent) {
1220
1211
  this.transportManager = parent.transportManager;
1221
1212
  this._sampler = parent._sampler;
@@ -1281,7 +1272,7 @@ var LogixiaLogger = class LogixiaLogger {
1281
1272
  this.config.levelOptions.level = this._validLevel(this.config.levelOptions.level, "levelOptions.level") ?? LogLevel.INFO;
1282
1273
  const effectiveLevel = this.resolveEffectiveLevel();
1283
1274
  this._minLevelValue = this._levelValues.get(effectiveLevel) ?? 2;
1284
- this._colorMap = new Map([
1275
+ this._colorMap = /* @__PURE__ */ new Map([
1285
1276
  ["black", "\x1B[30m"],
1286
1277
  ["red", "\x1B[31m"],
1287
1278
  ["green", "\x1B[32m"],
@@ -1324,7 +1315,7 @@ var LogixiaLogger = class LogixiaLogger {
1324
1315
  "green",
1325
1316
  "blue"
1326
1317
  ];
1327
- const _BUILTIN_LEVELS = new Set([
1318
+ const _BUILTIN_LEVELS = /* @__PURE__ */ new Set([
1328
1319
  "error",
1329
1320
  "warn",
1330
1321
  "info",
@@ -1338,10 +1329,12 @@ var LogixiaLogger = class LogixiaLogger {
1338
1329
  if (colorize && this._fieldCache.get("level") !== false) {
1339
1330
  var _this$config$levelOpt4;
1340
1331
  let colorName = (_this$config$levelOpt4 = this.config.levelOptions) === null || _this$config$levelOpt4 === void 0 || (_this$config$levelOpt4 = _this$config$levelOpt4.colors) === null || _this$config$levelOpt4 === void 0 ? void 0 : _this$config$levelOpt4[lvl];
1341
- if (!colorName) if (_BUILTIN_LEVELS.has(lvl)) colorName = "white";
1342
- else {
1343
- colorName = _AUTO_PALETTE[_paletteIdx % _AUTO_PALETTE.length];
1344
- _paletteIdx++;
1332
+ if (!colorName) {
1333
+ if (_BUILTIN_LEVELS.has(lvl)) colorName = "white";
1334
+ else {
1335
+ colorName = _AUTO_PALETTE[_paletteIdx % _AUTO_PALETTE.length];
1336
+ _paletteIdx++;
1337
+ }
1345
1338
  }
1346
1339
  const code = this._colorMap.get(colorName.toLowerCase()) ?? this._colorMap.get("white");
1347
1340
  const reset = this._colorMap.get("reset");
@@ -1353,6 +1346,11 @@ var LogixiaLogger = class LogixiaLogger {
1353
1346
  else this._formattedAppName = colorize ? `${this._colorMap.get("gray")}${appNameRaw}${this._colorMap.get("reset")} ` : `${appNameRaw} `;
1354
1347
  this._hasRedact = !!(this.config.redact && ((((_this$config$redact$p = this.config.redact.paths) === null || _this$config$redact$p === void 0 ? void 0 : _this$config$redact$p.length) ?? 0) > 0 || (((_this$config$redact$p2 = this.config.redact.patterns) === null || _this$config$redact$p2 === void 0 ? void 0 : _this$config$redact$p2.length) ?? 0) > 0 || !!this.config.redact.autoDetect));
1355
1348
  }
1349
+ /**
1350
+ * Log at `error` level. An `Error` is logged with its message and serialized
1351
+ * (name, message, stack) under `data.error`; a string is logged as-is.
1352
+ * `data` is merged into the entry payload.
1353
+ */
1356
1354
  async error(messageOrError, data) {
1357
1355
  if (isError(messageOrError)) await this.log("error", messageOrError.message, {
1358
1356
  ...data,
@@ -1360,30 +1358,53 @@ var LogixiaLogger = class LogixiaLogger {
1360
1358
  });
1361
1359
  else await this.log("error", messageOrError, data);
1362
1360
  }
1361
+ /** Log `message` at `warn` level; `data` is merged into the entry payload. */
1363
1362
  async warn(message, data) {
1364
1363
  await this.log("warn", message, data);
1365
1364
  }
1365
+ /** Log `message` at `info` level; `data` is merged into the entry payload. */
1366
1366
  async info(message, data) {
1367
1367
  await this.log("info", message, data);
1368
1368
  }
1369
+ /** Log `message` at `debug` level; `data` is merged into the entry payload. */
1369
1370
  async debug(message, data) {
1370
1371
  await this.log("debug", message, data);
1371
1372
  }
1373
+ /** Log `message` at `trace` level; `data` is merged into the entry payload. */
1372
1374
  async trace(message, data) {
1373
1375
  await this.log("trace", message, data);
1374
1376
  }
1377
+ /** Log `message` at `verbose` level; `data` is merged into the entry payload. */
1375
1378
  async verbose(message, data) {
1376
1379
  await this.log("verbose", message, data);
1377
1380
  }
1381
+ /**
1382
+ * Log at an arbitrary level name, including custom levels. Levels below the
1383
+ * active threshold are dropped, as are level names that are not registered
1384
+ * in `levelOptions.levels` (and are not built-in).
1385
+ */
1378
1386
  async logLevel(level, message, data) {
1379
1387
  await this.log(level, message, data);
1380
1388
  }
1389
+ /** Start a named timer; finish it with {@link timeEnd}. Reusing a label restarts it. */
1381
1390
  time(label) {
1382
1391
  this.timers.set(label, {
1383
1392
  label,
1384
1393
  startTime: Date.now()
1385
1394
  });
1386
1395
  }
1396
+ /**
1397
+ * Stop the timer `label`, log its duration at `info` level, and return the
1398
+ * elapsed milliseconds. Logs a `warn` and returns `undefined` if the timer
1399
+ * does not exist.
1400
+ *
1401
+ * @example
1402
+ * ```ts
1403
+ * logger.time('db');
1404
+ * await query();
1405
+ * const ms = await logger.timeEnd('db');
1406
+ * ```
1407
+ */
1387
1408
  async timeEnd(label) {
1388
1409
  const timer = this.timers.get(label);
1389
1410
  if (!timer) {
@@ -1413,6 +1434,17 @@ var LogixiaLogger = class LogixiaLogger {
1413
1434
  throw error;
1414
1435
  }
1415
1436
  }
1437
+ /**
1438
+ * Change the minimum log level at runtime. The override outranks
1439
+ * `LOGIXIA_LEVEL`, `LOGIXIA_LEVEL_<NS>` and `namespaceLevels`, and survives
1440
+ * later changes to fields or namespace levels. Unknown level names are
1441
+ * ignored with a warning and the current level is kept.
1442
+ *
1443
+ * @example
1444
+ * ```ts
1445
+ * logger.setLevel('debug');
1446
+ * ```
1447
+ */
1416
1448
  setLevel(level) {
1417
1449
  const canonical = canonicalLevel(level, this._levelValues);
1418
1450
  if (canonical === void 0) {
@@ -1421,9 +1453,14 @@ var LogixiaLogger = class LogixiaLogger {
1421
1453
  }
1422
1454
  this.config.levelOptions = this.config.levelOptions ?? {};
1423
1455
  this.config.levelOptions.level = canonical;
1424
- this._minLevelValue = this._levelValues.get(canonical) ?? this._minLevelValue;
1456
+ this._runtimeLevel = canonical;
1425
1457
  this._buildPerfCaches();
1426
1458
  }
1459
+ /**
1460
+ * Return the configured minimum log level, not the per-namespace effective
1461
+ * one. Without `setLevel()` it is `LOGIXIA_LEVEL`, else `levelOptions.level`,
1462
+ * else a `NODE_ENV` default (`debug` in development, `warn` in test), else `info`.
1463
+ */
1427
1464
  getLevel() {
1428
1465
  var _this$config$levelOpt5;
1429
1466
  return ((_this$config$levelOpt5 = this.config.levelOptions) === null || _this$config$levelOpt5 === void 0 ? void 0 : _this$config$levelOpt5.level) ?? LogLevel.INFO;
@@ -1477,30 +1514,36 @@ var LogixiaLogger = class LogixiaLogger {
1477
1514
  getNamespaceLevels() {
1478
1515
  return { ...this.config.namespaceLevels };
1479
1516
  }
1517
+ /** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
1480
1518
  setContext(context) {
1481
1519
  this.context = typeof context === "string" ? context : require_coerce_utils.safeToString(context);
1482
1520
  }
1521
+ /** Return the current context label, or `undefined` if none is set. */
1483
1522
  getContext() {
1484
1523
  return this.context;
1485
1524
  }
1525
+ /** Show `fieldName` in log output, overriding the config for this logger instance. */
1486
1526
  enableField(fieldName) {
1487
1527
  this.fieldState.set(fieldName, true);
1488
1528
  this._fieldCache.set(fieldName, true);
1489
1529
  if (fieldName === "level" || fieldName === "appName") this._buildPerfCaches();
1490
1530
  require_internal_log.internalLog(`Field '${fieldName}' enabled`);
1491
1531
  }
1532
+ /** Hide `fieldName` from log output, overriding the config for this logger instance. */
1492
1533
  disableField(fieldName) {
1493
1534
  this.fieldState.set(fieldName, false);
1494
1535
  this._fieldCache.set(fieldName, false);
1495
1536
  if (fieldName === "level" || fieldName === "appName") this._buildPerfCaches();
1496
1537
  require_internal_log.internalLog(`Field '${fieldName}' disabled`);
1497
1538
  }
1539
+ /** Whether `fieldName` is currently shown: runtime override first, then config, default `true`. */
1498
1540
  isFieldEnabled(fieldName) {
1499
1541
  var _this$config$fields2;
1500
1542
  if (this.fieldState.has(fieldName)) return this.fieldState.get(fieldName);
1501
1543
  if (((_this$config$fields2 = this.config.fields) === null || _this$config$fields2 === void 0 ? void 0 : _this$config$fields2[fieldName]) !== void 0) return this.config.fields[fieldName] !== false;
1502
1544
  return true;
1503
1545
  }
1546
+ /** Return the visibility (`true` = shown) of every standard log field. */
1504
1547
  getFieldState() {
1505
1548
  return Object.fromEntries([
1506
1549
  "timestamp",
@@ -1517,6 +1560,7 @@ var LogixiaLogger = class LogixiaLogger {
1517
1560
  "environment"
1518
1561
  ].map((f) => [f, this.isFieldEnabled(f)]));
1519
1562
  }
1563
+ /** Drop all runtime enable/disable overrides so field visibility follows the config again. */
1520
1564
  resetFieldState() {
1521
1565
  this.fieldState.clear();
1522
1566
  require_internal_log.internalLog("Field state reset to configuration defaults");
@@ -1531,10 +1575,12 @@ var LogixiaLogger = class LogixiaLogger {
1531
1575
  if (this.transportManager) this.transportManager.disableLevelPrompting();
1532
1576
  else require_internal_log.internalWarn("Transport manager not initialized");
1533
1577
  }
1578
+ /** Restrict `transportId` to only the given `levels`. Warns if no transports are configured. */
1534
1579
  setTransportLevels(transportId, levels) {
1535
1580
  if (this.transportManager) this.transportManager.setTransportLevels(transportId, levels);
1536
1581
  else require_internal_log.internalWarn("Transport manager not initialized");
1537
1582
  }
1583
+ /** Return the levels `transportId` is restricted to, or `undefined` if it has none. */
1538
1584
  getTransportLevels(transportId) {
1539
1585
  if (this.transportManager) return this.transportManager.getTransportLevels(transportId);
1540
1586
  require_internal_log.internalWarn("Transport manager not initialized");
@@ -1543,10 +1589,23 @@ var LogixiaLogger = class LogixiaLogger {
1543
1589
  if (this.transportManager) this.transportManager.clearTransportLevelPreferences();
1544
1590
  else require_internal_log.internalWarn("Transport manager not initialized");
1545
1591
  }
1592
+ /** Return the identifiers of the configured transports (empty if none). */
1546
1593
  getAvailableTransports() {
1547
1594
  var _this$transportManage;
1548
1595
  return ((_this$transportManage = this.transportManager) === null || _this$transportManage === void 0 ? void 0 : _this$transportManage.getTransports()) ?? [];
1549
1596
  }
1597
+ /**
1598
+ * Create a child logger with its own `context` that shares this logger's
1599
+ * configuration and transports. `data` is merged into the bound fields
1600
+ * inherited from this logger and added to every entry the child writes.
1601
+ * Closing a child does not close the shared transports.
1602
+ *
1603
+ * @example
1604
+ * ```ts
1605
+ * const req = logger.child('Checkout', { requestId: 'r-42' });
1606
+ * await req.info('started'); // entry includes requestId
1607
+ * ```
1608
+ */
1550
1609
  child(context, data) {
1551
1610
  const childLogger = new LogixiaLogger(this.config, context, this);
1552
1611
  const mergedContextData = {
@@ -1582,9 +1641,11 @@ var LogixiaLogger = class LogixiaLogger {
1582
1641
  this._pluginRegistry.unregister(pluginName);
1583
1642
  return this;
1584
1643
  }
1644
+ /** Flush buffered entries in all transports without closing them. */
1585
1645
  async flush() {
1586
1646
  if (this.transportManager) await this.transportManager.flush();
1587
1647
  }
1648
+ /** Report whether the transports are healthy; `healthy: false` if no transport manager exists. */
1588
1649
  async healthCheck() {
1589
1650
  if (!this.transportManager) return {
1590
1651
  healthy: false,
@@ -1592,6 +1653,20 @@ var LogixiaLogger = class LogixiaLogger {
1592
1653
  };
1593
1654
  return this.transportManager.healthCheck();
1594
1655
  }
1656
+ /**
1657
+ * Warn about timers that were never ended, then flush and close all transports,
1658
+ * stop the sampler and run plugin shutdown hooks. On a child logger only the
1659
+ * timer warnings run; the shared transports stay open.
1660
+ *
1661
+ * To flush on SIGTERM/SIGINT, set the `gracefulShutdown` config option rather
1662
+ * than writing your own signal handler; do not combine it with a manual
1663
+ * handler that calls `process.exit`, which can cut the flush short.
1664
+ *
1665
+ * @example
1666
+ * ```ts
1667
+ * await logger.close(); // e.g. at the end of a script or a test
1668
+ * ```
1669
+ */
1595
1670
  async close() {
1596
1671
  var _this$_sampler;
1597
1672
  for (const [label, timer] of this.timers) await this.warn(`Timer '${label}' was not ended properly`, {
@@ -1608,11 +1683,13 @@ var LogixiaLogger = class LogixiaLogger {
1608
1683
  async log(level, message, data) {
1609
1684
  if (this.config.silent) return;
1610
1685
  if (!this.shouldLog(level)) return;
1611
- if (this._sampler) {
1612
- const traceId$1 = this.config.traceId ? require_trace_utils.TraceContext.instance.getCurrentTraceId() : void 0;
1613
- if (!this._sampler.shouldEmit(level, traceId$1)) return;
1614
- }
1615
1686
  const alsContext = require_async_context.LogixiaContext.get();
1687
+ let activeTraceId;
1688
+ if (this.config.traceId) {
1689
+ const ctxTraceId = alsContext === null || alsContext === void 0 ? void 0 : alsContext.traceId;
1690
+ activeTraceId = require_request_trace.TraceContext.instance.getCurrentTraceId() ?? (typeof ctxTraceId === "string" ? ctxTraceId : void 0);
1691
+ }
1692
+ if (this._sampler && !this._sampler.shouldEmit(level, activeTraceId)) return;
1616
1693
  const hasAls = alsContext !== void 0 && Object.keys(alsContext).length > 0;
1617
1694
  const otelFields = _isOtelBridgeEnabled() ? _getOtelPayloadIfEnabled() : void 0;
1618
1695
  const hasOtel = otelFields !== void 0 && Object.keys(otelFields).length > 0;
@@ -1632,14 +1709,16 @@ var LogixiaLogger = class LogixiaLogger {
1632
1709
  ...mergedData
1633
1710
  } : mergedData;
1634
1711
  let payload;
1635
- if (rawPayload !== void 0 && rawPayload !== null) if (this._hasRedact) try {
1636
- payload = applyRedaction(rawPayload, this.config.redact) ?? rawPayload;
1637
- } catch (error) {
1638
- require_internal_log.internalError("Redaction failed", error);
1639
- payload = { redaction: REDACTION_FAILED };
1712
+ if (rawPayload !== void 0 && rawPayload !== null) {
1713
+ if (this._hasRedact) try {
1714
+ payload = applyRedaction(rawPayload, this.config.redact) ?? rawPayload;
1715
+ } catch (error) {
1716
+ require_internal_log.internalError("Redaction failed", error);
1717
+ payload = { redaction: REDACTION_FAILED };
1718
+ }
1719
+ else payload = rawPayload;
1640
1720
  }
1641
- else payload = rawPayload;
1642
- const traceId = this.config.traceId ? require_trace_utils.TraceContext.instance.getCurrentTraceId() ?? this.fallbackTraceId : void 0;
1721
+ const traceId = this.config.traceId ? activeTraceId ?? this.fallbackTraceId : void 0;
1643
1722
  let safeMessage = message;
1644
1723
  if (this._hasRedact) try {
1645
1724
  safeMessage = applyRedactionToString(message, this.config.redact);
@@ -1677,12 +1756,14 @@ var LogixiaLogger = class LogixiaLogger {
1677
1756
  * Feature 3: Resolve the effective log level for this logger instance.
1678
1757
  *
1679
1758
  * Priority:
1759
+ * 0. A level set at runtime with `setLevel()` (explicit programmatic call, wins over all below)
1680
1760
  * 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
1681
1761
  * 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
1682
1762
  * 3. Global `LOGIXIA_LEVEL` ENV override
1683
1763
  * 4. `levelOptions.level` (resolved via Feature 5 in constructor)
1684
1764
  */
1685
1765
  resolveEffectiveLevel() {
1766
+ if (this._runtimeLevel) return this._runtimeLevel;
1686
1767
  const ns = this.context;
1687
1768
  if (ns) {
1688
1769
  const nsKey = ns.split(".")[0].toUpperCase();
@@ -1756,6 +1837,22 @@ var LogixiaLogger = class LogixiaLogger {
1756
1837
  (level === LogLevel.ERROR ? process.stderr : process.stdout).write(this.formatLog(entry) + "\n");
1757
1838
  }
1758
1839
  };
1840
+ /**
1841
+ * Create a logger from `config`, with an optional default `context` label.
1842
+ *
1843
+ * Every key of `levelOptions.levels` that is not already a method becomes an
1844
+ * async method on the returned logger, typed through the config, and routes to
1845
+ * {@link LogixiaLogger.logLevel}.
1846
+ *
1847
+ * @example
1848
+ * ```ts
1849
+ * const logger = createLogger({
1850
+ * appName: 'api',
1851
+ * levelOptions: { level: 'info', levels: { error: 0, warn: 1, info: 2, audit: 2 } },
1852
+ * });
1853
+ * await logger.audit('user exported data', { userId: 'u1' });
1854
+ * ```
1855
+ */
1759
1856
  function createLogger(config, context) {
1760
1857
  var _config$levelOptions3;
1761
1858
  const logger = new LogixiaLogger(config, context);
@@ -1767,9 +1864,7 @@ function createLogger(config, context) {
1767
1864
  }
1768
1865
  return logger;
1769
1866
  }
1770
-
1771
- //#endregion
1772
- //#region src/exceptions/exception.ts
1867
+ // src/exceptions/exception.ts
1773
1868
  var LogixiaException = class extends Error {
1774
1869
  constructor(options) {
1775
1870
  super(options.message, { cause: options.cause });
@@ -1800,9 +1895,21 @@ var LogixiaException = class extends Error {
1800
1895
  function isLogixiaException(value) {
1801
1896
  return value instanceof LogixiaException;
1802
1897
  }
1803
-
1804
- //#endregion
1805
- //#region src/exceptions/builder.ts
1898
+ // src/exceptions/builder.ts
1899
+ /**
1900
+ * ErrorResponseBuilder — turns any exception into a `LogixiaErrorResponse`.
1901
+ *
1902
+ * Priority order:
1903
+ * 1. `LogixiaException` — typed fields used directly
1904
+ * 2. NestJS `HttpException` — duck-typed; status + message extracted
1905
+ * 3. Plain `Error` / unknown — falls back to 500 `server_error`
1906
+ *
1907
+ * The builder **always** populates `debug` when possible.
1908
+ * Your exception filter is responsible for stripping it in production:
1909
+ * ```ts
1910
+ * if (process.env.NODE_ENV === 'production') delete response.debug;
1911
+ * ```
1912
+ */
1806
1913
  /**
1807
1914
  * Generates a trace ID via the shared {@link TraceContext} generator.
1808
1915
  *
@@ -1813,7 +1920,7 @@ function isLogixiaException(value) {
1813
1920
  * @example `'550e8400-e29b-41d4-a716-446655440000'`
1814
1921
  */
1815
1922
  function generateTraceId() {
1816
- return require_trace_utils.TraceContext.instance.generate();
1923
+ return require_request_trace.TraceContext.instance.generate();
1817
1924
  }
1818
1925
  /** @deprecated Use `generateTraceId` instead. */
1819
1926
  const generateRequestId = generateTraceId;
@@ -1900,11 +2007,11 @@ var ErrorResponseBuilder = class {
1900
2007
  debug: exposeDebug,
1901
2008
  cause: exposeCause
1902
2009
  };
1903
- const traceId = require_trace_utils.TraceContext.instance.getCurrentTraceId() ?? rawTraceId;
2010
+ const traceId = require_request_trace.TraceContext.instance.getCurrentTraceId() ?? rawTraceId;
1904
2011
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
1905
2012
  const durationMs = startTime !== void 0 ? Date.now() - startTime : void 0;
1906
2013
  if (isLogixiaException(exception)) {
1907
- const debug$1 = buildDebug(exception, service, durationMs, expose);
2014
+ const debug = buildDebug(exception, service, durationMs, expose);
1908
2015
  const errorBlock = {
1909
2016
  type: exception.errorType,
1910
2017
  code: exception.errorCode,
@@ -1923,7 +2030,7 @@ var ErrorResponseBuilder = class {
1923
2030
  path,
1924
2031
  status: exception.httpStatus
1925
2032
  },
1926
- ...debug$1 !== void 0 ? { debug: debug$1 } : {}
2033
+ ...debug !== void 0 ? { debug } : {}
1927
2034
  },
1928
2035
  httpStatus: exception.httpStatus
1929
2036
  };
@@ -1939,7 +2046,7 @@ var ErrorResponseBuilder = class {
1939
2046
  } else message = exception.message;
1940
2047
  const type = httpStatusToType(status);
1941
2048
  const code = `HTTP_${status}`;
1942
- const debug$1 = buildDebug(exception, service, durationMs, expose);
2049
+ const debug = buildDebug(exception, service, durationMs, expose);
1943
2050
  return {
1944
2051
  response: {
1945
2052
  success: false,
@@ -1954,7 +2061,7 @@ var ErrorResponseBuilder = class {
1954
2061
  path,
1955
2062
  status
1956
2063
  },
1957
- ...debug$1 !== void 0 ? { debug: debug$1 } : {}
2064
+ ...debug !== void 0 ? { debug } : {}
1958
2065
  },
1959
2066
  httpStatus: status
1960
2067
  };
@@ -1980,174 +2087,173 @@ var ErrorResponseBuilder = class {
1980
2087
  };
1981
2088
  }
1982
2089
  };
1983
-
1984
- //#endregion
1985
- Object.defineProperty(exports, 'DEFAULT_CONFIG', {
1986
- enumerable: true,
1987
- get: function () {
1988
- return DEFAULT_CONFIG;
1989
- }
2090
+ Object.defineProperty(exports, "DEFAULT_CONFIG", {
2091
+ enumerable: true,
2092
+ get: function() {
2093
+ return DEFAULT_CONFIG;
2094
+ }
1990
2095
  });
1991
- Object.defineProperty(exports, 'DEFAULT_LOG_COLORS', {
1992
- enumerable: true,
1993
- get: function () {
1994
- return DEFAULT_LOG_COLORS;
1995
- }
2096
+ Object.defineProperty(exports, "DEFAULT_LOG_COLORS", {
2097
+ enumerable: true,
2098
+ get: function() {
2099
+ return DEFAULT_LOG_COLORS;
2100
+ }
1996
2101
  });
1997
- Object.defineProperty(exports, 'DEFAULT_LOG_LEVELS', {
1998
- enumerable: true,
1999
- get: function () {
2000
- return DEFAULT_LOG_LEVELS;
2001
- }
2102
+ Object.defineProperty(exports, "DEFAULT_LOG_LEVELS", {
2103
+ enumerable: true,
2104
+ get: function() {
2105
+ return DEFAULT_LOG_LEVELS;
2106
+ }
2002
2107
  });
2003
- Object.defineProperty(exports, 'ErrorResponseBuilder', {
2004
- enumerable: true,
2005
- get: function () {
2006
- return ErrorResponseBuilder;
2007
- }
2108
+ Object.defineProperty(exports, "ErrorResponseBuilder", {
2109
+ enumerable: true,
2110
+ get: function() {
2111
+ return ErrorResponseBuilder;
2112
+ }
2008
2113
  });
2009
- Object.defineProperty(exports, 'LogLevel', {
2010
- enumerable: true,
2011
- get: function () {
2012
- return LogLevel;
2013
- }
2114
+ Object.defineProperty(exports, "LogLevel", {
2115
+ enumerable: true,
2116
+ get: function() {
2117
+ return LogLevel;
2118
+ }
2014
2119
  });
2015
- Object.defineProperty(exports, 'LogixiaException', {
2016
- enumerable: true,
2017
- get: function () {
2018
- return LogixiaException;
2019
- }
2120
+ Object.defineProperty(exports, "LogixiaException", {
2121
+ enumerable: true,
2122
+ get: function() {
2123
+ return LogixiaException;
2124
+ }
2020
2125
  });
2021
- Object.defineProperty(exports, 'LogixiaLogger', {
2022
- enumerable: true,
2023
- get: function () {
2024
- return LogixiaLogger;
2025
- }
2126
+ Object.defineProperty(exports, "LogixiaLogger", {
2127
+ enumerable: true,
2128
+ get: function() {
2129
+ return LogixiaLogger;
2130
+ }
2026
2131
  });
2027
- Object.defineProperty(exports, 'PluginRegistry', {
2028
- enumerable: true,
2029
- get: function () {
2030
- return PluginRegistry;
2031
- }
2132
+ Object.defineProperty(exports, "PluginRegistry", {
2133
+ enumerable: true,
2134
+ get: function() {
2135
+ return PluginRegistry;
2136
+ }
2032
2137
  });
2033
- Object.defineProperty(exports, '_shutdownRegistrySize', {
2034
- enumerable: true,
2035
- get: function () {
2036
- return _shutdownRegistrySize;
2037
- }
2138
+ Object.defineProperty(exports, "_shutdownRegistrySize", {
2139
+ enumerable: true,
2140
+ get: function() {
2141
+ return _shutdownRegistrySize;
2142
+ }
2038
2143
  });
2039
- Object.defineProperty(exports, 'applyRedaction', {
2040
- enumerable: true,
2041
- get: function () {
2042
- return applyRedaction;
2043
- }
2144
+ Object.defineProperty(exports, "applyRedaction", {
2145
+ enumerable: true,
2146
+ get: function() {
2147
+ return applyRedaction;
2148
+ }
2044
2149
  });
2045
- Object.defineProperty(exports, 'createLogger', {
2046
- enumerable: true,
2047
- get: function () {
2048
- return createLogger;
2049
- }
2150
+ Object.defineProperty(exports, "createLogger", {
2151
+ enumerable: true,
2152
+ get: function() {
2153
+ return createLogger;
2154
+ }
2050
2155
  });
2051
- Object.defineProperty(exports, 'deregisterFromShutdown', {
2052
- enumerable: true,
2053
- get: function () {
2054
- return deregisterFromShutdown;
2055
- }
2156
+ Object.defineProperty(exports, "deregisterFromShutdown", {
2157
+ enumerable: true,
2158
+ get: function() {
2159
+ return deregisterFromShutdown;
2160
+ }
2056
2161
  });
2057
- Object.defineProperty(exports, 'disableOtelBridge', {
2058
- enumerable: true,
2059
- get: function () {
2060
- return disableOtelBridge;
2061
- }
2162
+ Object.defineProperty(exports, "disableOtelBridge", {
2163
+ enumerable: true,
2164
+ get: function() {
2165
+ return disableOtelBridge;
2166
+ }
2062
2167
  });
2063
- Object.defineProperty(exports, 'flushOnExit', {
2064
- enumerable: true,
2065
- get: function () {
2066
- return flushOnExit;
2067
- }
2168
+ Object.defineProperty(exports, "flushOnExit", {
2169
+ enumerable: true,
2170
+ get: function() {
2171
+ return flushOnExit;
2172
+ }
2068
2173
  });
2069
- Object.defineProperty(exports, 'generateRequestId', {
2070
- enumerable: true,
2071
- get: function () {
2072
- return generateRequestId;
2073
- }
2174
+ Object.defineProperty(exports, "generateRequestId", {
2175
+ enumerable: true,
2176
+ get: function() {
2177
+ return generateRequestId;
2178
+ }
2074
2179
  });
2075
- Object.defineProperty(exports, 'generateTraceId', {
2076
- enumerable: true,
2077
- get: function () {
2078
- return generateTraceId;
2079
- }
2180
+ Object.defineProperty(exports, "generateTraceId", {
2181
+ enumerable: true,
2182
+ get: function() {
2183
+ return generateTraceId;
2184
+ }
2080
2185
  });
2081
- Object.defineProperty(exports, 'getActiveOtelContext', {
2082
- enumerable: true,
2083
- get: function () {
2084
- return getActiveOtelContext;
2085
- }
2186
+ Object.defineProperty(exports, "getActiveOtelContext", {
2187
+ enumerable: true,
2188
+ get: function() {
2189
+ return getActiveOtelContext;
2190
+ }
2086
2191
  });
2087
- Object.defineProperty(exports, 'getOtelMetaFields', {
2088
- enumerable: true,
2089
- get: function () {
2090
- return getOtelMetaFields;
2091
- }
2192
+ Object.defineProperty(exports, "getOtelMetaFields", {
2193
+ enumerable: true,
2194
+ get: function() {
2195
+ return getOtelMetaFields;
2196
+ }
2092
2197
  });
2093
- Object.defineProperty(exports, 'globalPluginRegistry', {
2094
- enumerable: true,
2095
- get: function () {
2096
- return globalPluginRegistry;
2097
- }
2198
+ Object.defineProperty(exports, "globalPluginRegistry", {
2199
+ enumerable: true,
2200
+ get: function() {
2201
+ return globalPluginRegistry;
2202
+ }
2098
2203
  });
2099
- Object.defineProperty(exports, 'initOtelBridge', {
2100
- enumerable: true,
2101
- get: function () {
2102
- return initOtelBridge;
2103
- }
2204
+ Object.defineProperty(exports, "initOtelBridge", {
2205
+ enumerable: true,
2206
+ get: function() {
2207
+ return initOtelBridge;
2208
+ }
2104
2209
  });
2105
- Object.defineProperty(exports, 'isError', {
2106
- enumerable: true,
2107
- get: function () {
2108
- return isError;
2109
- }
2210
+ Object.defineProperty(exports, "isError", {
2211
+ enumerable: true,
2212
+ get: function() {
2213
+ return isError;
2214
+ }
2110
2215
  });
2111
- Object.defineProperty(exports, 'isLogixiaException', {
2112
- enumerable: true,
2113
- get: function () {
2114
- return isLogixiaException;
2115
- }
2216
+ Object.defineProperty(exports, "isLogixiaException", {
2217
+ enumerable: true,
2218
+ get: function() {
2219
+ return isLogixiaException;
2220
+ }
2116
2221
  });
2117
- Object.defineProperty(exports, 'normalizeError', {
2118
- enumerable: true,
2119
- get: function () {
2120
- return normalizeError;
2121
- }
2222
+ Object.defineProperty(exports, "normalizeError", {
2223
+ enumerable: true,
2224
+ get: function() {
2225
+ return normalizeError;
2226
+ }
2122
2227
  });
2123
- Object.defineProperty(exports, 'redactObject', {
2124
- enumerable: true,
2125
- get: function () {
2126
- return redactObject;
2127
- }
2228
+ Object.defineProperty(exports, "redactObject", {
2229
+ enumerable: true,
2230
+ get: function() {
2231
+ return redactObject;
2232
+ }
2128
2233
  });
2129
- Object.defineProperty(exports, 'registerForShutdown', {
2130
- enumerable: true,
2131
- get: function () {
2132
- return registerForShutdown;
2133
- }
2234
+ Object.defineProperty(exports, "registerForShutdown", {
2235
+ enumerable: true,
2236
+ get: function() {
2237
+ return registerForShutdown;
2238
+ }
2134
2239
  });
2135
- Object.defineProperty(exports, 'resetShutdownHandlers', {
2136
- enumerable: true,
2137
- get: function () {
2138
- return resetShutdownHandlers;
2139
- }
2240
+ Object.defineProperty(exports, "resetShutdownHandlers", {
2241
+ enumerable: true,
2242
+ get: function() {
2243
+ return resetShutdownHandlers;
2244
+ }
2140
2245
  });
2141
- Object.defineProperty(exports, 'serializeError', {
2142
- enumerable: true,
2143
- get: function () {
2144
- return serializeError;
2145
- }
2246
+ Object.defineProperty(exports, "serializeError", {
2247
+ enumerable: true,
2248
+ get: function() {
2249
+ return serializeError;
2250
+ }
2146
2251
  });
2147
- Object.defineProperty(exports, 'usePlugin', {
2148
- enumerable: true,
2149
- get: function () {
2150
- return usePlugin;
2151
- }
2252
+ Object.defineProperty(exports, "usePlugin", {
2253
+ enumerable: true,
2254
+ get: function() {
2255
+ return usePlugin;
2256
+ }
2152
2257
  });
2153
- //# sourceMappingURL=builder-D44QktIo.js.map
2258
+
2259
+ //# sourceMappingURL=builder-M7NoaugM.js.map