@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.
- package/CHANGELOG.md +17 -0
- package/LICENSE.md +152 -894
- package/dist/error.d.ts +95 -96
- package/dist/index.browser.d.ts +557 -47
- package/dist/index.browser.js +1 -1
- package/dist/index.server.d.ts +722 -61
- package/dist/index.server.js +5 -4
- package/dist/middleware/elysia.d.ts +65 -63
- package/dist/middleware/express.d.ts +73 -71
- package/dist/middleware/fastify.d.ts +69 -67
- package/dist/middleware/hono.d.ts +74 -72
- package/dist/middleware/next/handler.d.ts +101 -34
- package/dist/middleware/sveltekit.d.ts +100 -98
- package/dist/object-tree.d.ts +67 -70
- package/dist/packem_shared/{PrettyReporter-BtTr13Ha.js → PrettyReporter-CIbrmjUV.js} +1 -1
- package/dist/packem_shared/{PrettyReporter-BCvyNzXO.js → PrettyReporter-CNJEO9g7.js} +11 -8
- package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-CXAKYCb8.js → abstract-pretty-reporter-CkqCt5hg.js} +4 -2
- package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
- package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
- package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
- package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
- package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
- package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
- package/dist/processor/caller/caller-processor.d.ts +49 -47
- package/dist/processor/environment-processor.d.ts +113 -113
- package/dist/processor/environment-processor.js +3 -10
- package/dist/processor/message-formatter-processor.d.ts +51 -49
- package/dist/processor/message-formatter-processor.js +2 -2
- package/dist/processor/opentelemetry-processor.d.ts +69 -66
- package/dist/processor/redact-processor.d.ts +60 -41
- package/dist/processor/sampling-processor.d.ts +102 -101
- package/dist/reporter/file/json-file-reporter.d.ts +91 -42
- package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
- package/dist/reporter/http/http-reporter.d.ts +40 -36
- package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
- package/dist/reporter/json/index.browser.d.ts +99 -3
- package/dist/reporter/json/index.d.ts +51 -3
- package/dist/reporter/pretty/index.browser.d.ts +106 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +219 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
- package/dist/reporter/simple/simple-reporter.server.js +3 -2
- package/dist/wide-event.d.ts +5 -300
- package/package.json +6 -7
- package/dist/constants.d.ts +0 -37
- package/dist/middleware/next/middleware.d.ts +0 -59
- package/dist/middleware/next/storage.d.ts +0 -14
- package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
- package/dist/middleware/shared/headers.d.ts +0 -14
- package/dist/middleware/shared/routes.d.ts +0 -30
- package/dist/middleware/shared/storage.d.ts +0 -29
- package/dist/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -158
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
- package/dist/reporter/http/utils/compression.d.ts +0 -7
- package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
- package/dist/reporter/http/utils/retry.d.ts +0 -27
- package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
- package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
- package/dist/reporter/json/json-reporter.server.d.ts +0 -50
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
- package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
- package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
- package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
- package/dist/reporter/utils/format-label.d.ts +0 -3
- package/dist/types.d.ts +0 -241
- package/dist/utils/arrayify.d.ts +0 -2
- package/dist/utils/get-longest-badge.d.ts +0 -4
- package/dist/utils/get-longest-label.d.ts +0 -4
- package/dist/utils/merge-types.d.ts +0 -4
- package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
- package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
- package/dist/utils/write-stream.d.ts +0 -2
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
56
|
+
export { CallerProcessor as default };
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
+
* Environment processor configuration options.
|
|
28
|
+
*/
|
|
27
29
|
interface EnvironmentProcessorOptions {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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 ||
|
|
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 ||
|
|
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 ||
|
|
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
|
|
2
|
-
import
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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 };
|