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,14 +1,14 @@
1
- import { t as __require } from "./chunk-DLSkYcPk.mjs";
2
- import { n as internalLog, r as internalWarn, t as internalError } from "./internal-log-Cm8SOWSV.mjs";
3
- import { i as stringifyForLog } from "./safe-stringify-DJ66tW5I.mjs";
4
- import { i as TraceContext } from "./trace.utils-CvXgaiQT.mjs";
5
- import { t as LogixiaContext } from "./async-context-BzJrbfQs.mjs";
6
- import { t as safeToString } from "./coerce.utils-Cu6IUTgX.mjs";
7
- import { d as stripControlChars, t as TransportManager } from "./transport.manager-BiuCAJd2.mjs";
8
- import { constants } from "node:os";
1
+ import { t as __require } from "./rolldown-runtime-D3PmRqjj.mjs";
2
+ import { o as TraceContext } from "./request-trace-C_fvIDv4.mjs";
3
+ import { t as LogixiaContext } from "./async-context-B05ArHgM.mjs";
4
+ import { n as internalLog, o as SENSITIVE_KEY_NAMES, r as internalWarn, t as internalError } from "./internal-log-uCSd1PMc.mjs";
5
+ import { n as protectSecrets } from "./secret-config-BegMLkYl.mjs";
6
+ import { t as safeToString } from "./coerce.utils-B_rEudCn.mjs";
7
+ import { i as stringifyForLog } from "./safe-stringify-BMRl3EX3.mjs";
8
+ import { d as stripControlChars, t as TransportManager } from "./transport.manager-eZ_EeC00.mjs";
9
9
  import buildFastStringify from "fast-json-stringify";
10
-
11
- //#region src/types/index.ts
10
+ import { constants } from "node:os";
11
+ // src/types/index.ts
12
12
  const LogLevel = {
13
13
  ERROR: "error",
14
14
  WARN: "warn",
@@ -33,9 +33,7 @@ const DEFAULT_LOG_COLORS = {
33
33
  trace: "magenta",
34
34
  verbose: "cyan"
35
35
  };
36
-
37
- //#endregion
38
- //#region src/core/default-config.ts
36
+ // src/core/default-config.ts
39
37
  /**
40
38
  * Default configuration for Logixia logger
41
39
  */
@@ -79,9 +77,7 @@ const DEFAULT_CONFIG = {
79
77
  },
80
78
  outputs: ["console"]
81
79
  };
82
-
83
- //#endregion
84
- //#region src/plugin.ts
80
+ // src/plugin.ts
85
81
  /**
86
82
  * Holds an ordered list of `LogixiaPlugin` instances and dispatches lifecycle
87
83
  * events to them. One registry is created per logger instance; a global
@@ -186,9 +182,7 @@ const globalPluginRegistry = new PluginRegistry();
186
182
  function usePlugin(plugin) {
187
183
  globalPluginRegistry.register(plugin);
188
184
  }
189
-
190
- //#endregion
191
- //#region src/utils/error.utils.ts
185
+ // src/utils/error.utils.ts
192
186
  const EXTRA_FIELDS = [
193
187
  "code",
194
188
  "statusCode",
@@ -230,13 +224,15 @@ function _serializeError(error, includeStack, maxDepth, excludeFields, depth, se
230
224
  };
231
225
  if (includeStack && error.stack) serialized.stack = error.stack;
232
226
  const errorWithCause = error;
233
- if (errorWithCause.cause !== void 0) if (errorWithCause.cause instanceof Error) serialized.cause = _serializeError(errorWithCause.cause, includeStack, maxDepth, excludeFields, depth + 1, seen);
234
- 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
+ }
235
231
  const aggregateError = error;
236
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));
237
233
  const errorRecord = error;
238
234
  for (const field of EXTRA_FIELDS) if (!excludeFields.includes(field) && field in error && errorRecord[field] !== void 0) serialized[field] = errorRecord[field];
239
- const skip = new Set([
235
+ const skip = /* @__PURE__ */ new Set([
240
236
  "name",
241
237
  "message",
242
238
  "stack",
@@ -318,9 +314,7 @@ function normalizeError(error) {
318
314
  }
319
315
  return new Error(String(error));
320
316
  }
321
-
322
- //#endregion
323
- //#region src/utils/otel.ts
317
+ // src/utils/otel.ts
324
318
  let _otelApi;
325
319
  function tryLoadOtelApi() {
326
320
  if (_otelApi !== void 0) return _otelApi;
@@ -425,9 +419,7 @@ function _getOtelPayloadIfEnabled() {
425
419
  function disableOtelBridge() {
426
420
  _bridgeOptions = null;
427
421
  }
428
-
429
- //#endregion
430
- //#region src/utils/redact.utils.ts
422
+ // src/utils/redact.utils.ts
431
423
  const DEFAULT_CENSOR = "[REDACTED]";
432
424
  /** Maximum nesting depth walked; deeper values are replaced with a marker. */
433
425
  const MAX_DEPTH = 32;
@@ -456,34 +448,7 @@ const PII_CONSERVATIVE_PATTERNS = [
456
448
  /**
457
449
  * Conservative field-name paths auto-redacted by name regardless of value.
458
450
  */
459
- const PII_CONSERVATIVE_PATHS = [
460
- "**.password",
461
- "**.passwd",
462
- "**.secret",
463
- "**.token",
464
- "**.apiKey",
465
- "**.api_key",
466
- "**.accessToken",
467
- "**.access_token",
468
- "**.refreshToken",
469
- "**.refresh_token",
470
- "**.authorization",
471
- "**.credentials",
472
- "**.privateKey",
473
- "**.private_key",
474
- "**.clientSecret",
475
- "**.client_secret",
476
- "**.cookie",
477
- "**.set-cookie",
478
- "**.x-api-key",
479
- "**.session",
480
- "**.proxy-authorization",
481
- "**.x-auth-token",
482
- "**.x-access-token",
483
- "**.aws_secret_access_key",
484
- "**.awsSecretAccessKey",
485
- "**.secretAccessKey"
486
- ];
451
+ const PII_CONSERVATIVE_PATHS = SENSITIVE_KEY_NAMES.map((name) => `**.${name}`);
487
452
  /**
488
453
  * Aggressive patterns: also catch personal data that could identify a person.
489
454
  * Applied when `autoDetect: 'aggressive'`.
@@ -695,7 +660,7 @@ function walkToJSON(obj, state, fullPath, bare, depth) {
695
660
  function redactObject(obj, config, _currentPath = "") {
696
661
  const result = walkRecord(obj, {
697
662
  config,
698
- ancestors: new Set([obj]),
663
+ ancestors: /* @__PURE__ */ new Set([obj]),
699
664
  nodes: 0
700
665
  }, _currentPath, _currentPath, 0);
701
666
  return result === obj ? { ...obj } : result;
@@ -744,10 +709,8 @@ function isPlainObject(value) {
744
709
  if (ArrayBuffer.isView(value)) return false;
745
710
  return !OPAQUE_BUILTINS.some((ctor) => value instanceof ctor);
746
711
  }
747
-
748
- //#endregion
749
- //#region src/utils/sampling.utils.ts
750
- const ALWAYS_EMIT_LEVELS = new Set([
712
+ // src/utils/sampling.utils.ts
713
+ const ALWAYS_EMIT_LEVELS = /* @__PURE__ */ new Set([
751
714
  "error",
752
715
  "warn",
753
716
  "fatal"
@@ -765,8 +728,8 @@ var Sampler = class {
765
728
  constructor(config, onStats) {
766
729
  this.traceDecisions = /* @__PURE__ */ new Map();
767
730
  this.maxTrackedTraces = 1e5;
768
- this.traceTtlMs = 5 * 6e4;
769
- this.traceMaxLifetimeMs = 60 * 6e4;
731
+ this.traceTtlMs = 3e5;
732
+ this.traceMaxLifetimeMs = 36e5;
770
733
  this._tokenBucket = 0;
771
734
  this._lastRefillMs = Date.now();
772
735
  this._adaptiveWindow = [];
@@ -945,9 +908,14 @@ var Sampler = class {
945
908
  this._stats.dropped++;
946
909
  }
947
910
  };
948
-
949
- //#endregion
950
- //#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
+ */
951
919
  const MAX_BEFORE_EXIT_FLUSHES = 5;
952
920
  /** Module-level registry of all logger instances that have opted into graceful shutdown */
953
921
  const registry = /* @__PURE__ */ new Set();
@@ -1067,9 +1035,17 @@ function resetShutdownHandlers() {
1067
1035
  shutdownHandlerRegistered = false;
1068
1036
  shutdownInProgress = false;
1069
1037
  }
1070
-
1071
- //#endregion
1072
- //#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
+ */
1073
1049
  const _fastStringifyEntry = buildFastStringify({
1074
1050
  type: "object",
1075
1051
  properties: {
@@ -1099,7 +1075,7 @@ function nowIso() {
1099
1075
  }
1100
1076
  function namespacePatternToRegex(pattern) {
1101
1077
  const escaped = pattern.split(".").map((s) => s === "*" ? "[^.]+" : s.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")).join("\\.");
1102
- return /* @__PURE__ */ new RegExp(`^${escaped}$`);
1078
+ return new RegExp(`^${escaped}$`);
1103
1079
  }
1104
1080
  /** Max compiled patterns to keep in memory. Oldest entry is evicted when full. */
1105
1081
  const _NS_CACHE_MAX = 1e3;
@@ -1141,7 +1117,7 @@ function canonicalLevel(level, known) {
1141
1117
  function resolveInitialLevel(config) {
1142
1118
  var _config$levelOptions, _config$levelOptions2;
1143
1119
  const envLevel = process.env["LOGIXIA_LEVEL"];
1144
- 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) ?? {})]);
1145
1121
  if (envLevel && canonicalLevel(envLevel, knownLevels)) return envLevel;
1146
1122
  if ((_config$levelOptions2 = config.levelOptions) === null || _config$levelOptions2 === void 0 ? void 0 : _config$levelOptions2.level) return config.levelOptions.level;
1147
1123
  const nodeEnv = process.env["NODE_ENV"];
@@ -1151,6 +1127,19 @@ function resolveInitialLevel(config) {
1151
1127
  if (process.env["CI"]) return LogLevel.INFO;
1152
1128
  return LogLevel.INFO;
1153
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
+ */
1154
1143
  var LogixiaLogger = class LogixiaLogger {
1155
1144
  constructor(config, context, parent) {
1156
1145
  this.timers = /* @__PURE__ */ new Map();
@@ -1168,7 +1157,7 @@ var LogixiaLogger = class LogixiaLogger {
1168
1157
  this._hasRedact = false;
1169
1158
  this._parent = parent;
1170
1159
  this._pluginRegistry = parent ? parent._pluginRegistry : new PluginRegistry();
1171
- this.config = {
1160
+ const defaultConfig = {
1172
1161
  appName: "App",
1173
1162
  environment: "development",
1174
1163
  traceId: true,
@@ -1196,7 +1185,10 @@ var LogixiaLogger = class LogixiaLogger {
1196
1185
  [LogLevel.TRACE]: "gray",
1197
1186
  [LogLevel.VERBOSE]: "cyan"
1198
1187
  }
1199
- },
1188
+ }
1189
+ };
1190
+ this.config = {
1191
+ ...defaultConfig,
1200
1192
  ...config
1201
1193
  };
1202
1194
  const resolvedLevel = resolveInitialLevel(this.config);
@@ -1214,6 +1206,7 @@ var LogixiaLogger = class LogixiaLogger {
1214
1206
  timeTaken: "[time_taken_MS]"
1215
1207
  };
1216
1208
  this.context = context ?? "";
1209
+ protectSecrets(this, ["config"]);
1217
1210
  if (parent) {
1218
1211
  this.transportManager = parent.transportManager;
1219
1212
  this._sampler = parent._sampler;
@@ -1279,7 +1272,7 @@ var LogixiaLogger = class LogixiaLogger {
1279
1272
  this.config.levelOptions.level = this._validLevel(this.config.levelOptions.level, "levelOptions.level") ?? LogLevel.INFO;
1280
1273
  const effectiveLevel = this.resolveEffectiveLevel();
1281
1274
  this._minLevelValue = this._levelValues.get(effectiveLevel) ?? 2;
1282
- this._colorMap = new Map([
1275
+ this._colorMap = /* @__PURE__ */ new Map([
1283
1276
  ["black", "\x1B[30m"],
1284
1277
  ["red", "\x1B[31m"],
1285
1278
  ["green", "\x1B[32m"],
@@ -1322,7 +1315,7 @@ var LogixiaLogger = class LogixiaLogger {
1322
1315
  "green",
1323
1316
  "blue"
1324
1317
  ];
1325
- const _BUILTIN_LEVELS = new Set([
1318
+ const _BUILTIN_LEVELS = /* @__PURE__ */ new Set([
1326
1319
  "error",
1327
1320
  "warn",
1328
1321
  "info",
@@ -1336,10 +1329,12 @@ var LogixiaLogger = class LogixiaLogger {
1336
1329
  if (colorize && this._fieldCache.get("level") !== false) {
1337
1330
  var _this$config$levelOpt4;
1338
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];
1339
- if (!colorName) if (_BUILTIN_LEVELS.has(lvl)) colorName = "white";
1340
- else {
1341
- colorName = _AUTO_PALETTE[_paletteIdx % _AUTO_PALETTE.length];
1342
- _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
+ }
1343
1338
  }
1344
1339
  const code = this._colorMap.get(colorName.toLowerCase()) ?? this._colorMap.get("white");
1345
1340
  const reset = this._colorMap.get("reset");
@@ -1351,6 +1346,11 @@ var LogixiaLogger = class LogixiaLogger {
1351
1346
  else this._formattedAppName = colorize ? `${this._colorMap.get("gray")}${appNameRaw}${this._colorMap.get("reset")} ` : `${appNameRaw} `;
1352
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));
1353
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
+ */
1354
1354
  async error(messageOrError, data) {
1355
1355
  if (isError(messageOrError)) await this.log("error", messageOrError.message, {
1356
1356
  ...data,
@@ -1358,30 +1358,53 @@ var LogixiaLogger = class LogixiaLogger {
1358
1358
  });
1359
1359
  else await this.log("error", messageOrError, data);
1360
1360
  }
1361
+ /** Log `message` at `warn` level; `data` is merged into the entry payload. */
1361
1362
  async warn(message, data) {
1362
1363
  await this.log("warn", message, data);
1363
1364
  }
1365
+ /** Log `message` at `info` level; `data` is merged into the entry payload. */
1364
1366
  async info(message, data) {
1365
1367
  await this.log("info", message, data);
1366
1368
  }
1369
+ /** Log `message` at `debug` level; `data` is merged into the entry payload. */
1367
1370
  async debug(message, data) {
1368
1371
  await this.log("debug", message, data);
1369
1372
  }
1373
+ /** Log `message` at `trace` level; `data` is merged into the entry payload. */
1370
1374
  async trace(message, data) {
1371
1375
  await this.log("trace", message, data);
1372
1376
  }
1377
+ /** Log `message` at `verbose` level; `data` is merged into the entry payload. */
1373
1378
  async verbose(message, data) {
1374
1379
  await this.log("verbose", message, data);
1375
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
+ */
1376
1386
  async logLevel(level, message, data) {
1377
1387
  await this.log(level, message, data);
1378
1388
  }
1389
+ /** Start a named timer; finish it with {@link timeEnd}. Reusing a label restarts it. */
1379
1390
  time(label) {
1380
1391
  this.timers.set(label, {
1381
1392
  label,
1382
1393
  startTime: Date.now()
1383
1394
  });
1384
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
+ */
1385
1408
  async timeEnd(label) {
1386
1409
  const timer = this.timers.get(label);
1387
1410
  if (!timer) {
@@ -1411,6 +1434,17 @@ var LogixiaLogger = class LogixiaLogger {
1411
1434
  throw error;
1412
1435
  }
1413
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
+ */
1414
1448
  setLevel(level) {
1415
1449
  const canonical = canonicalLevel(level, this._levelValues);
1416
1450
  if (canonical === void 0) {
@@ -1419,9 +1453,14 @@ var LogixiaLogger = class LogixiaLogger {
1419
1453
  }
1420
1454
  this.config.levelOptions = this.config.levelOptions ?? {};
1421
1455
  this.config.levelOptions.level = canonical;
1422
- this._minLevelValue = this._levelValues.get(canonical) ?? this._minLevelValue;
1456
+ this._runtimeLevel = canonical;
1423
1457
  this._buildPerfCaches();
1424
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
+ */
1425
1464
  getLevel() {
1426
1465
  var _this$config$levelOpt5;
1427
1466
  return ((_this$config$levelOpt5 = this.config.levelOptions) === null || _this$config$levelOpt5 === void 0 ? void 0 : _this$config$levelOpt5.level) ?? LogLevel.INFO;
@@ -1475,30 +1514,36 @@ var LogixiaLogger = class LogixiaLogger {
1475
1514
  getNamespaceLevels() {
1476
1515
  return { ...this.config.namespaceLevels };
1477
1516
  }
1517
+ /** Set the context label (e.g. a class or module name) attached to every subsequent entry. */
1478
1518
  setContext(context) {
1479
1519
  this.context = typeof context === "string" ? context : safeToString(context);
1480
1520
  }
1521
+ /** Return the current context label, or `undefined` if none is set. */
1481
1522
  getContext() {
1482
1523
  return this.context;
1483
1524
  }
1525
+ /** Show `fieldName` in log output, overriding the config for this logger instance. */
1484
1526
  enableField(fieldName) {
1485
1527
  this.fieldState.set(fieldName, true);
1486
1528
  this._fieldCache.set(fieldName, true);
1487
1529
  if (fieldName === "level" || fieldName === "appName") this._buildPerfCaches();
1488
1530
  internalLog(`Field '${fieldName}' enabled`);
1489
1531
  }
1532
+ /** Hide `fieldName` from log output, overriding the config for this logger instance. */
1490
1533
  disableField(fieldName) {
1491
1534
  this.fieldState.set(fieldName, false);
1492
1535
  this._fieldCache.set(fieldName, false);
1493
1536
  if (fieldName === "level" || fieldName === "appName") this._buildPerfCaches();
1494
1537
  internalLog(`Field '${fieldName}' disabled`);
1495
1538
  }
1539
+ /** Whether `fieldName` is currently shown: runtime override first, then config, default `true`. */
1496
1540
  isFieldEnabled(fieldName) {
1497
1541
  var _this$config$fields2;
1498
1542
  if (this.fieldState.has(fieldName)) return this.fieldState.get(fieldName);
1499
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;
1500
1544
  return true;
1501
1545
  }
1546
+ /** Return the visibility (`true` = shown) of every standard log field. */
1502
1547
  getFieldState() {
1503
1548
  return Object.fromEntries([
1504
1549
  "timestamp",
@@ -1515,6 +1560,7 @@ var LogixiaLogger = class LogixiaLogger {
1515
1560
  "environment"
1516
1561
  ].map((f) => [f, this.isFieldEnabled(f)]));
1517
1562
  }
1563
+ /** Drop all runtime enable/disable overrides so field visibility follows the config again. */
1518
1564
  resetFieldState() {
1519
1565
  this.fieldState.clear();
1520
1566
  internalLog("Field state reset to configuration defaults");
@@ -1529,10 +1575,12 @@ var LogixiaLogger = class LogixiaLogger {
1529
1575
  if (this.transportManager) this.transportManager.disableLevelPrompting();
1530
1576
  else internalWarn("Transport manager not initialized");
1531
1577
  }
1578
+ /** Restrict `transportId` to only the given `levels`. Warns if no transports are configured. */
1532
1579
  setTransportLevels(transportId, levels) {
1533
1580
  if (this.transportManager) this.transportManager.setTransportLevels(transportId, levels);
1534
1581
  else internalWarn("Transport manager not initialized");
1535
1582
  }
1583
+ /** Return the levels `transportId` is restricted to, or `undefined` if it has none. */
1536
1584
  getTransportLevels(transportId) {
1537
1585
  if (this.transportManager) return this.transportManager.getTransportLevels(transportId);
1538
1586
  internalWarn("Transport manager not initialized");
@@ -1541,10 +1589,23 @@ var LogixiaLogger = class LogixiaLogger {
1541
1589
  if (this.transportManager) this.transportManager.clearTransportLevelPreferences();
1542
1590
  else internalWarn("Transport manager not initialized");
1543
1591
  }
1592
+ /** Return the identifiers of the configured transports (empty if none). */
1544
1593
  getAvailableTransports() {
1545
1594
  var _this$transportManage;
1546
1595
  return ((_this$transportManage = this.transportManager) === null || _this$transportManage === void 0 ? void 0 : _this$transportManage.getTransports()) ?? [];
1547
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
+ */
1548
1609
  child(context, data) {
1549
1610
  const childLogger = new LogixiaLogger(this.config, context, this);
1550
1611
  const mergedContextData = {
@@ -1580,9 +1641,11 @@ var LogixiaLogger = class LogixiaLogger {
1580
1641
  this._pluginRegistry.unregister(pluginName);
1581
1642
  return this;
1582
1643
  }
1644
+ /** Flush buffered entries in all transports without closing them. */
1583
1645
  async flush() {
1584
1646
  if (this.transportManager) await this.transportManager.flush();
1585
1647
  }
1648
+ /** Report whether the transports are healthy; `healthy: false` if no transport manager exists. */
1586
1649
  async healthCheck() {
1587
1650
  if (!this.transportManager) return {
1588
1651
  healthy: false,
@@ -1590,6 +1653,20 @@ var LogixiaLogger = class LogixiaLogger {
1590
1653
  };
1591
1654
  return this.transportManager.healthCheck();
1592
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
+ */
1593
1670
  async close() {
1594
1671
  var _this$_sampler;
1595
1672
  for (const [label, timer] of this.timers) await this.warn(`Timer '${label}' was not ended properly`, {
@@ -1606,11 +1683,13 @@ var LogixiaLogger = class LogixiaLogger {
1606
1683
  async log(level, message, data) {
1607
1684
  if (this.config.silent) return;
1608
1685
  if (!this.shouldLog(level)) return;
1609
- if (this._sampler) {
1610
- const traceId$1 = this.config.traceId ? TraceContext.instance.getCurrentTraceId() : void 0;
1611
- if (!this._sampler.shouldEmit(level, traceId$1)) return;
1612
- }
1613
1686
  const alsContext = LogixiaContext.get();
1687
+ let activeTraceId;
1688
+ if (this.config.traceId) {
1689
+ const ctxTraceId = alsContext === null || alsContext === void 0 ? void 0 : alsContext.traceId;
1690
+ activeTraceId = TraceContext.instance.getCurrentTraceId() ?? (typeof ctxTraceId === "string" ? ctxTraceId : void 0);
1691
+ }
1692
+ if (this._sampler && !this._sampler.shouldEmit(level, activeTraceId)) return;
1614
1693
  const hasAls = alsContext !== void 0 && Object.keys(alsContext).length > 0;
1615
1694
  const otelFields = _isOtelBridgeEnabled() ? _getOtelPayloadIfEnabled() : void 0;
1616
1695
  const hasOtel = otelFields !== void 0 && Object.keys(otelFields).length > 0;
@@ -1630,14 +1709,16 @@ var LogixiaLogger = class LogixiaLogger {
1630
1709
  ...mergedData
1631
1710
  } : mergedData;
1632
1711
  let payload;
1633
- if (rawPayload !== void 0 && rawPayload !== null) if (this._hasRedact) try {
1634
- payload = applyRedaction(rawPayload, this.config.redact) ?? rawPayload;
1635
- } catch (error) {
1636
- internalError("Redaction failed", error);
1637
- 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
+ internalError("Redaction failed", error);
1717
+ payload = { redaction: REDACTION_FAILED };
1718
+ }
1719
+ else payload = rawPayload;
1638
1720
  }
1639
- else payload = rawPayload;
1640
- const traceId = this.config.traceId ? TraceContext.instance.getCurrentTraceId() ?? this.fallbackTraceId : void 0;
1721
+ const traceId = this.config.traceId ? activeTraceId ?? this.fallbackTraceId : void 0;
1641
1722
  let safeMessage = message;
1642
1723
  if (this._hasRedact) try {
1643
1724
  safeMessage = applyRedactionToString(message, this.config.redact);
@@ -1675,12 +1756,14 @@ var LogixiaLogger = class LogixiaLogger {
1675
1756
  * Feature 3: Resolve the effective log level for this logger instance.
1676
1757
  *
1677
1758
  * Priority:
1759
+ * 0. A level set at runtime with `setLevel()` (explicit programmatic call, wins over all below)
1678
1760
  * 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
1679
1761
  * 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
1680
1762
  * 3. Global `LOGIXIA_LEVEL` ENV override
1681
1763
  * 4. `levelOptions.level` (resolved via Feature 5 in constructor)
1682
1764
  */
1683
1765
  resolveEffectiveLevel() {
1766
+ if (this._runtimeLevel) return this._runtimeLevel;
1684
1767
  const ns = this.context;
1685
1768
  if (ns) {
1686
1769
  const nsKey = ns.split(".")[0].toUpperCase();
@@ -1754,6 +1837,22 @@ var LogixiaLogger = class LogixiaLogger {
1754
1837
  (level === LogLevel.ERROR ? process.stderr : process.stdout).write(this.formatLog(entry) + "\n");
1755
1838
  }
1756
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
+ */
1757
1856
  function createLogger(config, context) {
1758
1857
  var _config$levelOptions3;
1759
1858
  const logger = new LogixiaLogger(config, context);
@@ -1765,9 +1864,7 @@ function createLogger(config, context) {
1765
1864
  }
1766
1865
  return logger;
1767
1866
  }
1768
-
1769
- //#endregion
1770
- //#region src/exceptions/exception.ts
1867
+ // src/exceptions/exception.ts
1771
1868
  var LogixiaException = class extends Error {
1772
1869
  constructor(options) {
1773
1870
  super(options.message, { cause: options.cause });
@@ -1798,9 +1895,21 @@ var LogixiaException = class extends Error {
1798
1895
  function isLogixiaException(value) {
1799
1896
  return value instanceof LogixiaException;
1800
1897
  }
1801
-
1802
- //#endregion
1803
- //#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
+ */
1804
1913
  /**
1805
1914
  * Generates a trace ID via the shared {@link TraceContext} generator.
1806
1915
  *
@@ -1902,7 +2011,7 @@ var ErrorResponseBuilder = class {
1902
2011
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
1903
2012
  const durationMs = startTime !== void 0 ? Date.now() - startTime : void 0;
1904
2013
  if (isLogixiaException(exception)) {
1905
- const debug$1 = buildDebug(exception, service, durationMs, expose);
2014
+ const debug = buildDebug(exception, service, durationMs, expose);
1906
2015
  const errorBlock = {
1907
2016
  type: exception.errorType,
1908
2017
  code: exception.errorCode,
@@ -1921,7 +2030,7 @@ var ErrorResponseBuilder = class {
1921
2030
  path,
1922
2031
  status: exception.httpStatus
1923
2032
  },
1924
- ...debug$1 !== void 0 ? { debug: debug$1 } : {}
2033
+ ...debug !== void 0 ? { debug } : {}
1925
2034
  },
1926
2035
  httpStatus: exception.httpStatus
1927
2036
  };
@@ -1937,7 +2046,7 @@ var ErrorResponseBuilder = class {
1937
2046
  } else message = exception.message;
1938
2047
  const type = httpStatusToType(status);
1939
2048
  const code = `HTTP_${status}`;
1940
- const debug$1 = buildDebug(exception, service, durationMs, expose);
2049
+ const debug = buildDebug(exception, service, durationMs, expose);
1941
2050
  return {
1942
2051
  response: {
1943
2052
  success: false,
@@ -1952,7 +2061,7 @@ var ErrorResponseBuilder = class {
1952
2061
  path,
1953
2062
  status
1954
2063
  },
1955
- ...debug$1 !== void 0 ? { debug: debug$1 } : {}
2064
+ ...debug !== void 0 ? { debug } : {}
1956
2065
  },
1957
2066
  httpStatus: status
1958
2067
  };
@@ -1978,7 +2087,6 @@ var ErrorResponseBuilder = class {
1978
2087
  };
1979
2088
  }
1980
2089
  };
1981
-
1982
- //#endregion
1983
2090
  export { globalPluginRegistry as C, DEFAULT_LOG_LEVELS as D, DEFAULT_LOG_COLORS as E, LogLevel as O, PluginRegistry as S, DEFAULT_CONFIG as T, getOtelMetaFields as _, isLogixiaException as a, normalizeError as b, _shutdownRegistrySize as c, registerForShutdown as d, resetShutdownHandlers as f, getActiveOtelContext as g, disableOtelBridge as h, LogixiaException as i, deregisterFromShutdown as l, redactObject as m, generateRequestId as n, LogixiaLogger as o, applyRedaction as p, generateTraceId as r, createLogger as s, ErrorResponseBuilder as t, flushOnExit as u, initOtelBridge as v, usePlugin as w, serializeError as x, isError as y };
1984
- //# sourceMappingURL=builder-0gEzRopq.mjs.map
2091
+
2092
+ //# sourceMappingURL=builder-D70z6kjj.mjs.map