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

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 (127) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE.md +131 -900
  3. package/dist/error.d.ts +95 -96
  4. package/dist/error.js +5 -76
  5. package/dist/index.browser.d.ts +557 -47
  6. package/dist/index.browser.js +19 -1499
  7. package/dist/index.server.d.ts +722 -61
  8. package/dist/index.server.js +31 -2803
  9. package/dist/middleware/elysia.d.ts +65 -63
  10. package/dist/middleware/elysia.js +1 -70
  11. package/dist/middleware/express.d.ts +73 -71
  12. package/dist/middleware/express.js +1 -29
  13. package/dist/middleware/fastify.d.ts +69 -67
  14. package/dist/middleware/fastify.js +1 -46
  15. package/dist/middleware/hono.d.ts +74 -72
  16. package/dist/middleware/hono.js +1 -33
  17. package/dist/middleware/next/handler.d.ts +101 -34
  18. package/dist/middleware/next/handler.js +1 -53
  19. package/dist/middleware/sveltekit.d.ts +100 -98
  20. package/dist/middleware/sveltekit.js +1 -43
  21. package/dist/object-tree.d.ts +67 -70
  22. package/dist/object-tree.js +2 -89
  23. package/dist/packem_shared/AbstractJsonReporter-BawNFYxI.js +1 -0
  24. package/dist/packem_shared/AbstractJsonReporter-Dt5-5x2R.js +1 -0
  25. package/dist/packem_shared/JsonReporter-15ln04rX.js +2 -0
  26. package/dist/packem_shared/JsonReporter-CerNvhg-.js +1 -0
  27. package/dist/packem_shared/PrettyReporter-Br5njEEy.js +5 -0
  28. package/dist/packem_shared/PrettyReporter-CgXnwIip.js +44 -0
  29. package/dist/packem_shared/abstract-json-reporter.d-Bz3lZEDi.d.ts +61 -0
  30. package/dist/packem_shared/abstract-pretty-reporter-BiHgKxG_.js +33 -0
  31. package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
  32. package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
  33. package/dist/packem_shared/create-middleware-logger.d-DeNLii5l.d.ts +47 -0
  34. package/dist/packem_shared/createPailError-53jAfQ-T.js +5 -0
  35. package/dist/packem_shared/headers-S8WyX-2m.js +1 -0
  36. package/dist/packem_shared/index-Bzp4LnJ5.js +1 -0
  37. package/dist/packem_shared/pailMiddleware-CWOJRmJq.js +1 -0
  38. package/dist/packem_shared/storage-DHM1EP2P.js +1 -0
  39. package/dist/packem_shared/types.d-ByY2ZuYG.d.ts +246 -0
  40. package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
  41. package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
  42. package/dist/packem_shared/useLogger-qyZrjy4D.js +1 -0
  43. package/dist/packem_shared/wide-event.d-Ke44zirU.d.ts +704 -0
  44. package/dist/packem_shared/write-console-log-based-on-level-DfD64owL.js +1 -0
  45. package/dist/packem_shared/write-stream-Dd4_PTcm.js +1 -0
  46. package/dist/processor/caller/caller-processor.d.ts +49 -47
  47. package/dist/processor/caller/caller-processor.js +1 -59
  48. package/dist/processor/environment-processor.d.ts +113 -113
  49. package/dist/processor/environment-processor.js +1 -89
  50. package/dist/processor/message-formatter-processor.d.ts +51 -49
  51. package/dist/processor/message-formatter-processor.js +1 -715
  52. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  53. package/dist/processor/opentelemetry-processor.js +1 -52
  54. package/dist/processor/redact-processor.d.ts +60 -41
  55. package/dist/processor/redact-processor.js +1 -31
  56. package/dist/processor/sampling-processor.d.ts +102 -101
  57. package/dist/processor/sampling-processor.js +1 -59
  58. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  59. package/dist/reporter/file/json-file-reporter.js +2 -136
  60. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  61. package/dist/reporter/http/abstract-http-reporter.js +2 -432
  62. package/dist/reporter/http/http-reporter.d.ts +40 -36
  63. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  64. package/dist/reporter/http/http-reporter.edge-light.js +2 -728
  65. package/dist/reporter/http/http-reporter.js +1 -13
  66. package/dist/reporter/json/index.browser.d.ts +99 -3
  67. package/dist/reporter/json/index.browser.js +1 -2
  68. package/dist/reporter/json/index.d.ts +51 -3
  69. package/dist/reporter/json/index.js +1 -2
  70. package/dist/reporter/pretty/index.browser.d.ts +106 -2
  71. package/dist/reporter/pretty/index.browser.js +1 -1
  72. package/dist/reporter/pretty/index.d.ts +186 -2
  73. package/dist/reporter/pretty/index.js +1 -1
  74. package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
  75. package/dist/reporter/simple/simple-reporter.server.js +8 -182
  76. package/dist/wide-event.d.ts +5 -300
  77. package/dist/wide-event.js +1 -284
  78. package/package.json +29 -30
  79. package/dist/constants.d.ts +0 -37
  80. package/dist/middleware/next/middleware.d.ts +0 -59
  81. package/dist/middleware/next/storage.d.ts +0 -14
  82. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  83. package/dist/middleware/shared/headers.d.ts +0 -14
  84. package/dist/middleware/shared/routes.d.ts +0 -30
  85. package/dist/middleware/shared/storage.d.ts +0 -29
  86. package/dist/packem_shared/AbstractJsonReporter-BO8Calb4.js +0 -284
  87. package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +0 -284
  88. package/dist/packem_shared/JsonReporter-CCmj7oYL.js +0 -28
  89. package/dist/packem_shared/JsonReporter-Ck2PIAEw.js +0 -58
  90. package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +0 -2720
  91. package/dist/packem_shared/PrettyReporter-BtTr13Ha.js +0 -213
  92. package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +0 -2635
  93. package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
  94. package/dist/packem_shared/constants-omsTHUWB.js +0 -119
  95. package/dist/packem_shared/createPailError-B_sgL0nF.js +0 -76
  96. package/dist/packem_shared/headers-BxHWM6KI.js +0 -127
  97. package/dist/packem_shared/index-Bx3-C0j9.js +0 -658
  98. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
  99. package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
  100. package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
  101. package/dist/packem_shared/write-console-log-based-on-level-ree2lDPw.js +0 -15
  102. package/dist/packem_shared/write-stream-MDqyXmc_.js +0 -6
  103. package/dist/pail.browser.d.ts +0 -412
  104. package/dist/pail.server.d.ts +0 -158
  105. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  106. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  107. package/dist/reporter/http/utils/compression.d.ts +0 -7
  108. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  109. package/dist/reporter/http/utils/retry.d.ts +0 -27
  110. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  111. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  112. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  113. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  114. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  115. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  116. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  117. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  118. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  119. package/dist/reporter/utils/format-label.d.ts +0 -3
  120. package/dist/types.d.ts +0 -241
  121. package/dist/utils/arrayify.d.ts +0 -2
  122. package/dist/utils/get-longest-badge.d.ts +0 -4
  123. package/dist/utils/get-longest-label.d.ts +0 -4
  124. package/dist/utils/merge-types.d.ts +0 -4
  125. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  126. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  127. 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-ByY2ZuYG.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,59 +1 @@
1
- const getCallerFilename = () => {
2
- const errorStack = Error.prepareStackTrace;
3
- try {
4
- let result = [];
5
- Error.prepareStackTrace = (_error, stack) => {
6
- const callSitesWithoutCurrent = stack.slice(1);
7
- result = callSitesWithoutCurrent;
8
- return callSitesWithoutCurrent;
9
- };
10
- const callers = result.reduce((accumulator, x) => {
11
- if (x.isNative() || x.getFileName()?.includes("pail/dist")) {
12
- return accumulator;
13
- }
14
- accumulator.push({
15
- columnNumber: x.getColumnNumber(),
16
- fileName: x.getFileName() ?? void 0,
17
- lineNumber: x.getLineNumber()
18
- });
19
- return accumulator;
20
- }, []);
21
- const firstExternalFilePath = callers.at(0);
22
- if (firstExternalFilePath) {
23
- return {
24
- columnNumber: firstExternalFilePath.columnNumber ?? void 0,
25
- fileName: firstExternalFilePath.fileName,
26
- lineNumber: firstExternalFilePath.lineNumber ?? void 0
27
- };
28
- }
29
- return {
30
- fileName: "anonymous",
31
- lineNumber: void 0
32
- };
33
- } finally {
34
- Error.prepareStackTrace = errorStack;
35
- }
36
- };
37
-
38
- class CallerProcessor {
39
- /**
40
- * Processes log metadata to add caller file information.
41
- *
42
- * Analyzes the call stack to determine the file location where the log
43
- * was called from and adds this information to the metadata.
44
- * @param meta The log metadata to process
45
- * @returns The processed metadata with file location information added
46
- */
47
- // eslint-disable-next-line class-methods-use-this
48
- process(meta) {
49
- const { columnNumber, fileName, lineNumber } = getCallerFilename();
50
- meta.file = {
51
- column: columnNumber,
52
- line: lineNumber,
53
- name: fileName
54
- };
55
- return meta;
56
- }
57
- }
58
-
59
- export { CallerProcessor as default };
1
+ var u=Object.defineProperty;var n=(a,e)=>u(a,"name",{value:e,configurable:!0});var m=Object.defineProperty,o=n((a,e)=>m(a,"name",{value:e,configurable:!0}),"u");const c=o(()=>{const a=Error.prepareStackTrace;try{let e=[];Error.prepareStackTrace=(i,r)=>{const t=r.slice(1);return e=t,t};const l=e.reduce((i,r)=>(r.isNative()||r.getFileName()?.includes("pail/dist")||i.push({columnNumber:r.getColumnNumber(),fileName:r.getFileName()??void 0,lineNumber:r.getLineNumber()}),i),[]).at(0);return l?{columnNumber:l.columnNumber??void 0,fileName:l.fileName,lineNumber:l.lineNumber??void 0}:{fileName:"anonymous",lineNumber:void 0}}finally{Error.prepareStackTrace=a}},"getCallerFilename");var s=Object.defineProperty,N=n((a,e)=>s(a,"name",{value:e,configurable:!0}),"r");class f{static{n(this,"a")}static{N(this,"CallerProcessor")}process(e){const{columnNumber:l,fileName:i,lineNumber:r}=c();return e.file={column:l,line:r,name:i},e}}export{f 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-ByY2ZuYG.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 };
@@ -1,89 +1 @@
1
- const detectEnvironment = () => {
2
- if (!process.env) {
3
- return {};
4
- }
5
- const { env } = process;
6
- const info = {
7
- /* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing -- env vars may be undefined or empty at runtime */
8
- // Commit hash
9
- commit: env.COMMIT_SHA || env.GIT_COMMIT || env.VERCEL_GIT_COMMIT_SHA?.slice(0, 7) || env.RAILWAY_GIT_COMMIT_SHA?.slice(0, 7) || env.RENDER_GIT_COMMIT?.slice(0, 7) || env.HEROKU_SLUG_COMMIT?.slice(0, 7) || env.CF_PAGES_COMMIT_SHA?.slice(0, 7) || void 0,
10
- // Environment / Node env
11
- environment: env.NODE_ENV || env.ENVIRONMENT || env.APP_ENV || void 0,
12
- // Hostname
13
- hostname: env.HOSTNAME || env.HOST || void 0,
14
- // PID
15
- pid: process.pid,
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,
20
- // 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,
25
- // 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
29
- /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/prefer-nullish-coalescing */
30
- };
31
- return Object.fromEntries(Object.entries(info).filter(([, v]) => v !== void 0));
32
- };
33
- class EnvironmentProcessor {
34
- #envInfo;
35
- /**
36
- * Creates a new EnvironmentProcessor instance.
37
- *
38
- * Auto-detects environment information on construction and merges
39
- * with any provided overrides. Undefined values in overrides are
40
- * filtered out so they don't overwrite detected values.
41
- * @param options Processor configuration options
42
- */
43
- constructor(options = {}) {
44
- const detected = detectEnvironment();
45
- const cleanOverrides = {};
46
- if (options.overrides) {
47
- const overrideEntries = Object.entries(options.overrides);
48
- for (let i = 0; i < overrideEntries.length; i += 1) {
49
- const [key, value] = overrideEntries[i];
50
- if (value !== void 0) {
51
- cleanOverrides[key] = value;
52
- }
53
- }
54
- }
55
- const merged = { ...detected, ...cleanOverrides };
56
- if (!options.includePid && cleanOverrides.pid === void 0) {
57
- delete merged.pid;
58
- }
59
- if (!options.includeHostname && cleanOverrides.hostname === void 0) {
60
- delete merged.hostname;
61
- }
62
- this.#envInfo = merged;
63
- }
64
- /**
65
- * Processes log metadata to add environment information.
66
- *
67
- * Adds a `__env` property to the meta containing detected and
68
- * configured environment details. Each call receives a shallow
69
- * clone of the environment info to prevent cross-record mutation.
70
- * @param meta The log metadata to process
71
- * @returns The processed metadata with environment info added
72
- */
73
- process(meta) {
74
- const enriched = { ...meta, envStorage: { ...this.#envInfo } };
75
- return enriched;
76
- }
77
- /**
78
- * Returns the detected environment information.
79
- *
80
- * Useful for inspecting what environment details were auto-detected.
81
- * Returns a shallow clone to prevent external mutation.
82
- * @returns The environment information object
83
- */
84
- getEnvironmentInfo() {
85
- return { ...this.#envInfo };
86
- }
87
- }
88
-
89
- export { EnvironmentProcessor as default, detectEnvironment };
1
+ var R=Object.defineProperty;var s=(e,E)=>R(e,"name",{value:E,configurable:!0});var c=Object.defineProperty,I=s((e,E)=>c(e,"name",{value:E,configurable:!0}),"s");const N=I(()=>{if(!process.env)return{};const{env:e}=process,E={commit:e.COMMIT_SHA||e.GIT_COMMIT||e.VERCEL_GIT_COMMIT_SHA?.slice(0,7)||e.RAILWAY_GIT_COMMIT_SHA?.slice(0,7)||e.RENDER_GIT_COMMIT?.slice(0,7)||e.HEROKU_SLUG_COMMIT?.slice(0,7)||e.CF_PAGES_COMMIT_SHA?.slice(0,7)||void 0,environment:e.NODE_ENV||e.ENVIRONMENT||e.APP_ENV||void 0,hostname:e.HOSTNAME||e.HOST||void 0,pid:process.pid,region:e.AWS_REGION||e.VERCEL_REGION||e.FLY_REGION||e.RENDER_REGION||e.CF_REGION||e.GOOGLE_CLOUD_REGION||e.FUNCTION_REGION||void 0,service:e.SERVICE_NAME||e.APP_NAME||e.K_SERVICE||e.GAE_SERVICE||e.FUNCTION_TARGET||e.VERCEL_PROJECT_PRODUCTION_URL||e.FLY_APP_NAME||e.RAILWAY_SERVICE_NAME||e.RENDER_SERVICE_NAME||e.HEROKU_APP_NAME||void 0,version:e.APP_VERSION||e.npm_package_version||e.K_REVISION||e.GAE_VERSION||e.RAILWAY_GIT_COMMIT_SHA?.slice(0,7)||e.RENDER_GIT_COMMIT?.slice(0,7)||void 0};return Object.fromEntries(Object.entries(E).filter(([,t])=>t!==void 0))},"detectEnvironment");class d{static{s(this,"O")}static{I(this,"EnvironmentProcessor")}#e;constructor(E={}){const t=N(),_={};if(E.overrides){const n=Object.entries(E.overrides);for(let o=0;o<n.length;o+=1){const[O,r]=n[o];r!==void 0&&(_[O]=r)}}const i={...t,..._};!E.includePid&&_.pid===void 0&&delete i.pid,!E.includeHostname&&_.hostname===void 0&&delete i.hostname,this.#e=i}process(E){return{...E,envStorage:{...this.#e}}}getEnvironmentInfo(){return{...this.#e}}}export{d as default,N as detectEnvironment};
@@ -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, e as StringifyAwareProcessor } from "../packem_shared/types.d-ByY2ZuYG.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 };