@mks2508/better-logger 0.18.2-alpha.1 → 0.18.3

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 (207) hide show
  1. package/README.md +38 -336
  2. package/dist/Logger.d.ts +356 -157
  3. package/dist/Logger.d.ts.map +1 -1
  4. package/dist/ScopedLogger.d.ts +549 -9
  5. package/dist/ScopedLogger.d.ts.map +1 -1
  6. package/dist/chunks/HookBridge-C-AvXmPD.cjs +504 -0
  7. package/dist/chunks/HookBridge-C-AvXmPD.cjs.map +1 -0
  8. package/dist/chunks/HookBridge-CI2PH79S.js +487 -0
  9. package/dist/chunks/HookBridge-CI2PH79S.js.map +1 -0
  10. package/dist/chunks/{LogContext-L7HzynFw.cjs → LogContext-BaMXleWj.cjs} +19 -4
  11. package/dist/chunks/LogContext-BaMXleWj.cjs.map +1 -0
  12. package/dist/chunks/LogContext-DZasm_P5.cjs +141 -0
  13. package/dist/chunks/LogContext-DZasm_P5.cjs.map +1 -0
  14. package/dist/chunks/{LogContext-Cwn-1Zzb.js → LogContext-DjlITOzZ.js} +19 -4
  15. package/dist/chunks/LogContext-DjlITOzZ.js.map +1 -0
  16. package/dist/chunks/LogContext-Dyzs61XG.js +136 -0
  17. package/dist/chunks/LogContext-Dyzs61XG.js.map +1 -0
  18. package/dist/chunks/SerializerBridge-Ba43Mk7j.js +393 -0
  19. package/dist/chunks/SerializerBridge-Ba43Mk7j.js.map +1 -0
  20. package/dist/chunks/SerializerBridge-C4a9Z37F.cjs +410 -0
  21. package/dist/chunks/SerializerBridge-C4a9Z37F.cjs.map +1 -0
  22. package/dist/chunks/{StyleManager-CIpd6wbO.cjs → StyleManager-DQ6UNRB-.cjs} +37 -11
  23. package/dist/chunks/StyleManager-DQ6UNRB-.cjs.map +1 -0
  24. package/dist/chunks/StyleManager-DjwAYbxE.js +113 -0
  25. package/dist/chunks/StyleManager-DjwAYbxE.js.map +1 -0
  26. package/dist/chunks/{core-PoT7RrTK.js → core-Blfi2klP.js} +1 -4
  27. package/dist/chunks/core-Blfi2klP.js.map +1 -0
  28. package/dist/chunks/{core-Dzz7agGa.cjs → core-CqS_UBzJ.cjs} +1 -4
  29. package/dist/chunks/core-CqS_UBzJ.cjs.map +1 -0
  30. package/dist/chunks/{environment-detector-CI3TrWK_.js → environment-detector-7NvnYUfr.js} +11 -11
  31. package/dist/chunks/environment-detector-7NvnYUfr.js.map +1 -0
  32. package/dist/chunks/{environment-detector-Cnn6wr6O.cjs → environment-detector-D-tHkKWA.cjs} +11 -11
  33. package/dist/chunks/environment-detector-D-tHkKWA.cjs.map +1 -0
  34. package/dist/chunks/server-fallback-CaCPjWby.cjs +119 -0
  35. package/dist/chunks/server-fallback-CaCPjWby.cjs.map +1 -0
  36. package/dist/chunks/server-fallback-jj0T6XaK.js +114 -0
  37. package/dist/chunks/server-fallback-jj0T6XaK.js.map +1 -0
  38. package/dist/chunks/{spinner-DNvxbM9a.cjs → spinner-BHyYEXsM.cjs} +319 -37
  39. package/dist/chunks/spinner-BHyYEXsM.cjs.map +1 -0
  40. package/dist/chunks/{spinner-D3FsF78o.js → spinner-BtkwpzYv.js} +319 -37
  41. package/dist/chunks/spinner-BtkwpzYv.js.map +1 -0
  42. package/dist/chunks/styling-CRw3KQW4.js +1592 -0
  43. package/dist/chunks/styling-CRw3KQW4.js.map +1 -0
  44. package/dist/chunks/styling-Cel2wPRy.cjs +1645 -0
  45. package/dist/chunks/styling-Cel2wPRy.cjs.map +1 -0
  46. package/dist/chunks/transports-BGfwwakw.js +1237 -0
  47. package/dist/chunks/transports-BGfwwakw.js.map +1 -0
  48. package/dist/chunks/transports-BZ-Mc2IT.cjs +1450 -0
  49. package/dist/chunks/transports-BZ-Mc2IT.cjs.map +1 -0
  50. package/dist/chunks/transports-DvaLAeGJ.js +1403 -0
  51. package/dist/chunks/transports-DvaLAeGJ.js.map +1 -0
  52. package/dist/chunks/transports-yK6CL0Ml.cjs +1278 -0
  53. package/dist/chunks/transports-yK6CL0Ml.cjs.map +1 -0
  54. package/dist/chunks/{utils-BqlFYocD.cjs → utils-W_cxqriN.cjs} +44 -37
  55. package/dist/chunks/utils-W_cxqriN.cjs.map +1 -0
  56. package/dist/chunks/{utils-VETbVpkR.js → utils-tKfBAWUM.js} +44 -37
  57. package/dist/chunks/utils-tKfBAWUM.js.map +1 -0
  58. package/dist/cli/CommandProcessor.d.ts +166 -19
  59. package/dist/cli/CommandProcessor.d.ts.map +1 -1
  60. package/dist/cli/commands/ConfigCommand.d.ts +36 -1
  61. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -1
  62. package/dist/cli/commands/ExportCommand.d.ts +49 -3
  63. package/dist/cli/commands/ExportCommand.d.ts.map +1 -1
  64. package/dist/cli/commands/ThemeCommand.d.ts +62 -3
  65. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -1
  66. package/dist/cli/help.d.ts +30 -2
  67. package/dist/cli/help.d.ts.map +1 -1
  68. package/dist/cli/index.d.ts +29 -2
  69. package/dist/cli/index.d.ts.map +1 -1
  70. package/dist/cli.cjs +2 -2
  71. package/dist/cli.js +2 -2
  72. package/dist/context/LogContext.d.ts +167 -70
  73. package/dist/context/LogContext.d.ts.map +1 -1
  74. package/dist/context.cjs +1 -1
  75. package/dist/context.js +1 -1
  76. package/dist/core.cjs +52 -29
  77. package/dist/core.cjs.map +1 -1
  78. package/dist/core.d.ts +50 -27
  79. package/dist/core.d.ts.map +1 -1
  80. package/dist/core.js +52 -29
  81. package/dist/core.js.map +1 -1
  82. package/dist/hooks/HookBridge.d.ts +15 -9
  83. package/dist/hooks/HookBridge.d.ts.map +1 -1
  84. package/dist/hooks/HookManager.d.ts +295 -2
  85. package/dist/hooks/HookManager.d.ts.map +1 -1
  86. package/dist/hooks.cjs +1 -1
  87. package/dist/hooks.js +1 -1
  88. package/dist/index.cjs +1415 -214
  89. package/dist/index.cjs.map +1 -1
  90. package/dist/index.d.ts +5 -1
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +1413 -215
  93. package/dist/index.js.map +1 -1
  94. package/dist/playground/TerminalBridge.d.ts +23 -16
  95. package/dist/playground/TerminalBridge.d.ts.map +1 -1
  96. package/dist/playground/box.d.ts +36 -5
  97. package/dist/playground/box.d.ts.map +1 -1
  98. package/dist/playground/cli-table.d.ts +41 -5
  99. package/dist/playground/cli-table.d.ts.map +1 -1
  100. package/dist/playground/divider.d.ts +22 -3
  101. package/dist/playground/divider.d.ts.map +1 -1
  102. package/dist/playground/header.d.ts +21 -4
  103. package/dist/playground/header.d.ts.map +1 -1
  104. package/dist/playground/server-fallback.d.ts +96 -9
  105. package/dist/playground/server-fallback.d.ts.map +1 -1
  106. package/dist/playground/spinner.d.ts +159 -10
  107. package/dist/playground/spinner.d.ts.map +1 -1
  108. package/dist/playground/step.d.ts +25 -6
  109. package/dist/playground/step.d.ts.map +1 -1
  110. package/dist/playground.cjs +1 -1
  111. package/dist/playground.js +1 -1
  112. package/dist/serializers/SerializerBridge.d.ts +13 -6
  113. package/dist/serializers/SerializerBridge.d.ts.map +1 -1
  114. package/dist/serializers/SerializerRegistry.d.ts +236 -0
  115. package/dist/serializers/SerializerRegistry.d.ts.map +1 -1
  116. package/dist/serializers.cjs +1 -1
  117. package/dist/serializers.js +1 -1
  118. package/dist/styles/StyleManager.d.ts +138 -31
  119. package/dist/styles/StyleManager.d.ts.map +1 -1
  120. package/dist/styles.cjs +2 -2
  121. package/dist/styles.js +2 -2
  122. package/dist/styling/SmartPresets.d.ts +100 -6
  123. package/dist/styling/SmartPresets.d.ts.map +1 -1
  124. package/dist/styling/StyleBuilder.d.ts +453 -32
  125. package/dist/styling/StyleBuilder.d.ts.map +1 -1
  126. package/dist/styling/banners.d.ts +83 -7
  127. package/dist/styling/banners.d.ts.map +1 -1
  128. package/dist/styling/themes.d.ts +41 -2
  129. package/dist/styling/themes.d.ts.map +1 -1
  130. package/dist/transports/ConsoleTransport.d.ts +95 -0
  131. package/dist/transports/ConsoleTransport.d.ts.map +1 -1
  132. package/dist/transports/FileTransport.d.ts +99 -18
  133. package/dist/transports/FileTransport.d.ts.map +1 -1
  134. package/dist/transports/HttpTransport.d.ts +135 -22
  135. package/dist/transports/HttpTransport.d.ts.map +1 -1
  136. package/dist/transports/OtlpTraceTransport.d.ts +118 -0
  137. package/dist/transports/OtlpTraceTransport.d.ts.map +1 -0
  138. package/dist/transports/OtlpTransport.d.ts +80 -37
  139. package/dist/transports/OtlpTransport.d.ts.map +1 -1
  140. package/dist/transports/SpanRuntime.d.ts +73 -0
  141. package/dist/transports/SpanRuntime.d.ts.map +1 -0
  142. package/dist/transports/TransportBridge.d.ts +19 -13
  143. package/dist/transports/TransportBridge.d.ts.map +1 -1
  144. package/dist/transports/TransportManager.d.ts +232 -10
  145. package/dist/transports/TransportManager.d.ts.map +1 -1
  146. package/dist/transports/index.d.ts +1 -0
  147. package/dist/transports/index.d.ts.map +1 -1
  148. package/dist/transports-module.d.ts +3 -1
  149. package/dist/transports-module.d.ts.map +1 -1
  150. package/dist/transports.cjs +2 -1
  151. package/dist/transports.js +2 -2
  152. package/dist/types/core.d.ts +155 -59
  153. package/dist/types/core.d.ts.map +1 -1
  154. package/dist/types/hooks.d.ts +92 -14
  155. package/dist/types/hooks.d.ts.map +1 -1
  156. package/dist/types/index.d.ts +1 -1
  157. package/dist/types/index.d.ts.map +1 -1
  158. package/dist/types/serializers.d.ts +72 -0
  159. package/dist/types/serializers.d.ts.map +1 -1
  160. package/dist/types/transports.d.ts +163 -39
  161. package/dist/types/transports.d.ts.map +1 -1
  162. package/dist/utils/ansi-colors.d.ts +15 -15
  163. package/dist/utils/asyncLocalStorage.d.ts +33 -0
  164. package/dist/utils/asyncLocalStorage.d.ts.map +1 -0
  165. package/dist/utils/environment-detector.d.ts +11 -11
  166. package/dist/utils/formatting.d.ts +8 -8
  167. package/dist/utils/output.d.ts +9 -9
  168. package/dist/utils/output.d.ts.map +1 -1
  169. package/dist/utils/stackTrace.d.ts +2 -2
  170. package/package.json +24 -25
  171. package/dist/chunks/HookBridge-CiRfR67f.cjs +0 -190
  172. package/dist/chunks/HookBridge-CiRfR67f.cjs.map +0 -1
  173. package/dist/chunks/HookBridge-SgMmbXZB.js +0 -173
  174. package/dist/chunks/HookBridge-SgMmbXZB.js.map +0 -1
  175. package/dist/chunks/LogContext-Cwn-1Zzb.js.map +0 -1
  176. package/dist/chunks/LogContext-L7HzynFw.cjs.map +0 -1
  177. package/dist/chunks/SerializerBridge-BaOQOb8q.cjs +0 -166
  178. package/dist/chunks/SerializerBridge-BaOQOb8q.cjs.map +0 -1
  179. package/dist/chunks/SerializerBridge-BkpQu5c9.js +0 -149
  180. package/dist/chunks/SerializerBridge-BkpQu5c9.js.map +0 -1
  181. package/dist/chunks/StyleManager-CIpd6wbO.cjs.map +0 -1
  182. package/dist/chunks/StyleManager-LCvVlVdx.js +0 -87
  183. package/dist/chunks/StyleManager-LCvVlVdx.js.map +0 -1
  184. package/dist/chunks/core-Dzz7agGa.cjs.map +0 -1
  185. package/dist/chunks/core-PoT7RrTK.js.map +0 -1
  186. package/dist/chunks/environment-detector-CI3TrWK_.js.map +0 -1
  187. package/dist/chunks/environment-detector-Cnn6wr6O.cjs.map +0 -1
  188. package/dist/chunks/server-fallback-BUKjdLS7.cjs +0 -42
  189. package/dist/chunks/server-fallback-BUKjdLS7.cjs.map +0 -1
  190. package/dist/chunks/server-fallback-BsuWH1Dk.js +0 -37
  191. package/dist/chunks/server-fallback-BsuWH1Dk.js.map +0 -1
  192. package/dist/chunks/spinner-D3FsF78o.js.map +0 -1
  193. package/dist/chunks/spinner-DNvxbM9a.cjs.map +0 -1
  194. package/dist/chunks/styling-84N8T97t.js +0 -941
  195. package/dist/chunks/styling-84N8T97t.js.map +0 -1
  196. package/dist/chunks/styling-Cg5saQ46.cjs +0 -994
  197. package/dist/chunks/styling-Cg5saQ46.cjs.map +0 -1
  198. package/dist/chunks/transports-BiDk345e.js +0 -715
  199. package/dist/chunks/transports-BiDk345e.js.map +0 -1
  200. package/dist/chunks/transports-COPWmlF1.cjs +0 -756
  201. package/dist/chunks/transports-COPWmlF1.cjs.map +0 -1
  202. package/dist/chunks/utils-BqlFYocD.cjs.map +0 -1
  203. package/dist/chunks/utils-VETbVpkR.js.map +0 -1
  204. package/dist/example.d.ts +0 -18
  205. package/dist/example.d.ts.map +0 -1
  206. package/dist/main.d.ts +0 -2
  207. package/dist/main.d.ts.map +0 -1
@@ -1,145 +1,242 @@
1
1
  /**
2
- * @fileoverview LogContext bridge — MDC (Mapped Diagnostic Context) management.
3
- * Encapsulates per-logger structured context, child logger creation, and
4
- * OTel resource merging.
2
+ * @fileoverview Bridge de LogContext — gestión de MDC (Mapped Diagnostic Context).
5
3
  *
6
- * F4 MDC API reset:
7
- * - `withContext(bindings, fn?)` — if fn provided, run within AsyncLocalStorage.
8
- * Without fn: no-op (backwards compat shim for the old setter shape).
9
- * - `withContextAsync(bindings, fn)` — async callback variant.
10
- * - `child(bindings)` remains immutable (canonical MDC pattern).
11
- * - Feature-detect AsyncLocalStorage; browser fallback is a no-op.
4
+ * Encapsula el contexto estructurado por logger, la creación de child loggers y
5
+ * el merge de resource OTel en cada record emitido.
6
+ *
7
+ * Modelo de API:
8
+ * - `withContext(bindings, fn?)` — si se pasa `fn`, lo ejecuta dentro de un
9
+ * scope de AsyncLocalStorage mergeando `bindings`. Sin `fn`: no-op (shim de
10
+ * backwards compat para la vieja forma de setter).
11
+ * - `withContextAsync(bindings, fn)` — variante async callback.
12
+ * - `child(bindings)` — inmutable (patrón canónico de MDC).
13
+ * - Feature-detect de AsyncLocalStorage; en browser sin ALS es no-op.
12
14
  */
13
15
  import type { ILogResourceRef } from '../types/index.js';
14
16
  import type { LoggerConfig } from '../types/index.js';
17
+ import { type AsyncLocalStorageLike } from '../utils/asyncLocalStorage.js';
15
18
  /**
16
- * Snapshot of the bound context. Returned by {@link LogContext.getContext}.
19
+ * Snapshot del contexto bound. Lo retorna {@link LogContext.getContext}.
20
+ *
21
+ * Es `Readonly` para marcar contractually que el objeto devuelto es una shallow
22
+ * copy: mutarlo no afecta a los records que emitan futuras llamadas de log.
17
23
  */
18
24
  export type ContextSnapshot = Readonly<Record<string, unknown>>;
19
25
  /**
20
- * Factory function type for creating child Logger instances.
21
- * Passed to LogContext so `child()` can instantiate new loggers without
22
- * introducing a circular import. Returns unknown — the actual Logger class
23
- * is used by the caller and the returned instance has its `context` field
24
- * written to by LogContext.
26
+ * Tipo de la factory function para crear instancias child de Logger.
27
+ *
28
+ * Se inyecta en LogContext para que `child()` pueda instanciar nuevos loggers
29
+ * sin introducir un import circular entre `Logger.ts` y `LogContext.ts`.
30
+ * Retorna `unknown` — la clase Logger concreta la maneja el caller, y la
31
+ * instancia devuelta tiene su campo `context` escrito por LogContext tras la
32
+ * creación.
25
33
  */
26
34
  export type ChildLoggerFactory = (config: Partial<LoggerConfig>) => unknown;
27
35
  /**
28
- * Minimal shape of a Logger instance needed by LogContext.
29
- * Used to avoid circular dependencies between LogContext and Logger.
30
- * The `_parentContextRecord` field is set by the parent Logger after
31
- * `LogContext.child()` returns, establishing the context chain.
36
+ * Shape mínima de una instancia de Logger que LogContext necesita ver.
37
+ *
38
+ * Evita dependencias circulares entre LogContext y Logger. El campo
39
+ * `_parentContextRecord` lo setea el Logger padre después de que
40
+ * `LogContext.child()` retorna, estableciendo la cadena de contextos.
32
41
  */
33
42
  export interface ChildLoggerShape {
34
43
  _parentContextRecord?: Record<string, unknown>;
35
- /** Legacy field — no longer the canonical context source (F4.5.5 fix). */
44
+ /** Campo legacy — ya no es la fuente canónica del contexto. */
36
45
  context?: Record<string, unknown>;
37
46
  }
38
47
  /**
39
- * Options passed to {@link createLogContext}.
48
+ * Options que se pasan a {@link createLogContext}.
40
49
  */
41
50
  export interface ILogContextOptions {
42
- /** Initial context key-value pairs. */
51
+ /** Pares key-value iniciales del contexto. */
43
52
  initialContext?: Record<string, unknown>;
44
- /** Factory for creating child logger instances. */
53
+ /** Factory para crear instancias child de logger. */
45
54
  childLoggerFactory: ChildLoggerFactory;
46
- /** Initial OTel resource to merge into every record. */
55
+ /** Resource OTel inicial a mergear en cada record emitido. */
47
56
  initialResource?: Partial<ILogResourceRef>;
48
57
  /**
49
- * Returns the parent logger's merged context record at child-creation time.
50
- * Used by _getContextRecord() to build the context chain.
58
+ * Retorna el record de contexto mergeado del logger padre en el momento
59
+ * de creación del child. Lo usa `_getContextRecord()` para construir la
60
+ * cadena de contextos.
51
61
  * @internal
52
62
  */
53
63
  getParentContextRecord?: () => Record<string, unknown>;
54
64
  /**
55
- * The ALS instance to use for withContext scoping.
65
+ * Instancia de AsyncLocalStorage a usar para el scoping de `withContext`.
56
66
  * @internal
57
67
  */
58
68
  alsInstance?: ALS;
59
69
  }
60
70
  /**
61
- * Result returned by {@link createLogContext}.
71
+ * Contrato que retorna {@link createLogContext}.
72
+ *
73
+ * Fachada de MDC (Mapped Diagnostic Context) por logger. Combina tres fuentes
74
+ * de contexto:
75
+ * - **base inmutable** vía `child()` (snapshot capturado al crear el child),
76
+ * - **scope transitorio** vía `withContext()` / `withContextAsync()` sobre
77
+ * AsyncLocalStorage,
78
+ * - **resource OTel** mergeado en cada record.
79
+ *
80
+ * En entornos browser sin `AsyncLocalStorage`, las variantes `withContext*`
81
+ * degradan a no-op: ejecutan `fn` sin scoping (o lo skipan si no hay `fn`).
82
+ * `child()` sigue operativo en browser porque no depende de ALS.
62
83
  */
63
84
  export interface LogContext {
64
85
  /**
65
- * Current bound context snapshot (shallow copy — mutation does NOT affect
66
- * what subsequent log calls emit).
86
+ * Snapshot actual del contexto bound.
87
+ *
88
+ * @returns Copia inmutable (shallow) del contexto; mutarla no afecta a los
89
+ * records que emitan futuras llamadas de log.
90
+ *
91
+ * @example
92
+ * const ctx = logContext.getContext();
93
+ * console.log(ctx.requestId); // 'abc-123'
67
94
  */
68
95
  getContext(): ContextSnapshot;
69
96
  /**
70
- * Runs `fn` within an AsyncLocalStorage scope where `bindings` are
71
- * merged into the context for all log calls inside `fn`.
97
+ * Ejecuta `fn` dentro de un scope de AsyncLocalStorage donde `bindings`
98
+ * se mergean al contexto para todas las llamadas de log dentro de `fn`.
72
99
  *
73
- * If `fn` is not provided (the old setter shape), this is a no-op
74
- * for backwards compatibility. Prefer `child()` for persistent binding
75
- * or `withContextAsync()` for async callbacks.
100
+ * Si no se pasa `fn` (la vieja forma de setter), es no-op por backwards
101
+ * compatibility. Para binding persistente prefiere `child()`; para
102
+ * callbacks async usa `withContextAsync()`.
76
103
  *
77
- * @param bindings - Key-value pairs to attach for the duration of `fn`
78
- * @param fn - Optional synchronous function to run with the scoped bindings
79
- * @returns The return value of `fn`, or undefined if no fn provided
104
+ * **Browser fallback**: sin ALS, ejecuta `fn` directamente sin scoping
105
+ * (los bindings NO se mergean). Si tampoco hay `fn`, retorna `undefined`.
106
+ *
107
+ * @param bindings - Pares key-value a attachar durante la ejecución de `fn`
108
+ * @param fn - Función sincrónica opcional a ejecutar bajo el scope ALS
109
+ * @returns El valor de retorno de `fn`, o `undefined` si no se pasa `fn`
110
+ *
111
+ * @example
112
+ * logContext.withContext({ requestId: 'abc-123' }, () => {
113
+ * logger.info('procesando'); // el record lleva requestId=abc-123
114
+ * });
115
+ * // fuera de fn: requestId ya no está presente en próximos logs
116
+ *
117
+ * @see {@link LogContext.withContextAsync} para callbacks async
118
+ * @see {@link LogContext.child} para binding persistente inmutable (sin ALS)
80
119
  */
81
120
  withContext<R>(bindings: Record<string, unknown>, fn?: () => R): R | undefined;
82
121
  /**
83
- * Async variant of `withContext`. Runs `fn` within an AsyncLocalStorage
84
- * scope so bindings are available to all async log calls inside `fn`.
122
+ * Variante async de {@link withContext}. Ejecuta `fn` dentro de un scope
123
+ * de AsyncLocalStorage para que los bindings queden disponibles a todas las
124
+ * llamadas de log async dentro de `fn` (incluso tras `await`).
125
+ *
126
+ * **Browser fallback**: sin ALS, ejecuta `fn` directamente sin scoping.
85
127
  *
86
- * @param bindings - Key-value pairs to attach for the duration of `fn`
87
- * @param fn - Async function to run with the scoped bindings
88
- * @returns The return value of `fn`
128
+ * @param bindings - Pares key-value a attachar durante la ejecución de `fn`
129
+ * @param fn - Función async a ejecutar bajo el scope ALS
130
+ * @returns El Promise retornado por `fn`
131
+ *
132
+ * @example
133
+ * await logContext.withContextAsync({ traceId }, async () => {
134
+ * const user = await fetchUser();
135
+ * logger.info('user cargado', { id: user.id });
136
+ * // el record lleva el traceId aunque el log ocurra tras un await
137
+ * });
89
138
  */
90
139
  withContextAsync<R>(bindings: Record<string, unknown>, fn: () => Promise<R>): Promise<R>;
91
140
  /**
92
- * Drops every key from the bound context. After this call, emitted
93
- * records no longer carry `attributes` until {@link withContext} or
94
- * {@link child} re-establishes one.
141
+ * Droppea todas las keys del contexto bound. Tras esta llamada, los
142
+ * records emitidos ya no llevan `attributes` hasta que
143
+ * {@link withContext} o {@link child} restablezcan uno.
144
+ *
145
+ * @returns La misma instancia de LogContext, ahora sin contexto
95
146
  *
96
- * @returns The same LogContext instance, now context-free
147
+ * @example
148
+ * logContext.clearContext();
149
+ * logger.info('limpio'); // sin attributes
97
150
  */
98
151
  clearContext(): this;
99
152
  /**
100
- * Updates the default OTel resource (service.name, version, env).
101
- * Persisted into every emitted record's `resource` field unless the
102
- * record itself overrides it.
153
+ * Actualiza el resource OTel por defecto (service.name, version,
154
+ * deployment.environment, ...).
155
+ *
156
+ * Se persiste en el campo `resource` de cada record emitido, salvo que el
157
+ * propio record lo overridee.
158
+ *
159
+ * @param resource - Resource OTel parcial a mergear con el actual
160
+ * @returns La misma instancia de LogContext, para encadenar calls
103
161
  *
104
- * @param resource - Partial OTel resource to merge into the current one
105
- * @returns The same LogContext instance, for chaining
162
+ * @example
163
+ * logContext.setResource({ serviceName: 'api-gateway', environment: 'prod' });
106
164
  */
107
165
  setResource(resource: Partial<ILogResourceRef>): this;
108
166
  /**
109
- * Returns an immutable copy of this logger with the extra context bound.
110
- * Future calls on the child emit with the merged context, without
111
- * mutating the parent — the canonical MDC pattern.
167
+ * Devuelve una copia inmutable de este logger con el contexto extra bound.
112
168
  *
113
- * @param extra - Key-value pairs to attach (requestId, userId, ...)
114
- * @returns A new Logger with merged context
169
+ * Las llamadas futuras sobre el child emiten con el contexto mergeado, sin
170
+ * mutar al padre — patrón canónico de MDC.
171
+ *
172
+ * A diferencia de {@link withContext}, **no involucra AsyncLocalStorage**:
173
+ * el binding es persistente y queda capturado en el snapshot del child al
174
+ * crearse. Por eso `child()` es operativo también en browser sin ALS.
175
+ *
176
+ * Los bindings transitorios de ALS activos en el momento de `child()` NO
177
+ * se bakean en el child — solo se captura el contexto base. ALS se aplica
178
+ * fresco en cada dispatch vía `_getContextRecord()`.
179
+ *
180
+ * @param extra - Pares key-value a attachar (requestId, userId, ...)
181
+ * @returns Un nuevo Logger con el contexto mergeado
182
+ *
183
+ * @example
184
+ * const requestLog = logContext.child({ requestId: 'abc-123' });
185
+ * requestLog.info('inicio'); // siempre lleva requestId=abc-123
186
+ * requestLog.info('fin');
187
+ * // el logger padre no se ve afectado por estos bindings
188
+ *
189
+ * @see {@link LogContext.withContext} para scoping transitorio (ALS)
115
190
  */
116
191
  child(extra: Record<string, unknown>): ChildLoggerShape;
117
- /** Internal context record. Exposed for TransportRecord assembly. */
192
+ /**
193
+ * Record de contexto interno. Expuesto para el ensamblado de TransportRecord
194
+ * (base + overlay ALS si hay store activo).
195
+ * @internal
196
+ */
118
197
  _getContextRecord(): Record<string, unknown>;
119
198
  /**
120
- * Returns the base context WITHOUT the ALS overlay.
121
- * Used by Logger.child() to capture the parent context snapshot for
122
- * child logger creation (F4.5.5 fix).
199
+ * Retorna el contexto base SIN el overlay de ALS.
200
+ *
201
+ * Lo usa `Logger.child()` para capturar el snapshot del contexto padre al
202
+ * crear un child logger, garantizando que el binding ALS transitorio no
203
+ * se bakeé en el child.
123
204
  * @internal
124
205
  */
125
206
  _getBaseContextRecord(): Record<string, unknown>;
126
- /** Internal resource record. Exposed for TransportRecord assembly. */
207
+ /**
208
+ * Record de resource interno. Expuesto para el ensamblado de TransportRecord.
209
+ * @internal
210
+ */
127
211
  _getResource(): Partial<ILogResourceRef> | undefined;
128
212
  /**
129
- * Returns the current AsyncLocalStorage store, if ALS is active.
213
+ * Retorna el store actual de AsyncLocalStorage, si ALS está activo en el
214
+ * call stack corriente.
130
215
  * @internal
131
216
  */
132
217
  _getAlsStore(): Record<string, unknown> | undefined;
133
218
  }
134
- type ALS = {
135
- run<R>(store: Record<string, unknown>, fn: () => R): R;
136
- getStore(): Record<string, unknown> | undefined;
137
- };
219
+ type ALS = AsyncLocalStorageLike<Record<string, unknown>>;
138
220
  /**
139
- * Creates a LogContext instance.
221
+ * Factory que crea una instancia de {@link LogContext}.
222
+ *
223
+ * @param options - Configuración (ver {@link ILogContextOptions})
224
+ * @returns Una instancia de LogContext lista para usar
225
+ *
226
+ * @example
227
+ * const logContext = createLogContext({
228
+ * childLoggerFactory: (cfg) => new Logger(cfg),
229
+ * initialContext: { service: 'orders-api' },
230
+ * initialResource: { serviceName: 'orders-api', environment: 'prod' }
231
+ * });
232
+ *
233
+ * // Child inmutable con contexto persistente
234
+ * const requestLog = logContext.child({ requestId: 'abc-123' });
140
235
  *
141
- * @param options - Configuration options
142
- * @returns A LogContext instance
236
+ * // Scope transitorio vía ALS (Node; en browser sin ALS es no-op)
237
+ * logContext.withContext({ traceId: 't-9' }, () => {
238
+ * requestLog.info('procesando orden');
239
+ * });
143
240
  */
144
241
  export declare function createLogContext(options: ILogContextOptions): LogContext;
145
242
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"LogContext.d.ts","sourceRoot":"","sources":["../../src/context/LogContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhE;;;;;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Ae,CAAC,GAAG,IAAI,CAAC;IAEtD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAAC;IAExD;;;;OAIG;IACH,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C;;;;;;;OAOG;IACH,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC;IACrD;;;;OAIG;IACH,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CACvD;AAGD,KAAK,GAAG,GAAG,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAW1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,UAAU,CA6FxE"}
package/dist/context.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_LogContext = require("./chunks/LogContext-L7HzynFw.cjs");
2
+ const require_LogContext = require("./chunks/LogContext-DZasm_P5.cjs");
3
3
  exports.createLogContext = require_LogContext.createLogContext;
package/dist/context.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createLogContext } from "./chunks/LogContext-Cwn-1Zzb.js";
1
+ import { t as createLogContext } from "./chunks/LogContext-Dyzs61XG.js";
2
2
  export { createLogContext };
package/dist/core.cjs CHANGED
@@ -2,17 +2,17 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_core = require("./chunks/core-Dzz7agGa.cjs");
6
- const require_utils = require("./chunks/utils-BqlFYocD.cjs");
7
- const require_environment_detector = require("./chunks/environment-detector-Cnn6wr6O.cjs");
5
+ const require_core = require("./chunks/core-CqS_UBzJ.cjs");
6
+ const require_utils = require("./chunks/utils-W_cxqriN.cjs");
7
+ const require_environment_detector = require("./chunks/environment-detector-D-tHkKWA.cjs");
8
8
  //#region src/core.ts
9
9
  /**
10
- * Minimal Logger class with core functionality only
11
- *
10
+ * Logger minimal con solo la funcionalidad core.
11
+ *
12
12
  * @example
13
13
  * ```typescript
14
14
  * import { CoreLogger } from '@mks2508/better-logger/core';
15
- *
15
+ *
16
16
  * const logger = new CoreLogger();
17
17
  * logger.info('Hello world');
18
18
  * logger.error('Something went wrong', error);
@@ -25,8 +25,8 @@ var CoreLogger = class CoreLogger {
25
25
  timers = /* @__PURE__ */ new Map();
26
26
  groupDepth = 0;
27
27
  /**
28
- * Creates a new CoreLogger instance
29
- * @param config - Optional configuration
28
+ * Crea una nueva instancia de CoreLogger.
29
+ * @param config - Configuración opcional.
30
30
  */
31
31
  constructor(config = {}) {
32
32
  this.config = {
@@ -40,25 +40,29 @@ var CoreLogger = class CoreLogger {
40
40
  };
41
41
  }
42
42
  /**
43
- * Get current configuration
43
+ * Obtiene la configuración actual.
44
44
  */
45
45
  getConfig() {
46
46
  return { ...this.config };
47
47
  }
48
48
  /**
49
- * Sets the global prefix for all log messages
49
+ * Define el prefijo global para todos los mensajes de log.
50
+ * @param prefix - Prefijo a aplicar a todos los mensajes.
50
51
  */
51
52
  setGlobalPrefix(prefix) {
52
53
  this.config.globalPrefix = prefix;
53
54
  }
54
55
  /**
55
- * Sets the verbosity level for filtering log output
56
+ * Define el nivel de verbosity para filtrar la salida de log.
57
+ * @param level - Nivel de verbosity.
56
58
  */
57
59
  setVerbosity(level) {
58
60
  this.config.verbosity = level;
59
61
  }
60
62
  /**
61
- * Creates a scoped logger with a specific prefix
63
+ * Crea un logger con scope y un prefijo específico.
64
+ * @param prefix - Prefijo del scope.
65
+ * @returns Nueva instancia de CoreLogger con el prefijo asignado.
62
66
  */
63
67
  scope(prefix) {
64
68
  const scopedLogger = new CoreLogger(this.config);
@@ -67,13 +71,16 @@ var CoreLogger = class CoreLogger {
67
71
  return scopedLogger;
68
72
  }
69
73
  /**
70
- * Adds a custom log handler for extensibility
74
+ * Añade un handler personalizado para extensibilidad.
75
+ * @param handler - Handler que implementa la interfaz ILogHandler.
71
76
  */
72
77
  addHandler(handler) {
73
78
  this.handlers.push(handler);
74
79
  }
75
80
  /**
76
- * Checks if a log level should be output based on current verbosity
81
+ * Comprueba si un nivel debe emitirse según el verbosity actual.
82
+ * @param level - Nivel a evaluar.
83
+ * @returns `true` si el nivel debe emitirse.
77
84
  */
78
85
  shouldLog(level) {
79
86
  if (this.config.verbosity === "silent") return false;
@@ -81,14 +88,17 @@ var CoreLogger = class CoreLogger {
81
88
  return require_core.LOG_LEVELS[level] >= require_core.LOG_LEVELS[verbosity];
82
89
  }
83
90
  /**
84
- * Gets the effective prefix (global + scoped)
91
+ * Obtiene el prefijo efectivo (global + scope).
92
+ * @returns Prefijo combinado o `undefined` si no hay ninguno.
85
93
  */
86
94
  getEffectivePrefix() {
87
95
  const parts = [this.config.globalPrefix, this.scopedPrefix].filter(Boolean);
88
96
  return parts.length > 0 ? parts.join(":") : void 0;
89
97
  }
90
98
  /**
91
- * Core logging method with universal formatting
99
+ * Método principal de log con formato universal.
100
+ * @param level - Nivel del mensaje.
101
+ * @param args - Argumentos del mensaje.
92
102
  */
93
103
  log(level, ...args) {
94
104
  if (!this.shouldLog(level)) return;
@@ -123,44 +133,52 @@ var CoreLogger = class CoreLogger {
123
133
  });
124
134
  }
125
135
  /**
126
- * Logs debug information (lowest priority)
136
+ * Emite mensajes de debug (prioridad más baja).
137
+ * @param args - Argumentos del mensaje.
127
138
  */
128
139
  debug(...args) {
129
140
  this.log("debug", ...args);
130
141
  }
131
142
  /**
132
- * Logs informational messages
143
+ * Emite mensajes informativos.
144
+ * @param args - Argumentos del mensaje.
133
145
  */
134
146
  info(...args) {
135
147
  this.log("info", ...args);
136
148
  }
137
149
  /**
138
- * Logs warning messages
150
+ * Emite mensajes de advertencia.
151
+ * @param args - Argumentos del mensaje.
139
152
  */
140
153
  warn(...args) {
141
154
  this.log("warn", ...args);
142
155
  }
143
156
  /**
144
- * Logs error messages
157
+ * Emite mensajes de error.
158
+ * @param args - Argumentos del mensaje.
145
159
  */
146
160
  error(...args) {
147
161
  this.log("error", ...args);
148
162
  }
149
163
  /**
150
- * Logs critical errors (highest priority)
164
+ * Emite errores críticos (prioridad más alta).
165
+ * @param args - Argumentos del mensaje.
151
166
  */
152
167
  critical(...args) {
153
168
  this.log("critical", ...args);
154
169
  }
155
170
  /**
156
- * Logs trace information (detailed debugging)
171
+ * Emite información de trace (debugging detallado).
172
+ * @param args - Argumentos del mensaje.
157
173
  */
158
174
  trace(...args) {
159
175
  this.log("debug", ...args);
160
176
  if (this.shouldLog("debug")) console.trace(...args);
161
177
  }
162
178
  /**
163
- * Displays data in a table format
179
+ * Muestra datos en formato tabla.
180
+ * @param data - Datos a mostrar.
181
+ * @param columns - Columnas opcionales a incluir.
164
182
  */
165
183
  table(data, columns) {
166
184
  if (!this.shouldLog("info")) return;
@@ -177,7 +195,9 @@ var CoreLogger = class CoreLogger {
177
195
  }
178
196
  }
179
197
  /**
180
- * Starts a collapsible group in the console
198
+ * Inicia un grupo colapsable en la console.
199
+ * @param label - Etiqueta del grupo.
200
+ * @param collapsed - Si el grupo inicia colapsado.
181
201
  */
182
202
  group(label, collapsed = false) {
183
203
  const prefix = this.getEffectivePrefix();
@@ -191,7 +211,7 @@ var CoreLogger = class CoreLogger {
191
211
  this.groupDepth++;
192
212
  }
193
213
  /**
194
- * Ends the current console group
214
+ * Cierra el grupo actual de la console.
195
215
  */
196
216
  groupEnd() {
197
217
  if (this.groupDepth > 0) {
@@ -201,7 +221,8 @@ var CoreLogger = class CoreLogger {
201
221
  }
202
222
  }
203
223
  /**
204
- * Starts a timer with the given label
224
+ * Inicia un timer con el label indicado.
225
+ * @param label - Identificador del timer.
205
226
  */
206
227
  time(label) {
207
228
  const timer = {
@@ -214,7 +235,8 @@ var CoreLogger = class CoreLogger {
214
235
  console.log(output);
215
236
  }
216
237
  /**
217
- * Ends a timer and logs the elapsed time
238
+ * Detiene un timer y emite el tiempo transcurrido.
239
+ * @param label - Identificador del timer previamente iniciado.
218
240
  */
219
241
  timeEnd(label) {
220
242
  const timer = this.timers.get(label);
@@ -229,7 +251,8 @@ var CoreLogger = class CoreLogger {
229
251
  console.log(output);
230
252
  }
231
253
  /**
232
- * Gets performance.now() or fallback for older environments
254
+ * Obtiene `performance.now()` o un fallback para entornos antiguos.
255
+ * @returns Timestamp en milisegundos.
233
256
  */
234
257
  getPerformanceNow() {
235
258
  if (typeof performance !== "undefined" && performance.now) return performance.now();
@@ -242,7 +265,7 @@ var CoreLogger = class CoreLogger {
242
265
  };
243
266
  const coreLogger = new CoreLogger();
244
267
  /**
245
- * Export individual methods for convenience (with proper binding)
268
+ * Exporta métodos individuales por conveniencia (con binding correcto).
246
269
  */
247
270
  const debug = (...args) => coreLogger.debug(...args);
248
271
  const info = (...args) => coreLogger.info(...args);