@visulima/pail 4.0.0-alpha.11 → 4.0.0-alpha.12

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 (78) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +152 -894
  3. package/dist/error.d.ts +95 -96
  4. package/dist/index.browser.d.ts +557 -47
  5. package/dist/index.browser.js +1 -1
  6. package/dist/index.server.d.ts +722 -61
  7. package/dist/index.server.js +5 -4
  8. package/dist/middleware/elysia.d.ts +65 -63
  9. package/dist/middleware/express.d.ts +73 -71
  10. package/dist/middleware/fastify.d.ts +69 -67
  11. package/dist/middleware/hono.d.ts +74 -72
  12. package/dist/middleware/next/handler.d.ts +101 -34
  13. package/dist/middleware/sveltekit.d.ts +100 -98
  14. package/dist/object-tree.d.ts +67 -70
  15. package/dist/packem_shared/{PrettyReporter-BtTr13Ha.js → PrettyReporter-CIbrmjUV.js} +1 -1
  16. package/dist/packem_shared/{PrettyReporter-BCvyNzXO.js → PrettyReporter-CNJEO9g7.js} +11 -8
  17. package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
  18. package/dist/packem_shared/{abstract-pretty-reporter-CXAKYCb8.js → abstract-pretty-reporter-CkqCt5hg.js} +4 -2
  19. package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
  20. package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
  21. package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
  22. package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
  23. package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
  24. package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
  25. package/dist/processor/caller/caller-processor.d.ts +49 -47
  26. package/dist/processor/environment-processor.d.ts +113 -113
  27. package/dist/processor/environment-processor.js +3 -10
  28. package/dist/processor/message-formatter-processor.d.ts +51 -49
  29. package/dist/processor/message-formatter-processor.js +2 -2
  30. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  31. package/dist/processor/redact-processor.d.ts +60 -41
  32. package/dist/processor/sampling-processor.d.ts +102 -101
  33. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  34. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  35. package/dist/reporter/http/http-reporter.d.ts +40 -36
  36. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  37. package/dist/reporter/json/index.browser.d.ts +99 -3
  38. package/dist/reporter/json/index.d.ts +51 -3
  39. package/dist/reporter/pretty/index.browser.d.ts +106 -2
  40. package/dist/reporter/pretty/index.browser.js +1 -1
  41. package/dist/reporter/pretty/index.d.ts +219 -2
  42. package/dist/reporter/pretty/index.js +1 -1
  43. package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
  44. package/dist/reporter/simple/simple-reporter.server.js +3 -2
  45. package/dist/wide-event.d.ts +5 -300
  46. package/package.json +6 -7
  47. package/dist/constants.d.ts +0 -37
  48. package/dist/middleware/next/middleware.d.ts +0 -59
  49. package/dist/middleware/next/storage.d.ts +0 -14
  50. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  51. package/dist/middleware/shared/headers.d.ts +0 -14
  52. package/dist/middleware/shared/routes.d.ts +0 -30
  53. package/dist/middleware/shared/storage.d.ts +0 -29
  54. package/dist/pail.browser.d.ts +0 -412
  55. package/dist/pail.server.d.ts +0 -158
  56. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  57. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  58. package/dist/reporter/http/utils/compression.d.ts +0 -7
  59. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  60. package/dist/reporter/http/utils/retry.d.ts +0 -27
  61. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  62. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  63. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  64. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  65. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  66. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  67. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  68. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  69. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  70. package/dist/reporter/utils/format-label.d.ts +0 -3
  71. package/dist/types.d.ts +0 -241
  72. package/dist/utils/arrayify.d.ts +0 -2
  73. package/dist/utils/get-longest-badge.d.ts +0 -4
  74. package/dist/utils/get-longest-label.d.ts +0 -4
  75. package/dist/utils/merge-types.d.ts +0 -4
  76. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  77. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  78. package/dist/utils/write-stream.d.ts +0 -2
@@ -1,54 +1,56 @@
1
- import type { Meta, Processor } from "../../types.d.ts";
1
+ import { M as Meta, P as Processor } from "../../packem_shared/types.d-BeLumqgD.js";
2
+ import '@visulima/colorize';
3
+ import '@visulima/interactive-manager';
2
4
  /**
3
- * Global namespace extension for caller file metadata.
4
- *
5
- * Extends the VisulimaPail.CustomMeta interface to include file information
6
- * that will be added by the CallerProcessor.
7
- */
5
+ * Global namespace extension for caller file metadata.
6
+ *
7
+ * Extends the VisulimaPail.CustomMeta interface to include file information
8
+ * that will be added by the CallerProcessor.
9
+ */
8
10
  declare global {
9
- namespace VisulimaPail {
10
- interface CustomMeta<L> {
11
- /** File information where the log was called from */
12
- file: {
13
- /** Column number in the source file */
14
- column: number | undefined;
15
- /** Line number in the source file */
16
- line: number | undefined;
17
- /** Name/path of the source file */
18
- name: string | undefined;
19
- } | undefined;
20
- }
11
+ namespace VisulimaPail {
12
+ interface CustomMeta<L> {
13
+ /** File information where the log was called from */
14
+ file: {
15
+ /** Column number in the source file */
16
+ column: number | undefined;
17
+ /** Line number in the source file */
18
+ line: number | undefined;
19
+ /** Name/path of the source file */
20
+ name: string | undefined;
21
+ } | undefined;
21
22
  }
23
+ }
22
24
  }
23
25
  /**
24
- * Caller Processor.
25
- *
26
- * A processor that adds file location information to log metadata.
27
- * Uses stack trace analysis to determine the file, line, and column
28
- * where the log call originated from.
29
- * @template L - The log level type
30
- * @example
31
- * ```typescript
32
- * import { createPail } from "@visulima/pail";
33
- * import CallerProcessor from "@visulima/pail/processor/caller";
34
- *
35
- * const logger = createPail({
36
- * processors: [new CallerProcessor()]
37
- * });
38
- *
39
- * logger.info("This log will include file location info");
40
- * // Result includes: file: { name: "...", line: 123, column: 45 }
41
- * ```
42
- */
26
+ * Caller Processor.
27
+ *
28
+ * A processor that adds file location information to log metadata.
29
+ * Uses stack trace analysis to determine the file, line, and column
30
+ * where the log call originated from.
31
+ * @template L - The log level type
32
+ * @example
33
+ * ```typescript
34
+ * import { createPail } from "@visulima/pail";
35
+ * import CallerProcessor from "@visulima/pail/processor/caller";
36
+ *
37
+ * const logger = createPail({
38
+ * processors: [new CallerProcessor()]
39
+ * });
40
+ *
41
+ * logger.info("This log will include file location info");
42
+ * // Result includes: file: { name: "...", line: 123, column: 45 }
43
+ * ```
44
+ */
43
45
  declare class CallerProcessor<L extends string = string> implements Processor<L> {
44
- /**
45
- * Processes log metadata to add caller file information.
46
- *
47
- * Analyzes the call stack to determine the file location where the log
48
- * was called from and adds this information to the metadata.
49
- * @param meta The log metadata to process
50
- * @returns The processed metadata with file location information added
51
- */
52
- process(meta: Meta<L>): Meta<L>;
46
+ /**
47
+ * Processes log metadata to add caller file information.
48
+ *
49
+ * Analyzes the call stack to determine the file location where the log
50
+ * was called from and adds this information to the metadata.
51
+ * @param meta The log metadata to process
52
+ * @returns The processed metadata with file location information added
53
+ */
54
+ process(meta: Meta<L>): Meta<L>;
53
55
  }
54
- export default CallerProcessor;
56
+ export { CallerProcessor as default };
@@ -1,124 +1,124 @@
1
- import type { Meta, Processor } from "../types.d.ts";
1
+ import { M as Meta, P as Processor } from "../packem_shared/types.d-BeLumqgD.js";
2
+ import '@visulima/colorize';
3
+ import '@visulima/interactive-manager';
2
4
  /**
3
- * Detected environment information.
4
- *
5
- * Contains runtime environment details that are automatically detected
6
- * from environment variables and process information.
7
- */
5
+ * Detected environment information.
6
+ *
7
+ * Contains runtime environment details that are automatically detected
8
+ * from environment variables and process information.
9
+ */
8
10
  interface EnvironmentInfo {
9
- /** Git commit hash or short SHA */
10
- commit?: string;
11
- /** Runtime environment (e.g., "production", "development", "test") */
12
- environment?: string;
13
- /** Hostname of the machine */
14
- hostname?: string;
15
- /** Process ID */
16
- pid?: number;
17
- /** Cloud region (e.g., "us-east-1") */
18
- region?: string;
19
- /** Application/service name */
20
- service?: string;
21
- /** Application version */
22
- version?: string;
11
+ /** Git commit hash or short SHA */
12
+ commit?: string;
13
+ /** Runtime environment (e.g., "production", "development", "test") */
14
+ environment?: string;
15
+ /** Hostname of the machine */
16
+ hostname?: string;
17
+ /** Process ID */
18
+ pid?: number;
19
+ /** Cloud region (e.g., "us-east-1") */
20
+ region?: string;
21
+ /** Application/service name */
22
+ service?: string;
23
+ /** Application version */
24
+ version?: string;
23
25
  }
24
26
  /**
25
- * Environment processor configuration options.
26
- */
27
+ * Environment processor configuration options.
28
+ */
27
29
  interface EnvironmentProcessorOptions {
28
- /**
29
- * Whether to include the hostname. Defaults to false.
30
- */
31
- includeHostname?: boolean;
32
- /**
33
- * Whether to include the process ID. Defaults to false.
34
- */
35
- includePid?: boolean;
36
- /**
37
- * Static environment info to use instead of or in addition to auto-detection.
38
- * Values provided here take precedence over auto-detected values.
39
- */
40
- overrides?: Partial<EnvironmentInfo>;
30
+ /**
31
+ * Whether to include the hostname. Defaults to false.
32
+ */
33
+ includeHostname?: boolean;
34
+ /**
35
+ * Whether to include the process ID. Defaults to false.
36
+ */
37
+ includePid?: boolean;
38
+ /**
39
+ * Static environment info to use instead of or in addition to auto-detection.
40
+ * Values provided here take precedence over auto-detected values.
41
+ */
42
+ overrides?: Partial<EnvironmentInfo>;
41
43
  }
42
44
  /**
43
- * Detects the runtime environment from environment variables.
44
- *
45
- * Checks common environment variable patterns used by various hosting
46
- * platforms (Vercel, AWS, GCP, Heroku, Railway, Fly.io, Render, etc.)
47
- * to automatically determine service name, version, environment, region,
48
- * and commit hash.
49
- * @returns Detected environment information
50
- */
45
+ * Detects the runtime environment from environment variables.
46
+ *
47
+ * Checks common environment variable patterns used by various hosting
48
+ * platforms (Vercel, AWS, GCP, Heroku, Railway, Fly.io, Render, etc.)
49
+ * to automatically determine service name, version, environment, region,
50
+ * and commit hash.
51
+ * @returns Detected environment information
52
+ */
51
53
  declare const detectEnvironment: () => EnvironmentInfo;
52
54
  /**
53
- * Environment Enrichment Processor.
54
- *
55
- * Inspired by evlog's automatic environment detection, this processor
56
- * enriches log metadata with runtime environment information. It auto-detects
57
- * details like service name, version, environment, region, and commit hash
58
- * from common environment variables used by popular hosting platforms.
59
- *
60
- * The detected info is added to the log's context, making it easier to
61
- * correlate logs across services and deployments in production.
62
- * @template L - The log level type
63
- * @example
64
- * ```typescript
65
- * import { createPail } from "@visulima/pail";
66
- * import EnvironmentProcessor from "@visulima/pail/processor/environment";
67
- *
68
- * const logger = createPail({
69
- * processors: [
70
- * new EnvironmentProcessor({
71
- * overrides: { service: "my-api" },
72
- * includePid: true,
73
- * }),
74
- * ],
75
- * });
76
- *
77
- * logger.info("Server started");
78
- * // Log metadata will include: { __env: { service: "my-api", environment: "production", ... } }
79
- * ```
80
- * @example
81
- * ```typescript
82
- * // With static configuration only (no auto-detection)
83
- * new EnvironmentProcessor({
84
- * overrides: {
85
- * service: "payment-service",
86
- * version: "2.1.0",
87
- * environment: "staging",
88
- * },
89
- * });
90
- * ```
91
- */
55
+ * Environment Enrichment Processor.
56
+ *
57
+ * Inspired by evlog's automatic environment detection, this processor
58
+ * enriches log metadata with runtime environment information. It auto-detects
59
+ * details like service name, version, environment, region, and commit hash
60
+ * from common environment variables used by popular hosting platforms.
61
+ *
62
+ * The detected info is added to the log's context, making it easier to
63
+ * correlate logs across services and deployments in production.
64
+ * @template L - The log level type
65
+ * @example
66
+ * ```typescript
67
+ * import { createPail } from "@visulima/pail";
68
+ * import EnvironmentProcessor from "@visulima/pail/processor/environment";
69
+ *
70
+ * const logger = createPail({
71
+ * processors: [
72
+ * new EnvironmentProcessor({
73
+ * overrides: { service: "my-api" },
74
+ * includePid: true,
75
+ * }),
76
+ * ],
77
+ * });
78
+ *
79
+ * logger.info("Server started");
80
+ * // Log metadata will include: { __env: { service: "my-api", environment: "production", ... } }
81
+ * ```
82
+ * @example
83
+ * ```typescript
84
+ * // With static configuration only (no auto-detection)
85
+ * new EnvironmentProcessor({
86
+ * overrides: {
87
+ * service: "payment-service",
88
+ * version: "2.1.0",
89
+ * environment: "staging",
90
+ * },
91
+ * });
92
+ * ```
93
+ */
92
94
  declare class EnvironmentProcessor<L extends string = string> implements Processor<L> {
93
- #private;
94
- /**
95
- * Creates a new EnvironmentProcessor instance.
96
- *
97
- * Auto-detects environment information on construction and merges
98
- * with any provided overrides. Undefined values in overrides are
99
- * filtered out so they don't overwrite detected values.
100
- * @param options Processor configuration options
101
- */
102
- constructor(options?: EnvironmentProcessorOptions);
103
- /**
104
- * Processes log metadata to add environment information.
105
- *
106
- * Adds a `__env` property to the meta containing detected and
107
- * configured environment details. Each call receives a shallow
108
- * clone of the environment info to prevent cross-record mutation.
109
- * @param meta The log metadata to process
110
- * @returns The processed metadata with environment info added
111
- */
112
- process(meta: Meta<L>): Meta<L>;
113
- /**
114
- * Returns the detected environment information.
115
- *
116
- * Useful for inspecting what environment details were auto-detected.
117
- * Returns a shallow clone to prevent external mutation.
118
- * @returns The environment information object
119
- */
120
- getEnvironmentInfo(): Readonly<EnvironmentInfo>;
95
+ #private;
96
+ /**
97
+ * Creates a new EnvironmentProcessor instance.
98
+ *
99
+ * Auto-detects environment information on construction and merges
100
+ * with any provided overrides. Undefined values in overrides are
101
+ * filtered out so they don't overwrite detected values.
102
+ * @param options Processor configuration options
103
+ */
104
+ constructor(options?: EnvironmentProcessorOptions);
105
+ /**
106
+ * Processes log metadata to add environment information.
107
+ *
108
+ * Adds a `__env` property to the meta containing detected and
109
+ * configured environment details. Each call receives a shallow
110
+ * clone of the environment info to prevent cross-record mutation.
111
+ * @param meta The log metadata to process
112
+ * @returns The processed metadata with environment info added
113
+ */
114
+ process(meta: Meta<L>): Meta<L>;
115
+ /**
116
+ * Returns the detected environment information.
117
+ *
118
+ * Useful for inspecting what environment details were auto-detected.
119
+ * Returns a shallow clone to prevent external mutation.
120
+ * @returns The environment information object
121
+ */
122
+ getEnvironmentInfo(): Readonly<EnvironmentInfo>;
121
123
  }
122
- export { detectEnvironment };
123
- export default EnvironmentProcessor;
124
- export type { EnvironmentInfo, EnvironmentProcessorOptions };
124
+ export { type EnvironmentInfo, type EnvironmentProcessorOptions, EnvironmentProcessor as default, detectEnvironment };
@@ -14,18 +14,11 @@ const detectEnvironment = () => {
14
14
  // PID
15
15
  pid: process.pid,
16
16
  // Region (including GCP Cloud Functions FUNCTION_REGION and GOOGLE_CLOUD_REGION)
17
- region: env.AWS_REGION || env.VERCEL_REGION || env.FLY_REGION || env.RENDER_REGION || env.CF_REGION || env.GOOGLE_CLOUD_REGION || // GCP general
18
- env.FUNCTION_REGION || // GCP Cloud Functions
19
- void 0,
17
+ region: env.AWS_REGION || env.VERCEL_REGION || env.FLY_REGION || env.RENDER_REGION || env.CF_REGION || env.GOOGLE_CLOUD_REGION || env.FUNCTION_REGION || void 0,
20
18
  // Service name - check common platform variables (including GCP Cloud Run / App Engine)
21
- service: env.SERVICE_NAME || env.APP_NAME || env.K_SERVICE || // GCP Cloud Run
22
- env.GAE_SERVICE || // GCP App Engine
23
- env.FUNCTION_TARGET || // GCP Cloud Functions
24
- env.VERCEL_PROJECT_PRODUCTION_URL || env.FLY_APP_NAME || env.RAILWAY_SERVICE_NAME || env.RENDER_SERVICE_NAME || env.HEROKU_APP_NAME || void 0,
19
+ service: env.SERVICE_NAME || env.APP_NAME || env.K_SERVICE || env.GAE_SERVICE || env.FUNCTION_TARGET || env.VERCEL_PROJECT_PRODUCTION_URL || env.FLY_APP_NAME || env.RAILWAY_SERVICE_NAME || env.RENDER_SERVICE_NAME || env.HEROKU_APP_NAME || void 0,
25
20
  // Version (including GCP Cloud Run K_REVISION and App Engine GAE_VERSION)
26
- version: env.APP_VERSION || env.npm_package_version || env.K_REVISION || // GCP Cloud Run revision
27
- env.GAE_VERSION || // GCP App Engine version
28
- env.RAILWAY_GIT_COMMIT_SHA?.slice(0, 7) || env.RENDER_GIT_COMMIT?.slice(0, 7) || void 0
21
+ version: env.APP_VERSION || env.npm_package_version || env.K_REVISION || env.GAE_VERSION || env.RAILWAY_GIT_COMMIT_SHA?.slice(0, 7) || env.RENDER_GIT_COMMIT?.slice(0, 7) || void 0
29
22
  /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing */
30
23
  };
31
24
  return Object.fromEntries(Object.entries(info).filter(([, v]) => v !== void 0));
@@ -1,52 +1,54 @@
1
- import type { FormatterFunction } from "@visulima/fmt";
2
- import type { Meta, StringifyAwareProcessor } from "../types.d.ts";
1
+ import { M as Meta, b as StringifyAwareProcessor } from "../packem_shared/types.d-BeLumqgD.js";
2
+ import '@visulima/colorize';
3
+ import '@visulima/interactive-manager';
4
+ type FormatterFunction = (argument: any) => string;
3
5
  /**
4
- * Message Formatter Processor.
5
- *
6
- * A processor that formats log messages using the {@link https://visulima.com/packages/fmt/|@visulima/fmt} library.
7
- * Supports custom formatters, string interpolation, and complex object formatting.
8
- * Processes both the main message and contextual data.
9
- * @template L - The log level type
10
- * @example
11
- * ```typescript
12
- * import { createPail } from "@visulima/pail";
13
- * import MessageFormatterProcessor from "@visulima/pail/processor/message-formatter";
14
- *
15
- * const logger = createPail({
16
- * processors: [new MessageFormatterProcessor({
17
- * formatters: {
18
- * user: (value) => `[USER:${value.id}]`
19
- * }
20
- * })]
21
- * });
22
- *
23
- * logger.info("User {user} logged in", { user: { id: 123 } });
24
- * // Output: "User [USER:123] logged in"
25
- * ```
26
- */
6
+ * Message Formatter Processor.
7
+ *
8
+ * A processor that formats log messages using the {@link https://visulima.com/packages/fmt/|@visulima/fmt} library.
9
+ * Supports custom formatters, string interpolation, and complex object formatting.
10
+ * Processes both the main message and contextual data.
11
+ * @template L - The log level type
12
+ * @example
13
+ * ```typescript
14
+ * import { createPail } from "@visulima/pail";
15
+ * import MessageFormatterProcessor from "@visulima/pail/processor/message-formatter";
16
+ *
17
+ * const logger = createPail({
18
+ * processors: [new MessageFormatterProcessor({
19
+ * formatters: {
20
+ * user: (value) => `[USER:${value.id}]`
21
+ * }
22
+ * })]
23
+ * });
24
+ *
25
+ * logger.info("User {user} logged in", { user: { id: 123 } });
26
+ * // Output: "User [USER:123] logged in"
27
+ * ```
28
+ */
27
29
  declare class MessageFormatterProcessor<L extends string = string> implements StringifyAwareProcessor<L> {
28
- #private;
29
- /**
30
- * Creates a new MessageFormatterProcessor instance.
31
- * @param options Configuration options
32
- * @param options.formatters Custom formatters for message interpolation
33
- */
34
- constructor(options?: {
35
- formatters?: Record<string, FormatterFunction>;
36
- });
37
- /**
38
- * Sets the stringify function for object serialization.
39
- * @param function_ The stringify function to use for serializing objects
40
- */
41
- setStringify(function_: typeof JSON.stringify): void;
42
- /**
43
- * Processes log metadata to format messages.
44
- *
45
- * Applies string interpolation and custom formatters to the message
46
- * and contextual data in the log metadata.
47
- * @param meta The log metadata to process
48
- * @returns The processed metadata with formatted messages
49
- */
50
- process(meta: Meta<L>): Meta<L>;
30
+ #private;
31
+ /**
32
+ * Creates a new MessageFormatterProcessor instance.
33
+ * @param options Configuration options
34
+ * @param options.formatters Custom formatters for message interpolation
35
+ */
36
+ constructor(options?: {
37
+ formatters?: Record<string, FormatterFunction>;
38
+ });
39
+ /**
40
+ * Sets the stringify function for object serialization.
41
+ * @param function_ The stringify function to use for serializing objects
42
+ */
43
+ setStringify(function_: typeof JSON.stringify): void;
44
+ /**
45
+ * Processes log metadata to format messages.
46
+ *
47
+ * Applies string interpolation and custom formatters to the message
48
+ * and contextual data in the log metadata.
49
+ * @param meta The log metadata to process
50
+ * @returns The processed metadata with formatted messages
51
+ */
52
+ process(meta: Meta<L>): Meta<L>;
51
53
  }
52
- export default MessageFormatterProcessor;
54
+ export { MessageFormatterProcessor as default };
@@ -322,7 +322,7 @@ const parseCss = (cssString) => {
322
322
  }
323
323
  return css;
324
324
  };
325
- const cssToAnsi = (css, previousCss = null) => {
325
+ const cssToAnsi = (css, previousCss) => {
326
326
  previousCss = previousCss ?? getDefaultCss();
327
327
  let ansi = "";
328
328
  if (!colorEquals(css.backgroundColor, previousCss.backgroundColor)) {
@@ -499,7 +499,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
499
499
  let a = 1 - offset;
500
500
  let lastPosition = -1;
501
501
  let usedStyle = false;
502
- let previousCss = null;
502
+ let previousCss;
503
503
  for (let index = 0; index < fmt.length; ) {
504
504
  if (fmt.codePointAt(index) === CHAR_PERCENT && index + 1 < fmt.length) {
505
505
  lastPosition = lastPosition > -1 ? lastPosition : 0;
@@ -1,70 +1,73 @@
1
- import type { Meta, Processor } from "../types.d.ts";
1
+ import { M as Meta, P as Processor } from "../packem_shared/types.d-BeLumqgD.js";
2
+ import '@visulima/colorize';
3
+ import '@visulima/interactive-manager';
2
4
  /**
3
- * Configuration options for the OpenTelemetry processor.
4
- */
5
- export interface OpenTelemetryProcessorOptions {
6
- /**
7
- * Field name for the span ID. Defaults to 'span_id'
8
- */
9
- spanIdFieldName?: string;
10
- /**
11
- * If specified, all trace fields will be nested under this key
12
- */
13
- traceFieldName?: string;
14
- /**
15
- * Field name for the trace flags. Defaults to 'trace_flags'
16
- */
17
- traceFlagsFieldName?: string;
18
- /**
19
- * Field name for the trace ID. Defaults to 'trace_id'
20
- */
21
- traceIdFieldName?: string;
5
+ * Configuration options for the OpenTelemetry processor.
6
+ */
7
+ interface OpenTelemetryProcessorOptions {
8
+ /**
9
+ * Field name for the span ID. Defaults to 'span_id'
10
+ */
11
+ spanIdFieldName?: string;
12
+ /**
13
+ * If specified, all trace fields will be nested under this key
14
+ */
15
+ traceFieldName?: string;
16
+ /**
17
+ * Field name for the trace flags. Defaults to 'trace_flags'
18
+ */
19
+ traceFlagsFieldName?: string;
20
+ /**
21
+ * Field name for the trace ID. Defaults to 'trace_id'
22
+ */
23
+ traceIdFieldName?: string;
22
24
  }
23
25
  /**
24
- * OpenTelemetry Processor.
25
- *
26
- * A processor that adds OpenTelemetry trace context to log metadata.
27
- * Extracts trace ID, span ID, and trace flags from the active OpenTelemetry span
28
- * and adds them to the log context for distributed tracing correlation.
29
- * @template L - The log level type
30
- * @example
31
- * ```typescript
32
- * import { createPail } from "@visulima/pail";
33
- * import { OpenTelemetryProcessor } from "@visulima/pail/processor/opentelemetry";
34
- *
35
- * const logger = createPail({
36
- * processors: [new OpenTelemetryProcessor()]
37
- * });
38
- *
39
- * logger.info("Processing request");
40
- * // Context includes: { trace_id: "...", span_id: "...", trace_flags: "01" }
41
- * ```
42
- * @example
43
- * ```typescript
44
- * // With custom field names
45
- * const logger = createPail({
46
- * processors: [new OpenTelemetryProcessor({
47
- * traceFieldName: "trace",
48
- * traceIdFieldName: "traceId",
49
- * spanIdFieldName: "spanId"
50
- * })]
51
- * });
52
- * ```
53
- */
54
- export declare class OpenTelemetryProcessor<L extends string = string> implements Processor<L> {
55
- #private;
56
- /**
57
- * Creates a new OpenTelemetryProcessor instance.
58
- * @param options Configuration options for field names and nesting
59
- */
60
- constructor(options?: OpenTelemetryProcessorOptions);
61
- /**
62
- * Processes log metadata to add OpenTelemetry trace context.
63
- *
64
- * Extracts trace information from the active OpenTelemetry span and adds it
65
- * to the log context. If no valid span is found, the metadata is returned unchanged.
66
- * @param meta The log metadata to process
67
- * @returns The processed metadata with trace context added
68
- */
69
- process(meta: Meta<L>): Meta<L>;
26
+ * OpenTelemetry Processor.
27
+ *
28
+ * A processor that adds OpenTelemetry trace context to log metadata.
29
+ * Extracts trace ID, span ID, and trace flags from the active OpenTelemetry span
30
+ * and adds them to the log context for distributed tracing correlation.
31
+ * @template L - The log level type
32
+ * @example
33
+ * ```typescript
34
+ * import { createPail } from "@visulima/pail";
35
+ * import { OpenTelemetryProcessor } from "@visulima/pail/processor/opentelemetry";
36
+ *
37
+ * const logger = createPail({
38
+ * processors: [new OpenTelemetryProcessor()]
39
+ * });
40
+ *
41
+ * logger.info("Processing request");
42
+ * // Context includes: { trace_id: "...", span_id: "...", trace_flags: "01" }
43
+ * ```
44
+ * @example
45
+ * ```typescript
46
+ * // With custom field names
47
+ * const logger = createPail({
48
+ * processors: [new OpenTelemetryProcessor({
49
+ * traceFieldName: "trace",
50
+ * traceIdFieldName: "traceId",
51
+ * spanIdFieldName: "spanId"
52
+ * })]
53
+ * });
54
+ * ```
55
+ */
56
+ declare class OpenTelemetryProcessor<L extends string = string> implements Processor<L> {
57
+ #private;
58
+ /**
59
+ * Creates a new OpenTelemetryProcessor instance.
60
+ * @param options Configuration options for field names and nesting
61
+ */
62
+ constructor(options?: OpenTelemetryProcessorOptions);
63
+ /**
64
+ * Processes log metadata to add OpenTelemetry trace context.
65
+ *
66
+ * Extracts trace information from the active OpenTelemetry span and adds it
67
+ * to the log context. If no valid span is found, the metadata is returned unchanged.
68
+ * @param meta The log metadata to process
69
+ * @returns The processed metadata with trace context added
70
+ */
71
+ process(meta: Meta<L>): Meta<L>;
70
72
  }
73
+ export { OpenTelemetryProcessor, OpenTelemetryProcessorOptions };