@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.
- package/README.md +38 -336
- package/dist/Logger.d.ts +356 -157
- package/dist/Logger.d.ts.map +1 -1
- package/dist/ScopedLogger.d.ts +549 -9
- package/dist/ScopedLogger.d.ts.map +1 -1
- package/dist/chunks/HookBridge-C-AvXmPD.cjs +504 -0
- package/dist/chunks/HookBridge-C-AvXmPD.cjs.map +1 -0
- package/dist/chunks/HookBridge-CI2PH79S.js +487 -0
- package/dist/chunks/HookBridge-CI2PH79S.js.map +1 -0
- package/dist/chunks/{LogContext-L7HzynFw.cjs → LogContext-BaMXleWj.cjs} +19 -4
- package/dist/chunks/LogContext-BaMXleWj.cjs.map +1 -0
- package/dist/chunks/LogContext-DZasm_P5.cjs +141 -0
- package/dist/chunks/LogContext-DZasm_P5.cjs.map +1 -0
- package/dist/chunks/{LogContext-Cwn-1Zzb.js → LogContext-DjlITOzZ.js} +19 -4
- package/dist/chunks/LogContext-DjlITOzZ.js.map +1 -0
- package/dist/chunks/LogContext-Dyzs61XG.js +136 -0
- package/dist/chunks/LogContext-Dyzs61XG.js.map +1 -0
- package/dist/chunks/SerializerBridge-Ba43Mk7j.js +393 -0
- package/dist/chunks/SerializerBridge-Ba43Mk7j.js.map +1 -0
- package/dist/chunks/SerializerBridge-C4a9Z37F.cjs +410 -0
- package/dist/chunks/SerializerBridge-C4a9Z37F.cjs.map +1 -0
- package/dist/chunks/{StyleManager-CIpd6wbO.cjs → StyleManager-DQ6UNRB-.cjs} +37 -11
- package/dist/chunks/StyleManager-DQ6UNRB-.cjs.map +1 -0
- package/dist/chunks/StyleManager-DjwAYbxE.js +113 -0
- package/dist/chunks/StyleManager-DjwAYbxE.js.map +1 -0
- package/dist/chunks/{core-PoT7RrTK.js → core-Blfi2klP.js} +1 -4
- package/dist/chunks/core-Blfi2klP.js.map +1 -0
- package/dist/chunks/{core-Dzz7agGa.cjs → core-CqS_UBzJ.cjs} +1 -4
- package/dist/chunks/core-CqS_UBzJ.cjs.map +1 -0
- package/dist/chunks/{environment-detector-CI3TrWK_.js → environment-detector-7NvnYUfr.js} +11 -11
- package/dist/chunks/environment-detector-7NvnYUfr.js.map +1 -0
- package/dist/chunks/{environment-detector-Cnn6wr6O.cjs → environment-detector-D-tHkKWA.cjs} +11 -11
- package/dist/chunks/environment-detector-D-tHkKWA.cjs.map +1 -0
- package/dist/chunks/server-fallback-CaCPjWby.cjs +119 -0
- package/dist/chunks/server-fallback-CaCPjWby.cjs.map +1 -0
- package/dist/chunks/server-fallback-jj0T6XaK.js +114 -0
- package/dist/chunks/server-fallback-jj0T6XaK.js.map +1 -0
- package/dist/chunks/{spinner-DNvxbM9a.cjs → spinner-BHyYEXsM.cjs} +319 -37
- package/dist/chunks/spinner-BHyYEXsM.cjs.map +1 -0
- package/dist/chunks/{spinner-D3FsF78o.js → spinner-BtkwpzYv.js} +319 -37
- package/dist/chunks/spinner-BtkwpzYv.js.map +1 -0
- package/dist/chunks/styling-CRw3KQW4.js +1592 -0
- package/dist/chunks/styling-CRw3KQW4.js.map +1 -0
- package/dist/chunks/styling-Cel2wPRy.cjs +1645 -0
- package/dist/chunks/styling-Cel2wPRy.cjs.map +1 -0
- package/dist/chunks/transports-BGfwwakw.js +1237 -0
- package/dist/chunks/transports-BGfwwakw.js.map +1 -0
- package/dist/chunks/transports-BZ-Mc2IT.cjs +1450 -0
- package/dist/chunks/transports-BZ-Mc2IT.cjs.map +1 -0
- package/dist/chunks/transports-DvaLAeGJ.js +1403 -0
- package/dist/chunks/transports-DvaLAeGJ.js.map +1 -0
- package/dist/chunks/transports-yK6CL0Ml.cjs +1278 -0
- package/dist/chunks/transports-yK6CL0Ml.cjs.map +1 -0
- package/dist/chunks/{utils-BqlFYocD.cjs → utils-W_cxqriN.cjs} +44 -37
- package/dist/chunks/utils-W_cxqriN.cjs.map +1 -0
- package/dist/chunks/{utils-VETbVpkR.js → utils-tKfBAWUM.js} +44 -37
- package/dist/chunks/utils-tKfBAWUM.js.map +1 -0
- package/dist/cli/CommandProcessor.d.ts +166 -19
- package/dist/cli/CommandProcessor.d.ts.map +1 -1
- package/dist/cli/commands/ConfigCommand.d.ts +36 -1
- package/dist/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/dist/cli/commands/ExportCommand.d.ts +49 -3
- package/dist/cli/commands/ExportCommand.d.ts.map +1 -1
- package/dist/cli/commands/ThemeCommand.d.ts +62 -3
- package/dist/cli/commands/ThemeCommand.d.ts.map +1 -1
- package/dist/cli/help.d.ts +30 -2
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/index.d.ts +29 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/cli.js +2 -2
- package/dist/context/LogContext.d.ts +167 -70
- package/dist/context/LogContext.d.ts.map +1 -1
- package/dist/context.cjs +1 -1
- package/dist/context.js +1 -1
- package/dist/core.cjs +52 -29
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +50 -27
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +52 -29
- package/dist/core.js.map +1 -1
- package/dist/hooks/HookBridge.d.ts +15 -9
- package/dist/hooks/HookBridge.d.ts.map +1 -1
- package/dist/hooks/HookManager.d.ts +295 -2
- package/dist/hooks/HookManager.d.ts.map +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +1415 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1413 -215
- package/dist/index.js.map +1 -1
- package/dist/playground/TerminalBridge.d.ts +23 -16
- package/dist/playground/TerminalBridge.d.ts.map +1 -1
- package/dist/playground/box.d.ts +36 -5
- package/dist/playground/box.d.ts.map +1 -1
- package/dist/playground/cli-table.d.ts +41 -5
- package/dist/playground/cli-table.d.ts.map +1 -1
- package/dist/playground/divider.d.ts +22 -3
- package/dist/playground/divider.d.ts.map +1 -1
- package/dist/playground/header.d.ts +21 -4
- package/dist/playground/header.d.ts.map +1 -1
- package/dist/playground/server-fallback.d.ts +96 -9
- package/dist/playground/server-fallback.d.ts.map +1 -1
- package/dist/playground/spinner.d.ts +159 -10
- package/dist/playground/spinner.d.ts.map +1 -1
- package/dist/playground/step.d.ts +25 -6
- package/dist/playground/step.d.ts.map +1 -1
- package/dist/playground.cjs +1 -1
- package/dist/playground.js +1 -1
- package/dist/serializers/SerializerBridge.d.ts +13 -6
- package/dist/serializers/SerializerBridge.d.ts.map +1 -1
- package/dist/serializers/SerializerRegistry.d.ts +236 -0
- package/dist/serializers/SerializerRegistry.d.ts.map +1 -1
- package/dist/serializers.cjs +1 -1
- package/dist/serializers.js +1 -1
- package/dist/styles/StyleManager.d.ts +138 -31
- package/dist/styles/StyleManager.d.ts.map +1 -1
- package/dist/styles.cjs +2 -2
- package/dist/styles.js +2 -2
- package/dist/styling/SmartPresets.d.ts +100 -6
- package/dist/styling/SmartPresets.d.ts.map +1 -1
- package/dist/styling/StyleBuilder.d.ts +453 -32
- package/dist/styling/StyleBuilder.d.ts.map +1 -1
- package/dist/styling/banners.d.ts +83 -7
- package/dist/styling/banners.d.ts.map +1 -1
- package/dist/styling/themes.d.ts +41 -2
- package/dist/styling/themes.d.ts.map +1 -1
- package/dist/transports/ConsoleTransport.d.ts +95 -0
- package/dist/transports/ConsoleTransport.d.ts.map +1 -1
- package/dist/transports/FileTransport.d.ts +99 -18
- package/dist/transports/FileTransport.d.ts.map +1 -1
- package/dist/transports/HttpTransport.d.ts +135 -22
- package/dist/transports/HttpTransport.d.ts.map +1 -1
- package/dist/transports/OtlpTraceTransport.d.ts +118 -0
- package/dist/transports/OtlpTraceTransport.d.ts.map +1 -0
- package/dist/transports/OtlpTransport.d.ts +80 -37
- package/dist/transports/OtlpTransport.d.ts.map +1 -1
- package/dist/transports/SpanRuntime.d.ts +73 -0
- package/dist/transports/SpanRuntime.d.ts.map +1 -0
- package/dist/transports/TransportBridge.d.ts +19 -13
- package/dist/transports/TransportBridge.d.ts.map +1 -1
- package/dist/transports/TransportManager.d.ts +232 -10
- package/dist/transports/TransportManager.d.ts.map +1 -1
- package/dist/transports/index.d.ts +1 -0
- package/dist/transports/index.d.ts.map +1 -1
- package/dist/transports-module.d.ts +3 -1
- package/dist/transports-module.d.ts.map +1 -1
- package/dist/transports.cjs +2 -1
- package/dist/transports.js +2 -2
- package/dist/types/core.d.ts +155 -59
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/hooks.d.ts +92 -14
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/serializers.d.ts +72 -0
- package/dist/types/serializers.d.ts.map +1 -1
- package/dist/types/transports.d.ts +163 -39
- package/dist/types/transports.d.ts.map +1 -1
- package/dist/utils/ansi-colors.d.ts +15 -15
- package/dist/utils/asyncLocalStorage.d.ts +33 -0
- package/dist/utils/asyncLocalStorage.d.ts.map +1 -0
- package/dist/utils/environment-detector.d.ts +11 -11
- package/dist/utils/formatting.d.ts +8 -8
- package/dist/utils/output.d.ts +9 -9
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/stackTrace.d.ts +2 -2
- package/package.json +24 -25
- package/dist/chunks/HookBridge-CiRfR67f.cjs +0 -190
- package/dist/chunks/HookBridge-CiRfR67f.cjs.map +0 -1
- package/dist/chunks/HookBridge-SgMmbXZB.js +0 -173
- package/dist/chunks/HookBridge-SgMmbXZB.js.map +0 -1
- package/dist/chunks/LogContext-Cwn-1Zzb.js.map +0 -1
- package/dist/chunks/LogContext-L7HzynFw.cjs.map +0 -1
- package/dist/chunks/SerializerBridge-BaOQOb8q.cjs +0 -166
- package/dist/chunks/SerializerBridge-BaOQOb8q.cjs.map +0 -1
- package/dist/chunks/SerializerBridge-BkpQu5c9.js +0 -149
- package/dist/chunks/SerializerBridge-BkpQu5c9.js.map +0 -1
- package/dist/chunks/StyleManager-CIpd6wbO.cjs.map +0 -1
- package/dist/chunks/StyleManager-LCvVlVdx.js +0 -87
- package/dist/chunks/StyleManager-LCvVlVdx.js.map +0 -1
- package/dist/chunks/core-Dzz7agGa.cjs.map +0 -1
- package/dist/chunks/core-PoT7RrTK.js.map +0 -1
- package/dist/chunks/environment-detector-CI3TrWK_.js.map +0 -1
- package/dist/chunks/environment-detector-Cnn6wr6O.cjs.map +0 -1
- package/dist/chunks/server-fallback-BUKjdLS7.cjs +0 -42
- package/dist/chunks/server-fallback-BUKjdLS7.cjs.map +0 -1
- package/dist/chunks/server-fallback-BsuWH1Dk.js +0 -37
- package/dist/chunks/server-fallback-BsuWH1Dk.js.map +0 -1
- package/dist/chunks/spinner-D3FsF78o.js.map +0 -1
- package/dist/chunks/spinner-DNvxbM9a.cjs.map +0 -1
- package/dist/chunks/styling-84N8T97t.js +0 -941
- package/dist/chunks/styling-84N8T97t.js.map +0 -1
- package/dist/chunks/styling-Cg5saQ46.cjs +0 -994
- package/dist/chunks/styling-Cg5saQ46.cjs.map +0 -1
- package/dist/chunks/transports-BiDk345e.js +0 -715
- package/dist/chunks/transports-BiDk345e.js.map +0 -1
- package/dist/chunks/transports-COPWmlF1.cjs +0 -756
- package/dist/chunks/transports-COPWmlF1.cjs.map +0 -1
- package/dist/chunks/utils-BqlFYocD.cjs.map +0 -1
- package/dist/chunks/utils-VETbVpkR.js.map +0 -1
- package/dist/example.d.ts +0 -18
- package/dist/example.d.ts.map +0 -1
- package/dist/main.d.ts +0 -2
- package/dist/main.d.ts.map +0 -1
|
@@ -1,20 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Función de serialización registrada para un tipo específico de valor.
|
|
3
|
+
*
|
|
4
|
+
* Recibe el valor a serializar y un {@link SerializerContext} con el estado
|
|
5
|
+
* del recorrido (profundidad, camino de claves, set de objetos ya vistos para
|
|
6
|
+
* detectar ciclos). Devuelve una representación segura para logs / JSON —
|
|
7
|
+
* normalmente un plain object o un primitivo que `JSON.stringify` pueda emitir
|
|
8
|
+
* sin perder información ni lanzar sobre estructuras profundas.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam T - Tipo del valor que este serializer sabe manejar.
|
|
11
|
+
* @param value - Instancia a serializar.
|
|
12
|
+
* @param context - Estado del recorrido (depth, path, seen).
|
|
13
|
+
* @returns Representación serializable del valor de entrada.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Serializer para `Error` que aplana los campos relevantes
|
|
17
|
+
* const errorSerializer: SerializerFn<Error> = (err) => ({
|
|
18
|
+
* name: err.name,
|
|
19
|
+
* message: err.message,
|
|
20
|
+
* stack: err.stack
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
1
23
|
export type SerializerFn<T = any> = (value: T, context: SerializerContext) => any;
|
|
24
|
+
/**
|
|
25
|
+
* Estado de recorrido que el {@link ISerializerRegistry} pasa a cada
|
|
26
|
+
* {@link SerializerFn} durante la serialización de un valor.
|
|
27
|
+
*
|
|
28
|
+
* Permite que los serializers personalizados respeten `maxDepth`, reconozcan
|
|
29
|
+
* su posición dentro del grafo de objetos y participen de la detección de
|
|
30
|
+
* referencias circulares.
|
|
31
|
+
*
|
|
32
|
+
* @property depth - Profundidad actual dentro del grafo (raíz = 0).
|
|
33
|
+
* @property maxDepth - Profundidad máxima permitida antes de truncar.
|
|
34
|
+
* @property path - Camino de claves desde la raíz hasta el nodo actual.
|
|
35
|
+
* @property seen - `WeakSet` de objetos ya visitados, para detectar ciclos.
|
|
36
|
+
*/
|
|
2
37
|
export interface SerializerContext {
|
|
3
38
|
depth: number;
|
|
4
39
|
maxDepth: number;
|
|
5
40
|
path: string[];
|
|
6
41
|
seen: WeakSet<object>;
|
|
7
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Entrada del registry que asocia un constructor con su {@link SerializerFn}
|
|
45
|
+
* y la prioridad con la que fue registrado.
|
|
46
|
+
*
|
|
47
|
+
* Cuando varios serializers matchean por jerarquía (p.ej. `TypeError` vs
|
|
48
|
+
* `Error`), gana el de `priority` más alta; en empate gana el registrado más
|
|
49
|
+
* tarde. Devuelto por {@link ISerializerRegistry.getAll} para inspección y
|
|
50
|
+
* depuración del orden de resolución.
|
|
51
|
+
*/
|
|
8
52
|
export interface SerializerEntry<T = any> {
|
|
9
53
|
type: new (...args: any[]) => T;
|
|
10
54
|
serializer: SerializerFn<T>;
|
|
11
55
|
priority: number;
|
|
12
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Opciones de serialización pasadas a {@link ISerializerRegistry.serialize}.
|
|
59
|
+
*
|
|
60
|
+
* @property maxDepth - Profundidad máxima antes de truncar el subárbol con un placeholder. Toma el default del registry si se omite.
|
|
61
|
+
* @property circular - Estrategia ante referencias circulares:
|
|
62
|
+
* - `'error'` — lanza al detectar un ciclo.
|
|
63
|
+
* - `'skip'` — omite el campo circular del output.
|
|
64
|
+
* - `'placeholder'` — reemplaza el ciclo por `'[Circular]'` (default).
|
|
65
|
+
* @property preserveUndefined - Si mantener `undefined` (en lugar de omitirlo). Por compatibilidad con JSON, default `false`.
|
|
66
|
+
*/
|
|
13
67
|
export interface SerializerConfig {
|
|
14
68
|
maxDepth?: number;
|
|
15
69
|
circular?: 'error' | 'skip' | 'placeholder';
|
|
16
70
|
preserveUndefined?: boolean;
|
|
17
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Contrato del registry de serializers por tipo.
|
|
74
|
+
*
|
|
75
|
+
* Mantiene una tabla de constructors → {@link SerializerFn} con prioridades,
|
|
76
|
+
* y expone `serialize()` para transformar valores arbitrarios (`Error`,
|
|
77
|
+
* `Date`, `Map`, `Set`, tipos custom del dominio) en representaciones
|
|
78
|
+
* seguras para logs y para `JSON.stringify`.
|
|
79
|
+
*
|
|
80
|
+
* La resolución recorre la cadena de prototipos del valor y aplica el
|
|
81
|
+
* serializer más específico registrado; si nadie matchea, cae al serializer
|
|
82
|
+
* por defecto (JSON-safe).
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* const registry: ISerializerRegistry = createRegistry();
|
|
86
|
+
* registry.add(Error, (e: Error) => ({ name: e.name, message: e.message }), 10);
|
|
87
|
+
* registry.serialize(new TypeError('boom'));
|
|
88
|
+
* // → { name: 'TypeError', message: 'boom' } (TypeError hereda de Error)
|
|
89
|
+
*/
|
|
18
90
|
export interface ISerializerRegistry {
|
|
19
91
|
add<T>(type: new (...args: any[]) => T, serializer: SerializerFn<T>, priority?: number): void;
|
|
20
92
|
remove<T>(type: new (...args: any[]) => T): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializers.d.ts","sourceRoot":"","sources":["../../src/types/serializers.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,GAAG,CAAC;AAElF,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACpC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAChC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;IAC5C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAChC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,UAAU,EAA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AC;IAC5C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mBAAmB;IAChC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9F,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC;IACpD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC;IACjD,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,GAAG,CAAC;IACtD,MAAM,IAAI,eAAe,EAAE,CAAC;CAC/B"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { LogLevel, LogTag } from './core.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* SigNoz /
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Mapea un `LogLevel` a la severidad numérica de OpenTelemetry (1-24) usada
|
|
4
|
+
* por SigNoz / cualquier backend OTLP/HTTP. Valores por banda conformes a la
|
|
5
|
+
* spec: TRACE=1-4, DEBUG=5-8, INFO=9-12, WARN=13-16, ERROR=17-20, FATAL=21-24.
|
|
6
|
+
* Se usa el valor canónico del medio de cada banda.
|
|
7
7
|
*
|
|
8
8
|
* @see https://opentelemetry.io/docs/specs/otel/logs/data-model/#severity-fields
|
|
9
9
|
*/
|
|
10
10
|
export declare const LOG_LEVEL_TO_SEVERITY_NUMBER: Record<LogLevel, number>;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Mapea un `LogLevel` a su nombre de severidad OpenTelemetry (mayúsculas, spec OTel).
|
|
13
13
|
*/
|
|
14
14
|
export declare const LOG_LEVEL_TO_SEVERITY_TEXT: Record<LogLevel, string>;
|
|
15
15
|
/**
|
|
16
|
-
* OTel
|
|
17
|
-
*
|
|
16
|
+
* Atributos de recurso OTel adjuntados una vez por batch (service.name, version,
|
|
17
|
+
* env, ...). Los valores son string-coerced por la capa de transport.
|
|
18
18
|
*/
|
|
19
19
|
export interface ILogResource {
|
|
20
20
|
'service.name': string;
|
|
@@ -23,71 +23,178 @@ export interface ILogResource {
|
|
|
23
23
|
[key: string]: string | undefined;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Valor admitido en un {@link ILogAttributes}: unión recursiva de primitivos
|
|
27
|
+
* serializables (string, number, boolean, null), arrays y structs anidados.
|
|
28
|
+
* Compatible con el modelo de attribute value de OpenTelemetry.
|
|
28
29
|
*/
|
|
29
30
|
export type LogAttributeValue = string | number | boolean | null | LogAttributeValue[] | {
|
|
30
31
|
[k: string]: LogAttributeValue;
|
|
31
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Bag estructurado de atributos (compatible con OpenTelemetry). Cada clave
|
|
35
|
+
* mapea a un valor tipado; la capa de transport decide cómo serializarlo.
|
|
36
|
+
*/
|
|
32
37
|
export interface ILogAttributes {
|
|
33
38
|
[key: string]: LogAttributeValue;
|
|
34
39
|
}
|
|
35
40
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
41
|
+
* Payload enviado a cada transport en cada llamada a `log()`. Los campos son
|
|
42
|
+
* deliberadamente explícitos (sin escape hatch `[key: string]: any`) para que
|
|
43
|
+
* implementaciones como `OtlpTransport` puedan mapear 1:1 a `logRecords` OTLP.
|
|
39
44
|
*/
|
|
40
45
|
export interface TransportRecord {
|
|
41
|
-
/**
|
|
46
|
+
/** Nivel canónico (trace/debug/info/warn/error/critical). */
|
|
42
47
|
level: LogLevel;
|
|
43
|
-
/**
|
|
48
|
+
/** Severidad numérica, copiada de `LOG_LEVELS[level]`. */
|
|
44
49
|
levelValue: number;
|
|
45
|
-
/**
|
|
50
|
+
/** Severidad numérica OTel (1-24). La asigna automáticamente el Logger. */
|
|
46
51
|
severityNumber: number;
|
|
47
|
-
/**
|
|
52
|
+
/** Nombre de severidad OTel (TRACE/DEBUG/INFO/WARN/ERROR/FATAL). */
|
|
48
53
|
severityText: string;
|
|
49
|
-
/** Epoch milliseconds
|
|
54
|
+
/** Epoch milliseconds en el momento del log. */
|
|
50
55
|
time: number;
|
|
51
|
-
/**
|
|
56
|
+
/** Texto final del mensaje, ya procesado por los hooks. */
|
|
52
57
|
msg: string;
|
|
53
|
-
/**
|
|
58
|
+
/** Scope lógico opcional (p.ej. "Auth", "API:Users"). */
|
|
54
59
|
prefix?: string;
|
|
55
|
-
/**
|
|
60
|
+
/** Ubicación del caller, solo cuando `enableStackTrace` es true. */
|
|
56
61
|
location?: {
|
|
57
62
|
file: string;
|
|
58
63
|
line: number;
|
|
59
64
|
column: number;
|
|
60
65
|
function?: string;
|
|
61
66
|
};
|
|
62
|
-
/**
|
|
67
|
+
/** Trace id hex de 32 chars (OTel), cuando hay correlación con un span activo. */
|
|
63
68
|
traceId?: string;
|
|
64
|
-
/**
|
|
69
|
+
/** Span id hex de 16 chars (OTel), cuando hay correlación con un span activo. */
|
|
65
70
|
spanId?: string;
|
|
66
|
-
/**
|
|
71
|
+
/** Atributos estructurados (requestId, userId, tags custom). */
|
|
67
72
|
attributes?: ILogAttributes;
|
|
68
|
-
/**
|
|
73
|
+
/** Recurso a nivel de log (sobreescribe el resource del transport). */
|
|
69
74
|
resource?: Partial<ILogResource>;
|
|
70
|
-
/**
|
|
75
|
+
/** Tag especial "success" — lo setea `Logger.success()`. */
|
|
71
76
|
tag?: LogTag;
|
|
72
77
|
}
|
|
73
78
|
/**
|
|
74
|
-
*
|
|
79
|
+
* Kind de record que circula por el pipeline de transports. Los transports
|
|
80
|
+
* declaran cuáles aceptan vía {@link ITransport.accepts}; el
|
|
81
|
+
* {@link ITransportManager} enruta cada record solo a los transports cuyo
|
|
82
|
+
* `accepts` lo incluye.
|
|
83
|
+
*/
|
|
84
|
+
export type TransportRecordKind = 'log' | 'span';
|
|
85
|
+
/**
|
|
86
|
+
* Valor admitido en los attributes de un {@link SpanRecord}. Deliberadamente
|
|
87
|
+
* más estrecho que {@link LogAttributeValue}: el JSON mapping de OTLP traces
|
|
88
|
+
* solo acepta primitivos en `span.attributes` sin schema extra.
|
|
89
|
+
*/
|
|
90
|
+
export type SpanAttributeValue = string | number | boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Bag de attributes de un span (compatible con el modelo de attributes de
|
|
93
|
+
* OpenTelemetry para traces).
|
|
94
|
+
*/
|
|
95
|
+
export interface SpanAttributes {
|
|
96
|
+
[key: string]: SpanAttributeValue;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Status de finalización de un span, conforme al proto OTel `Status`.
|
|
100
|
+
* `code: 2` = `STATUS_CODE_ERROR`.
|
|
101
|
+
*
|
|
102
|
+
* @see https://opentelemetry.io/docs/specs/otel/trace/api/#set-status
|
|
103
|
+
*/
|
|
104
|
+
export interface SpanStatus {
|
|
105
|
+
code: number;
|
|
106
|
+
message?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Record de span (trace) que emite el trio API `event`/`span`/`startSpan`.
|
|
110
|
+
* A diferencia de {@link TransportRecord}, NO atraviesa el hook path de logs:
|
|
111
|
+
* el {@link ITransportManager} lo despacha solo a transports cuyo
|
|
112
|
+
* {@link ITransport.accepts} incluye `'span'`.
|
|
113
|
+
*
|
|
114
|
+
* `traceId` son 16 bytes en hex (32 chars) y `spanId` 8 bytes en hex
|
|
115
|
+
* (16 chars), conforme a la spec W3C Trace Context que exige OTLP/HTTP.
|
|
116
|
+
*/
|
|
117
|
+
export interface SpanRecord {
|
|
118
|
+
kind: 'span';
|
|
119
|
+
/** Trace id hex de 32 chars. Se hereda del span activo si existe. */
|
|
120
|
+
traceId: string;
|
|
121
|
+
/** Span id hex de 16 chars. */
|
|
122
|
+
spanId: string;
|
|
123
|
+
/** Span id del padre, tomado del span activo en el ALS al crearse. */
|
|
124
|
+
parentSpanId?: string;
|
|
125
|
+
/** Nombre de la operación (`db.query`, `http.request`, ...). */
|
|
126
|
+
name: string;
|
|
127
|
+
/** Span kind OTel numérico. 1 = SPAN_KIND_INTERNAL. */
|
|
128
|
+
spanKind: number;
|
|
129
|
+
/** Instante de inicio en nanosegundos (string decimal). */
|
|
130
|
+
startTimeUnixNano: string;
|
|
131
|
+
/** Instante de fin en nanosegundos (string decimal). `'0'` hasta end(). */
|
|
132
|
+
endTimeUnixNano: string;
|
|
133
|
+
/** Attributes del span. Mutables vía {@link Span.set} hasta el end(). */
|
|
134
|
+
attributes: SpanAttributes;
|
|
135
|
+
/** Status de finalización. Presente si el span terminó con `fail()`. */
|
|
136
|
+
status?: SpanStatus;
|
|
137
|
+
/** `true` cuando el span se cerró por flush sin `end()` explícito. */
|
|
138
|
+
incomplete?: boolean;
|
|
139
|
+
/** Scope del logger que emitió el span (nombre del scoped logger). */
|
|
140
|
+
scope: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handle de un span externally-ended. Lo devuelven `startSpan()` y el
|
|
144
|
+
* callback de `span(fn)`.
|
|
145
|
+
*/
|
|
146
|
+
export interface Span {
|
|
147
|
+
/**
|
|
148
|
+
* Añade o actualiza un attribute del span.
|
|
149
|
+
*
|
|
150
|
+
* @param key - Nombre del attribute.
|
|
151
|
+
* @param value - Valor primitivo (string | number | boolean).
|
|
152
|
+
* @returns `this`, para encadenar.
|
|
153
|
+
*/
|
|
154
|
+
set(key: string, value: SpanAttributeValue): this;
|
|
155
|
+
/**
|
|
156
|
+
* Finaliza el span: fija `endTimeUnixNano` y encola el
|
|
157
|
+
* {@link SpanRecord} para export. Llamadas posteriores son no-op.
|
|
158
|
+
*
|
|
159
|
+
* @param attributes - Attributes finales a mergear antes del export.
|
|
160
|
+
*/
|
|
161
|
+
end(attributes?: SpanAttributes): void;
|
|
162
|
+
/**
|
|
163
|
+
* Marca el span como fallido (`status.code = 2` con el mensaje del
|
|
164
|
+
* error) y luego lo finaliza como {@link end}.
|
|
165
|
+
*
|
|
166
|
+
* @param err - Error (o valor) que causó el fallo.
|
|
167
|
+
*/
|
|
168
|
+
fail(err: unknown): void;
|
|
169
|
+
/** Trace id hex de 32 chars del span. */
|
|
170
|
+
readonly traceId: string;
|
|
171
|
+
/** Span id hex de 16 chars del span. */
|
|
172
|
+
readonly spanId: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Unión de todo record que puede atravesar el {@link ITransportManager}:
|
|
176
|
+
* un log ({@link TransportRecord}) o un span ({@link SpanRecord}).
|
|
177
|
+
* El routing por kind lo hace el manager vía {@link ITransport.accepts}.
|
|
178
|
+
*/
|
|
179
|
+
export type TransportDispatchRecord = TransportRecord | SpanRecord;
|
|
180
|
+
/**
|
|
181
|
+
* Opciones aceptadas por cualquier transport al registrarse.
|
|
75
182
|
*/
|
|
76
183
|
export interface TransportOptions {
|
|
77
184
|
level?: LogLevel;
|
|
78
|
-
/**
|
|
185
|
+
/** Transforma el record antes de serializarlo. Devolver null descarta el record. */
|
|
79
186
|
transform?: (record: TransportRecord) => TransportRecord | null;
|
|
80
|
-
/** Flush
|
|
187
|
+
/** Flush cuando el buffer alcanza esta cantidad de records. */
|
|
81
188
|
batchSize?: number;
|
|
82
|
-
/** Flush
|
|
189
|
+
/** Flush periódico a este intervalo (ms). */
|
|
83
190
|
flushInterval?: number;
|
|
84
|
-
/**
|
|
191
|
+
/** Tope duro de records en buffer. Los más antiguos se descartan al desbordar. */
|
|
85
192
|
maxBufferSize?: number;
|
|
86
193
|
}
|
|
87
194
|
/**
|
|
88
|
-
*
|
|
89
|
-
* -
|
|
90
|
-
* -
|
|
195
|
+
* Registro de un transport. `target` puede ser:
|
|
196
|
+
* - Una instancia de `ITransport` (legacy / inline).
|
|
197
|
+
* - Un string registrado en el registry built-in de `TransportManager`
|
|
91
198
|
* (`'console' | 'file' | 'http' | 'otlp'`).
|
|
92
199
|
*/
|
|
93
200
|
export interface TransportTarget {
|
|
@@ -96,18 +203,31 @@ export interface TransportTarget {
|
|
|
96
203
|
level?: LogLevel;
|
|
97
204
|
}
|
|
98
205
|
/**
|
|
99
|
-
*
|
|
206
|
+
* Contrato mínimo que todo transport debe satisfacer.
|
|
207
|
+
*
|
|
208
|
+
* Un transport declara qué kinds de record acepta vía {@link accepts}:
|
|
209
|
+
* ausente o `['log']` → log-only (default, comportamiento de todos los
|
|
210
|
+
* transports históricos); `['span']` → solo spans (p.ej. `OtlpTraceTransport`);
|
|
211
|
+
* `['log', 'span']` → ambos. El {@link ITransportManager} garantiza que un
|
|
212
|
+
* transport jamás recibe un record de un kind que no declaró — un
|
|
213
|
+
* `SpanRecord` nunca llega a un transport de logs.
|
|
100
214
|
*/
|
|
101
215
|
export interface ITransport {
|
|
102
216
|
readonly name: string;
|
|
103
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Kinds de record que este transport acepta. **Default `['log']` cuando
|
|
219
|
+
* está ausente** — los transports existentes siguen siendo log-only sin
|
|
220
|
+
* cambios.
|
|
221
|
+
*/
|
|
222
|
+
readonly accepts?: readonly TransportRecordKind[];
|
|
223
|
+
write(record: TransportDispatchRecord): void | Promise<void>;
|
|
104
224
|
flush?(): void | Promise<void>;
|
|
105
225
|
close?(): void | Promise<void>;
|
|
106
226
|
isReady?(): boolean;
|
|
107
227
|
}
|
|
108
228
|
/**
|
|
109
|
-
*
|
|
110
|
-
* `FileTransport`
|
|
229
|
+
* Contrato de transport con buffer. Transports concretos como `HttpTransport`,
|
|
230
|
+
* `FileTransport` y `OtlpTransport` extienden esta interfaz.
|
|
111
231
|
*/
|
|
112
232
|
export interface IBufferedTransport extends ITransport {
|
|
113
233
|
readonly bufferSize: number;
|
|
@@ -115,12 +235,16 @@ export interface IBufferedTransport extends ITransport {
|
|
|
115
235
|
flush(): Promise<void>;
|
|
116
236
|
}
|
|
117
237
|
/**
|
|
118
|
-
*
|
|
238
|
+
* Contrato del registry / dispatch de transports.
|
|
119
239
|
*/
|
|
120
240
|
export interface ITransportManager {
|
|
121
241
|
add(target: TransportTarget): string;
|
|
122
242
|
remove(id: string): boolean;
|
|
123
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Dispatcha un record (log o span) a los transports que acepten su kind
|
|
245
|
+
* y (para logs) pasen el filtro de nivel del transport.
|
|
246
|
+
*/
|
|
247
|
+
write(record: TransportDispatchRecord): Promise<void>;
|
|
124
248
|
flush(): Promise<void>;
|
|
125
249
|
close(): Promise<void>;
|
|
126
250
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../../src/types/transports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAa,MAAM,WAAW,CAAC;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAOxD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAOtD,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACrC;AAED
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../../src/types/transports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAa,MAAM,WAAW,CAAC;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,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G,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,OAAO,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,GAAG,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC;IACrC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview ANSI
|
|
2
|
+
* @fileoverview Utilidades de colores ANSI para entornos de terminal
|
|
3
3
|
*/
|
|
4
4
|
import type { LogLevel } from '../types/index.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Códigos de color ANSI para estilos en terminal
|
|
7
7
|
*/
|
|
8
8
|
export declare const ANSI_CODES: {
|
|
9
9
|
readonly black: 30;
|
|
@@ -57,7 +57,7 @@ export declare const ANSI_CODES: {
|
|
|
57
57
|
readonly resetStrikethrough: 29;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
|
-
* ANSI
|
|
60
|
+
* Presets de colores ANSI para los distintos niveles de log
|
|
61
61
|
*/
|
|
62
62
|
export declare const ANSI_LEVEL_STYLES: Record<LogLevel | 'success', {
|
|
63
63
|
color: number;
|
|
@@ -66,50 +66,50 @@ export declare const ANSI_LEVEL_STYLES: Record<LogLevel | 'success', {
|
|
|
66
66
|
emoji: string;
|
|
67
67
|
}>;
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Aplica estilos ANSI al texto
|
|
70
70
|
*/
|
|
71
71
|
export declare function ansiStyle(text: string, codes: number[]): string;
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Aplica color al texto
|
|
74
74
|
*/
|
|
75
75
|
export declare function ansiColor(text: string, color: number): string;
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* Aplica color de fondo al texto
|
|
78
78
|
*/
|
|
79
79
|
export declare function ansiBackground(text: string, bg: number, color?: number): string;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* Pone el texto en bold
|
|
82
82
|
*/
|
|
83
83
|
export declare function ansiBold(text: string): string;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* Aplica dim al texto
|
|
86
86
|
*/
|
|
87
87
|
export declare function ansiDim(text: string): string;
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* Subraya el texto
|
|
90
90
|
*/
|
|
91
91
|
export declare function ansiUnderline(text: string): string;
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* Formatters especializados para distintos contextos
|
|
94
94
|
*/
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* Formatea el timestamp para terminal
|
|
97
97
|
*/
|
|
98
98
|
export declare function formatTimestampANSI(timestamp: string): string;
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Formatea el nivel de log para terminal
|
|
101
101
|
*/
|
|
102
102
|
export declare function formatLogLevelANSI(level: LogLevel, useEmojis?: boolean): string;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* Formatea el mensaje de success para terminal
|
|
105
105
|
*/
|
|
106
106
|
export declare function formatSuccessANSI(message: string, useEmojis?: boolean): string;
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
108
|
+
* Formatea el prefix para terminal
|
|
109
109
|
*/
|
|
110
110
|
export declare function formatPrefixANSI(prefix: string): string;
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* Formatea la ubicación del archivo para terminal
|
|
113
113
|
*/
|
|
114
114
|
export declare function formatLocationANSI(location: string): string;
|
|
115
115
|
//# sourceMappingURL=ansi-colors.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Resolución compartida de `AsyncLocalStorage` — utilidad
|
|
3
|
+
* interna, NO exportada por el barrel público (`src/utils/index.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Único punto de verdad para resolver `node:async_hooks` por capas. Lo
|
|
6
|
+
* consumen tanto `transports/SpanRuntime.ts` (ALS singleton de spans) como
|
|
7
|
+
* `context/LogContext.ts` (ALS singleton de MDC). Antes había dos copias de
|
|
8
|
+
* este conocimiento: una acertaba (SpanRuntime, la que sigue este archivo) y
|
|
9
|
+
* otra usaba `typeof AsyncLocalStorage !== 'undefined'` — un feature-detect
|
|
10
|
+
* roto, porque en Node y Bun el constructor NO es global, así que esa rama
|
|
11
|
+
* quedaba siempre en `undefined` y el MDC de logs era no-op silencioso fuera
|
|
12
|
+
* del browser.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Forma mínima de `AsyncLocalStorage<T>` que necesita este paquete.
|
|
16
|
+
*/
|
|
17
|
+
export interface AsyncLocalStorageLike<T> {
|
|
18
|
+
run<R>(store: T, fn: () => R): R;
|
|
19
|
+
getStore(): T | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resuelve `AsyncLocalStorage` por capas:
|
|
23
|
+
* 1. global `AsyncLocalStorage` (runtimes/polyfills que lo exponen),
|
|
24
|
+
* 2. `process.getBuiltinModule('async_hooks')` (Node >= 22.3, Bun),
|
|
25
|
+
* 3. `require('node:async_hooks')` (CJS interop),
|
|
26
|
+
* 4. `undefined` → browser estricto: sin correlación (degradación
|
|
27
|
+
* documentada; el caller decide qué hacer sin ALS).
|
|
28
|
+
*
|
|
29
|
+
* Nota: NO basta con `typeof AsyncLocalStorage !== 'undefined'` — en Node y
|
|
30
|
+
* Bun el constructor NO es global y hay que ir a `node:async_hooks`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveAsyncLocalStorage<T>(): AsyncLocalStorageLike<T> | undefined;
|
|
33
|
+
//# sourceMappingURL=asyncLocalStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncLocalStorage.d.ts","sourceRoot":"","sources":["../../src/utils/asyncLocalStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACpC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACjC,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,KAAK,qBAAqB,CAAC,CAAC,CAAC,GAAG,SAAS,CAiClF"}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Detector de entorno — Detección robusta del entorno para el logger
|
|
3
|
+
* Detecta entornos browser, terminal, server y otros runtime
|
|
4
4
|
*/
|
|
5
5
|
export type Environment = 'browser' | 'terminal' | 'server' | 'webworker' | 'deno' | 'unknown';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Comprueba si se ejecuta en entorno Node.js
|
|
8
8
|
*/
|
|
9
9
|
export declare const isNode: string | false;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Comprueba si se ejecuta en entorno browser
|
|
12
12
|
*/
|
|
13
13
|
export declare const isBrowser: boolean;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Función principal de detección de entorno
|
|
16
16
|
*/
|
|
17
17
|
export declare function getEnvironment(): Environment;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Comprueba si se ejecuta en una terminal interactiva
|
|
20
20
|
*/
|
|
21
21
|
export declare function isRunningInTerminal(): boolean;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Comprueba si el entorno soporta colores ANSI
|
|
24
24
|
*/
|
|
25
25
|
export declare function supportsANSI(): boolean;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Obtiene la capacidad de color específica del entorno
|
|
28
28
|
*/
|
|
29
29
|
export declare function getColorCapability(): 'full' | 'basic' | 'none';
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Obtiene el ancho de la terminal en columnas
|
|
32
32
|
*/
|
|
33
33
|
export declare function getTerminalWidth(): number;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Obtiene el alto de la terminal en filas
|
|
36
36
|
*/
|
|
37
37
|
export declare function getTerminalHeight(): number;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Información del entorno para debugging
|
|
40
40
|
*/
|
|
41
41
|
export declare function getEnvironmentInfo(): {
|
|
42
42
|
environment: Environment;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
2
|
+
* @fileoverview Utilidades de formatting para Universal Logger
|
|
3
3
|
*/
|
|
4
4
|
import type { LogLevel, StackInfo } from '../types/index.js';
|
|
5
5
|
export type { OutputFormat } from '../types/index.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Crea output en texto plano para cualquier entorno
|
|
8
|
+
* Sin colores ni estilos — máxima compatibilidad
|
|
9
9
|
*/
|
|
10
10
|
export declare function createPlainOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Obtiene el método de console adecuado para el nivel
|
|
13
|
+
* Usa distintos métodos de console para mejor semántica
|
|
14
14
|
*/
|
|
15
15
|
export declare function getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error';
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Crea un objeto simple de log entry para los handlers
|
|
18
18
|
*/
|
|
19
19
|
export declare function createLogEntry(level: LogLevel, message: string, args: any[], prefix?: string, stackInfo?: StackInfo | null): {
|
|
20
20
|
timestamp: string;
|
|
@@ -31,11 +31,11 @@ export declare function createLogEntry(level: LogLevel, message: string, args: a
|
|
|
31
31
|
raw: any[];
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Formatea datos para visualización en tabla como texto plano
|
|
35
35
|
*/
|
|
36
36
|
export declare function formatTablePlain(data: any, columns?: string[]): string;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Serialización segura de objetos para logging
|
|
39
39
|
*/
|
|
40
40
|
export declare function safeSerialize(obj: any, maxDepth?: number, currentDepth?: number): any;
|
|
41
41
|
//# sourceMappingURL=formatting.d.ts.map
|