@visulima/pail 4.0.2 → 4.1.1
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 +23 -0
- package/LICENSE.md +346 -0
- package/README.md +17 -0
- package/dist/error.d.ts +69 -69
- package/dist/index.browser.d.ts +446 -445
- package/dist/index.browser.js +17 -17
- package/dist/index.server.d.ts +582 -582
- package/dist/index.server.js +27 -27
- package/dist/middleware/elysia.d.ts +44 -42
- package/dist/middleware/elysia.js +1 -1
- package/dist/middleware/express.d.ts +58 -59
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +55 -56
- package/dist/middleware/fastify.js +1 -1
- package/dist/middleware/hono.d.ts +56 -57
- package/dist/middleware/hono.js +1 -1
- package/dist/middleware/next/handler.d.ts +67 -68
- package/dist/middleware/next/handler.js +1 -1
- package/dist/middleware/sveltekit.d.ts +72 -73
- package/dist/middleware/sveltekit.js +1 -1
- package/dist/object-tree.d.ts +44 -44
- package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +1 -0
- package/dist/packem_shared/JsonReporter-9IcELa1m.js +2 -0
- package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +1 -0
- package/dist/packem_shared/{PrettyReporter-DsHfKOU7.js → PrettyReporter-BUWNEg3_.js} +1 -1
- package/dist/packem_shared/{PrettyReporter-CcDdPQSt.js → PrettyReporter-DbgD89ck.js} +56 -30
- package/dist/packem_shared/abstract-json-reporter.d-B6NoO-hG.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-DrLBJ6ds.js → abstract-pretty-reporter-CyfTvmKf.js} +41 -39
- package/dist/packem_shared/create-middleware-logger.d-BRkkBMlk.d.ts +47 -0
- package/dist/packem_shared/headers-DI58djdG.js +1 -0
- package/dist/packem_shared/index-CbkPnylC.js +1 -0
- package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +1 -0
- package/dist/packem_shared/storage-DVcJumyk.js +1 -0
- package/dist/packem_shared/types.d-4ge_rME4.d.ts +246 -0
- package/dist/packem_shared/{types.d-Cz9S7jZh.d.ts → types.d-BW8kAXUv.d.ts} +95 -95
- package/dist/packem_shared/types.d-DGHeA2iJ.d.ts +194 -0
- package/dist/packem_shared/useLogger-7p55yvvc.js +1 -0
- package/dist/packem_shared/wide-event.d-BMLastMR.d.ts +716 -0
- package/dist/packem_shared/write-stream-ytl_vhg_.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +32 -33
- package/dist/processor/environment-processor.d.ts +83 -84
- package/dist/processor/message-formatter-processor.d.ts +40 -45
- package/dist/processor/message-formatter-processor.js +1 -1
- package/dist/processor/opentelemetry-processor.d.ts +51 -52
- package/dist/processor/redact-processor.d.ts +57 -65
- package/dist/processor/sampling-processor.d.ts +90 -91
- package/dist/reporter/file/json-file-reporter.d.ts +77 -78
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +125 -121
- package/dist/reporter/http/abstract-http-reporter.js +2 -2
- package/dist/reporter/http/http-reporter.d.ts +33 -34
- package/dist/reporter/http/http-reporter.edge-light.d.ts +235 -230
- package/dist/reporter/http/http-reporter.edge-light.js +2 -2
- package/dist/reporter/json/index.browser.d.ts +62 -61
- package/dist/reporter/json/index.browser.js +1 -1
- package/dist/reporter/json/index.d.ts +36 -37
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/pretty/index.browser.d.ts +57 -56
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +133 -133
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +91 -90
- package/dist/reporter/simple/simple-reporter.server.js +7 -7
- package/dist/wide-event.d.ts +2 -3
- package/dist/wide-event.js +1 -1
- package/package.json +58 -37
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +0 -1
- package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +0 -1
- package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +0 -2
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +0 -1
- package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +0 -62
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +0 -25
- package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +0 -47
- package/dist/packem_shared/headers-DH0H2s8W.js +0 -1
- package/dist/packem_shared/index-Q1764hvO.js +0 -1
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +0 -1
- package/dist/packem_shared/storage-DaXAlpiO.js +0 -1
- package/dist/packem_shared/types.d-bWnqHJKL.d.ts +0 -211
- package/dist/packem_shared/types.d-xxE3FOD3.d.ts +0 -229
- package/dist/packem_shared/useLogger-DB34CuU5.js +0 -1
- package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +0 -717
- package/dist/packem_shared/write-stream-C7jxLxIT.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=new Set(["alert","critical","emergency","error","trace","warning"]),e=a=>t.has(a),c=(a,r)=>r?(r.__write??r.write.bind(r)).call(r,a):!1;export{c as a,e as r};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { M as Meta, P as Processor } from "../../packem_shared/types.d-
|
|
1
|
+
import { M as Meta, P as Processor } from "../../packem_shared/types.d-4ge_rME4.js";
|
|
2
2
|
import '@visulima/colorize';
|
|
3
3
|
import '@visulima/interactive-manager';
|
|
4
|
-
import 'type-fest';
|
|
5
4
|
/**
|
|
6
|
-
* Global namespace extension for caller file metadata.
|
|
7
|
-
*
|
|
8
|
-
* Extends the VisulimaPail.CustomMeta interface to include file information
|
|
9
|
-
* that will be added by the CallerProcessor.
|
|
10
|
-
*/
|
|
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
|
+
*/
|
|
11
10
|
declare global {
|
|
12
11
|
namespace VisulimaPail {
|
|
13
12
|
interface CustomMeta<L> {
|
|
@@ -24,34 +23,34 @@ declare global {
|
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
|
-
* Caller Processor.
|
|
28
|
-
*
|
|
29
|
-
* A processor that adds file location information to log metadata.
|
|
30
|
-
* Uses stack trace analysis to determine the file, line, and column
|
|
31
|
-
* where the log call originated from.
|
|
32
|
-
* @template L - The log level type
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* import { createPail } from "@visulima/pail";
|
|
36
|
-
* import CallerProcessor from "@visulima/pail/processor/caller";
|
|
37
|
-
*
|
|
38
|
-
* const logger = createPail({
|
|
39
|
-
* processors: [new CallerProcessor()]
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* logger.info("This log will include file location info");
|
|
43
|
-
* // Result includes: file: { name: "...", line: 123, column: 45 }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
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
|
+
*/
|
|
46
45
|
declare class CallerProcessor<L extends string = string> implements Processor<L> {
|
|
47
46
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
+
*/
|
|
55
54
|
process(meta: Meta<L>): Meta<L>;
|
|
56
55
|
}
|
|
57
56
|
export { CallerProcessor as default };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { M as Meta, P as Processor } from "../packem_shared/types.d-
|
|
1
|
+
import { M as Meta, P as Processor } from "../packem_shared/types.d-4ge_rME4.js";
|
|
2
2
|
import '@visulima/colorize';
|
|
3
3
|
import '@visulima/interactive-manager';
|
|
4
|
-
import 'type-fest';
|
|
5
4
|
/**
|
|
6
|
-
* Detected environment information.
|
|
7
|
-
*
|
|
8
|
-
* Contains runtime environment details that are automatically detected
|
|
9
|
-
* from environment variables and process information.
|
|
10
|
-
*/
|
|
5
|
+
* Detected environment information.
|
|
6
|
+
*
|
|
7
|
+
* Contains runtime environment details that are automatically detected
|
|
8
|
+
* from environment variables and process information.
|
|
9
|
+
*/
|
|
11
10
|
interface EnvironmentInfo {
|
|
12
11
|
/** Git commit hash or short SHA */
|
|
13
12
|
commit?: string;
|
|
@@ -25,101 +24,101 @@ interface EnvironmentInfo {
|
|
|
25
24
|
version?: string;
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
|
-
* Environment processor configuration options.
|
|
29
|
-
*/
|
|
27
|
+
* Environment processor configuration options.
|
|
28
|
+
*/
|
|
30
29
|
interface EnvironmentProcessorOptions {
|
|
31
30
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
* Whether to include the hostname. Defaults to false.
|
|
32
|
+
*/
|
|
34
33
|
includeHostname?: boolean;
|
|
35
34
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
* Whether to include the process ID. Defaults to false.
|
|
36
|
+
*/
|
|
38
37
|
includePid?: boolean;
|
|
39
38
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
*/
|
|
43
42
|
overrides?: Partial<EnvironmentInfo>;
|
|
44
43
|
}
|
|
45
44
|
/**
|
|
46
|
-
* Detects the runtime environment from environment variables.
|
|
47
|
-
*
|
|
48
|
-
* Checks common environment variable patterns used by various hosting
|
|
49
|
-
* platforms (Vercel, AWS, GCP, Heroku, Railway, Fly.io, Render, etc.)
|
|
50
|
-
* to automatically determine service name, version, environment, region,
|
|
51
|
-
* and commit hash.
|
|
52
|
-
* @returns Detected environment information
|
|
53
|
-
*/
|
|
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
|
+
*/
|
|
54
53
|
declare const detectEnvironment: () => EnvironmentInfo;
|
|
55
54
|
/**
|
|
56
|
-
* Environment Enrichment Processor.
|
|
57
|
-
*
|
|
58
|
-
* Inspired by evlog's automatic environment detection, this processor
|
|
59
|
-
* enriches log metadata with runtime environment information. It auto-detects
|
|
60
|
-
* details like service name, version, environment, region, and commit hash
|
|
61
|
-
* from common environment variables used by popular hosting platforms.
|
|
62
|
-
*
|
|
63
|
-
* The detected info is added to the log's context, making it easier to
|
|
64
|
-
* correlate logs across services and deployments in production.
|
|
65
|
-
* @template L - The log level type
|
|
66
|
-
* @example
|
|
67
|
-
* ```typescript
|
|
68
|
-
* import { createPail } from "@visulima/pail";
|
|
69
|
-
* import EnvironmentProcessor from "@visulima/pail/processor/environment";
|
|
70
|
-
*
|
|
71
|
-
* const logger = createPail({
|
|
72
|
-
* processors: [
|
|
73
|
-
* new EnvironmentProcessor({
|
|
74
|
-
* overrides: { service: "my-api" },
|
|
75
|
-
* includePid: true,
|
|
76
|
-
* }),
|
|
77
|
-
* ],
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* logger.info("Server started");
|
|
81
|
-
* // Log metadata will include: { __env: { service: "my-api", environment: "production", ... } }
|
|
82
|
-
* ```
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* // With static configuration only (no auto-detection)
|
|
86
|
-
* new EnvironmentProcessor({
|
|
87
|
-
* overrides: {
|
|
88
|
-
* service: "payment-service",
|
|
89
|
-
* version: "2.1.0",
|
|
90
|
-
* environment: "staging",
|
|
91
|
-
* },
|
|
92
|
-
* });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
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
|
+
*/
|
|
95
94
|
declare class EnvironmentProcessor<L extends string = string> implements Processor<L> {
|
|
96
95
|
#private;
|
|
97
96
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
*/
|
|
105
104
|
constructor(options?: EnvironmentProcessorOptions);
|
|
106
105
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
*/
|
|
115
114
|
process(meta: Meta<L>): Meta<L>;
|
|
116
115
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
*/
|
|
123
122
|
getEnvironmentInfo(): Readonly<EnvironmentInfo>;
|
|
124
123
|
}
|
|
125
124
|
export { type EnvironmentInfo, type EnvironmentProcessorOptions, EnvironmentProcessor as default, detectEnvironment };
|
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
import { M as Meta,
|
|
1
|
+
import { M as Meta, c as StringifyAwareProcessor } from "../packem_shared/types.d-4ge_rME4.js";
|
|
2
2
|
import '@visulima/colorize';
|
|
3
3
|
import '@visulima/interactive-manager';
|
|
4
|
-
import 'type-fest';
|
|
5
4
|
/**
|
|
6
|
-
* A custom specifier formatter: receives the matched argument and returns its string form.
|
|
7
|
-
*/
|
|
5
|
+
* A custom specifier formatter: receives the matched argument and returns its string form.
|
|
6
|
+
*/
|
|
8
7
|
type FormatterFunction = (argument: any) => string;
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
* logger.info("User {user} logged in", { user: { id: 123 } });
|
|
34
|
-
* // Output: "User [USER:123] logged in"
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
9
|
+
* Message Formatter Processor.
|
|
10
|
+
*
|
|
11
|
+
* A processor that formats log messages using the {@link https://visulima.com/packages/fmt/|@visulima/fmt} library.
|
|
12
|
+
* Supports custom formatters, string interpolation, and complex object formatting.
|
|
13
|
+
* Processes both the main message and contextual data.
|
|
14
|
+
* @template L - The log level type
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createPail } from "@visulima/pail";
|
|
18
|
+
* import MessageFormatterProcessor from "@visulima/pail/processor/message-formatter";
|
|
19
|
+
*
|
|
20
|
+
* const logger = createPail({
|
|
21
|
+
* processors: [new MessageFormatterProcessor({
|
|
22
|
+
* formatters: {
|
|
23
|
+
* user: (value) => `[USER:${value.id}]`
|
|
24
|
+
* }
|
|
25
|
+
* })]
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* logger.info("User {user} logged in", { user: { id: 123 } });
|
|
29
|
+
* // Output: "User [USER:123] logged in"
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
37
32
|
declare class MessageFormatterProcessor<L extends string = string> implements StringifyAwareProcessor<L> {
|
|
38
33
|
#private;
|
|
39
34
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
* Creates a new MessageFormatterProcessor instance.
|
|
36
|
+
* @param options Configuration options
|
|
37
|
+
* @param options.formatters Custom formatters for message interpolation
|
|
38
|
+
*/
|
|
44
39
|
constructor(options?: {
|
|
45
40
|
formatters?: Record<string, FormatterFunction>;
|
|
46
41
|
});
|
|
47
42
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
* Sets the stringify function for object serialization.
|
|
44
|
+
* @param function_ The stringify function to use for serializing objects
|
|
45
|
+
*/
|
|
51
46
|
setStringify(function_: typeof JSON.stringify): void;
|
|
52
47
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
* Processes log metadata to format messages.
|
|
49
|
+
*
|
|
50
|
+
* Applies string interpolation and custom formatters to the message
|
|
51
|
+
* and contextual data in the log metadata.
|
|
52
|
+
* @param meta The log metadata to process
|
|
53
|
+
* @returns The processed metadata with formatted messages
|
|
54
|
+
*/
|
|
60
55
|
process(meta: Meta<L>): Meta<L>;
|
|
61
56
|
}
|
|
62
57
|
export { MessageFormatterProcessor as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let h;const B=()=>(h!==void 0||(h=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),h),$=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,A=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,v=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,S=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,y=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),x=/\s+/,m=e=>{const t=B();t.has(e)&&(e=t.get(e));const o=$.exec(e);if(o)return[Number.parseInt(o[1],16),Number.parseInt(o[2],16),Number.parseInt(o[3],16)];const i=A.exec(e);if(i)return[Number.parseInt(`${i[1]}${i[1]}`,16),Number.parseInt(`${i[2]}${i[2]}`,16),Number.parseInt(`${i[3]}${i[3]}`,16)];const f=v.exec(e);if(f)return[Math.round(Math.max(0,Math.min(255,Number(f[1])))),Math.round(Math.max(0,Math.min(255,Number(f[2])))),Math.round(Math.max(0,Math.min(255,Number(f[3]))))];const n=S.exec(e);if(n){let l=Number(n[1])%360;l<0&&(l+=360);const a=Math.max(0,Math.min(100,Number(n[2])))/100,s=Math.max(0,Math.min(100,Number(n[3])))/100,u=(1-Math.abs(2*s-1))*a,b=u*(1-Math.abs(l/60%2-1)),r=s-u/2;let d,c,g;return l<60?{0:d,1:c,2:g}=[u,b,0]:l<120?{0:d,1:c,2:g}=[b,u,0]:l<180?{0:d,1:c,2:g}=[0,u,b]:l<240?{0:d,1:c,2:g}=[0,b,u]:l<300?{0:d,1:c,2:g}=[b,0,u]:{0:d,1:c,2:g}=[u,0,b],[Math.round((d+r)*255),Math.round((c+r)*255),Math.round((g+r)*255)]}return null},k=(e,t)=>e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],D=e=>{if(typeof e!="string")return y();const t=y(),o=[];let i=!1,f=null,n=0,l="";for(const a of e){if(a==="(")n+=1;else if(n>0)a===")"&&(n-=1);else if(i){if(a===";"){const s=l.trim();s!==""&&o.push([f,s]),f=null,l="",i=!1;continue}}else if(a===":"){f=l.trim(),l="",i=!0;continue}l+=a}if(i&&n===0){const a=l.trim();a!==""&&o.push([f,a]),f=null,l=""}for(const{0:a,1:s}of o)switch(a){case"background-color":{s!=null&&(t.backgroundColor=s);break}case"color":{s!=null&&(t.color=s);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(s)&&(t.fontStyle="italic");break}case"font-weight":{s==="bold"&&(t.fontWeight=s);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=s.split(x);for(const b of u){const r=m(b);r!=null?t.textDecorationColor=r:["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b)}break}case"text-decoration-color":{const u=m(s);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=s.split(x);for(const b of u)["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b);break}}return t},M=(e,t)=>{t=t??y();let o="";if(!k(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)o+="\x1B[49m";else switch(e.backgroundColor){case"black":{o+="\x1B[40m";break}case"blue":{o+="\x1B[44m";break}case"cyan":{o+="\x1B[46m";break}case"green":{o+="\x1B[42m";break}case"magenta":{o+="\x1B[45m";break}case"red":{o+="\x1B[41m";break}case"white":{o+="\x1B[47m";break}case"yellow":{o+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:i,1:f,2:n}=e.backgroundColor;o+=`\x1B[48;2;${String(i)};${String(f)};${String(n)}m`}else{const i=m(e.backgroundColor);if(i===null)o+="\x1B[49m";else{const{0:f,1:n,2:l}=i;o+=`\x1B[48;2;${String(f)};${String(n)};${String(l)}m`}}}if(!k(e.color,t.color))if(e.color==null)o+="\x1B[39m";else switch(e.color){case"black":{o+="\x1B[30m";break}case"blue":{o+="\x1B[34m";break}case"cyan":{o+="\x1B[36m";break}case"green":{o+="\x1B[32m";break}case"magenta":{o+="\x1B[35m";break}case"red":{o+="\x1B[31m";break}case"white":{o+="\x1B[37m";break}case"yellow":{o+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:i,1:f,2:n}=e.color;o+=`\x1B[38;2;${String(i)};${String(f)};${String(n)}m`}else{const i=m(e.color);if(i===null)o+="\x1B[39m";else{const{0:f,1:n,2:l}=i;o+=`\x1B[38;2;${String(f)};${String(n)};${String(l)}m`}}}if(e.fontWeight!==t.fontWeight&&(o+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(o+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!k(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)o+="\x1B[59m";else{const{0:i,1:f,2:n}=e.textDecorationColor;o+=`\x1B[58;2;${String(i)};${String(f)};${String(n)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(o+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(o+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(o+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),o},N=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},p="%".codePointAt(0),C="s".codePointAt(0),j="d".codePointAt(0),L="f".codePointAt(0),F="i".codePointAt(0),P="O".codePointAt(0),q="o".codePointAt(0),E="j".codePointAt(0),I="c".codePointAt(0),w=(e,t=[],o={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const i=o.stringify??N,f=1;if(typeof e=="object"){const r=t.length+f;if(r===1)return"{}";const d=Array.from({length:r});d[0]=i(e);for(let c=1;c<r;c+=1)d[c]=i(t[c-f]);return d.join(" ")}if(t.length===0)return e;let n="",l=1-f,a=-1,s=!1,u;const b=o.colors??globalThis.window===void 0;for(let r=0;r<e.length;){if(e.codePointAt(r)===p&&r+1<e.length){a=a>-1?a:0;const d=e.codePointAt(r+1);switch(d){case I:{if(b){const c=D(t[l]);a<r&&(n+=e.slice(a,r));const g=M(c,u);n+=g,g!==""&&(s=!0,u=c)}a=r+2,r+=1;break}case j:case L:{const c=t[l];if(l>=t.length||c==null)break;a<r&&(n+=e.slice(a,r)),n+=(typeof c=="symbol"?Number.NaN:Number(c)).toString(),a=r+2,r+=1;break}case F:{const c=t[l];if(l>=t.length||c==null)break;a<r&&(n+=e.slice(a,r)),n+=Math.floor(typeof c=="symbol"?Number.NaN:Number(c)).toString(),a=r+2,r+=1;break}case E:case P:case q:{if(l>=t.length||t[l]===void 0)break;a<r&&(n+=e.slice(a,r));const c=t[l],g=typeof c;if(g==="string"){n+=`'${c}'`,a=r+2,r+=1;break}if(g==="function"){n+=c.name?`[Function: ${c.name}]`:"[Function: <anonymous>]",a=r+2,r+=1;break}n+=i(c),a=r+2,r+=1;break}case p:{a<r&&(n+=e.slice(a,r)),n+="%",a=r+2,r+=1,l-=1;break}case C:{if(l>=t.length)break;a<r&&(n+=e.slice(a,r));const c=t[l];n+=typeof c=="object"&&c!==null?i(c):String(c),a=r+2,r+=1;break}default:typeof o.formatters?.[d]=="function"?(a<r&&(n+=e.slice(a,r)),n+=o.formatters[d](t[l]),a=r+2,r+=1):l-=1}l+=1}r+=1}if(a===-1&&!(o.appendExtraArguments&&l<t.length))return e;if(a===-1?n=e:a<e.length&&(n+=e.slice(a)),a!==-1&&s&&(n+="\x1B[0m"),o.appendExtraArguments&&l<t.length)for(let r=Math.max(l,0);r<t.length;r+=1){const d=t[r];n+=` ${typeof d=="object"&&d!==null?i(d):String(d)}`}return n},O=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([i,f])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof f!="function")throw new TypeError(`Formatter for %${i} is not a function`);const n=i.codePointAt(0);if(n===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);t[n]=f});const o=Object.freeze({formatters:t});return(i,f=[],n)=>n===void 0?w(i,f,o):w(i,f,{...n,formatters:t})};class W{#r;#t;#e;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#r=t}process(t){this.#e===void 0&&(this.#e=O({formatters:this.#t}));const o=this.#e;return t.message!==void 0&&(t.message=this.#o(o,t.message,t.context??[])),t}#o(t,o,i=[]){if(typeof o=="string")return t(o,i);if(typeof o=="object"&&o!==null){const f=o,n=Object.keys(f);for(let l=0;l<n.length;l+=1){const a=n[l],s=f[a];(typeof s=="string"||Array.isArray(s)||typeof s=="object")&&(f[a]=this.#o(t,s,i))}}return o}}export{W as default};
|
|
1
|
+
let h;const B=()=>(h!==void 0||(h=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),h),$=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,A=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,S=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,v=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,k=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),x=/\s+/,m=e=>{const t=B();t.has(e)&&(e=t.get(e));const r=$.exec(e);if(r)return[Number.parseInt(r[1],16),Number.parseInt(r[2],16),Number.parseInt(r[3],16)];const l=A.exec(e);if(l)return[Number.parseInt(`${l[1]}${l[1]}`,16),Number.parseInt(`${l[2]}${l[2]}`,16),Number.parseInt(`${l[3]}${l[3]}`,16)];const f=S.exec(e);if(f)return[Math.round(Math.max(0,Math.min(255,Number(f[1])))),Math.round(Math.max(0,Math.min(255,Number(f[2])))),Math.round(Math.max(0,Math.min(255,Number(f[3]))))];const n=v.exec(e);if(n){let a=Number(n[1])%360;a<0&&(a+=360);const i=Math.max(0,Math.min(100,Number(n[2])))/100,s=Math.max(0,Math.min(100,Number(n[3])))/100,u=(1-Math.abs(2*s-1))*i,b=u*(1-Math.abs(a/60%2-1)),o=s-u/2;let d,c,g;return a<60?{0:d,1:c,2:g}=[u,b,0]:a<120?{0:d,1:c,2:g}=[b,u,0]:a<180?{0:d,1:c,2:g}=[0,u,b]:a<240?{0:d,1:c,2:g}=[0,b,u]:a<300?{0:d,1:c,2:g}=[b,0,u]:{0:d,1:c,2:g}=[u,0,b],[Math.round((d+o)*255),Math.round((c+o)*255),Math.round((g+o)*255)]}return null},y=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],N=e=>{if(typeof e!="string")return k();const t=k(),r=[];let l=!1,f=null,n=0,a="";for(const i of e){if(i==="(")n+=1;else if(n>0)i===")"&&(n-=1);else if(l){if(i===";"){const s=a.trim();s!==""&&r.push([f,s]),f=null,a="",l=!1;continue}}else if(i===":"){f=a.trim(),a="",l=!0;continue}a+=i}if(l&&n===0){const i=a.trim();i!==""&&r.push([f,i]),f=null,a=""}for(const{0:i,1:s}of r)switch(i){case"background-color":{s!=null&&(t.backgroundColor=s);break}case"color":{s!=null&&(t.color=s);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(s)&&(t.fontStyle="italic");break}case"font-weight":{s==="bold"&&(t.fontWeight=s);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=s.split(x);for(const b of u){const o=m(b);o!=null?t.textDecorationColor=o:["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b)}break}case"text-decoration-color":{const u=m(s);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=s.split(x);for(const b of u)["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b);break}}return t},D=(e,t)=>{t=t??k();let r="";if(!y(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)r+="\x1B[49m";else switch(e.backgroundColor){case"black":{r+="\x1B[40m";break}case"blue":{r+="\x1B[44m";break}case"cyan":{r+="\x1B[46m";break}case"green":{r+="\x1B[42m";break}case"magenta":{r+="\x1B[45m";break}case"red":{r+="\x1B[41m";break}case"white":{r+="\x1B[47m";break}case"yellow":{r+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:l,1:f,2:n}=e.backgroundColor;r+=`\x1B[48;2;${String(l)};${String(f)};${String(n)}m`}else{const l=m(e.backgroundColor);if(l===null)r+="\x1B[49m";else{const{0:f,1:n,2:a}=l;r+=`\x1B[48;2;${String(f)};${String(n)};${String(a)}m`}}}if(!y(e.color,t.color))if(e.color==null)r+="\x1B[39m";else switch(e.color){case"black":{r+="\x1B[30m";break}case"blue":{r+="\x1B[34m";break}case"cyan":{r+="\x1B[36m";break}case"green":{r+="\x1B[32m";break}case"magenta":{r+="\x1B[35m";break}case"red":{r+="\x1B[31m";break}case"white":{r+="\x1B[37m";break}case"yellow":{r+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:l,1:f,2:n}=e.color;r+=`\x1B[38;2;${String(l)};${String(f)};${String(n)}m`}else{const l=m(e.color);if(l===null)r+="\x1B[39m";else{const{0:f,1:n,2:a}=l;r+=`\x1B[38;2;${String(f)};${String(n)};${String(a)}m`}}}if(e.fontWeight!==t.fontWeight&&(r+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(r+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!y(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)r+="\x1B[59m";else{const{0:l,1:f,2:n}=e.textDecorationColor;r+=`\x1B[58;2;${String(l)};${String(f)};${String(n)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(r+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(r+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(r+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),r},M=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},p="%".codePointAt(0),C="s".codePointAt(0),j="d".codePointAt(0),L="f".codePointAt(0),F="i".codePointAt(0),P="O".codePointAt(0),q="o".codePointAt(0),E="j".codePointAt(0),O="c".codePointAt(0),w=(e,t=[],r={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const l=r.stringify??M,f=1;if(typeof e=="object"){const o=t.length+f;if(o===1)return"{}";const d=Array.from({length:o});d[0]=l(e);for(let c=1;c<o;c+=1)d[c]=l(t[c-f]);return d.join(" ")}if(t.length===0)return e;let n="",a=1-f,i=-1,s=!1,u;const b=r.colors??globalThis.window===void 0;for(let o=0;o<e.length;){if(e.codePointAt(o)===p&&o+1<e.length){i=i>-1?i:0;const d=e.codePointAt(o+1);switch(d){case O:{if(i<o&&(n+=e.slice(i,o)),b){const c=N(t[a]),g=D(c,u);n+=g,g!==""&&(s=!0,u=c)}i=o+2,o+=1;break}case j:case L:{const c=t[a];if(a>=t.length||c==null)break;i<o&&(n+=e.slice(i,o)),n+=(typeof c=="symbol"?Number.NaN:Number(c)).toString(),i=o+2,o+=1;break}case F:{const c=t[a];if(a>=t.length||c==null)break;i<o&&(n+=e.slice(i,o)),n+=Math.floor(typeof c=="symbol"?Number.NaN:Number(c)).toString(),i=o+2,o+=1;break}case E:case P:case q:{if(a>=t.length||t[a]===void 0)break;i<o&&(n+=e.slice(i,o));const c=t[a],g=typeof c;if(g==="string"){n+=`'${c}'`,i=o+2,o+=1;break}if(g==="function"){n+=c.name?`[Function: ${c.name}]`:"[Function: <anonymous>]",i=o+2,o+=1;break}n+=l(c),i=o+2,o+=1;break}case p:{i<o&&(n+=e.slice(i,o)),n+="%",i=o+2,o+=1,a-=1;break}case C:{if(a>=t.length)break;i<o&&(n+=e.slice(i,o));const c=t[a];n+=typeof c=="object"&&c!==null?l(c):String(c),i=o+2,o+=1;break}default:typeof r.formatters?.[d]=="function"?(i<o&&(n+=e.slice(i,o)),n+=r.formatters[d](t[a]),i=o+2,o+=1):a-=1}a+=1}o+=1}if(i===-1&&!(r.appendExtraArguments&&a<t.length))return e;if(i===-1?n=e:i<e.length&&(n+=e.slice(i)),i!==-1&&s&&(n+="\x1B[0m"),r.appendExtraArguments&&a<t.length)for(let o=Math.max(a,0);o<t.length;o+=1){const d=t[o];n+=` ${typeof d=="object"&&d!==null?l(d):String(d)}`}return n},I=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([f,n])=>{if(f.length===0)throw new Error(`Formatter %${f} has no characters`);if(f.length>1)throw new Error(`Formatter %${f} has more than one character`);if(typeof n!="function")throw new TypeError(`Formatter for %${f} is not a function`);const a=f.codePointAt(0);if(a===void 0)throw new Error(`${f}.codePointAt(0) failed to return a value, please report this issue`);t[a]=n});const r={...e};delete r.formatters;const l=Object.freeze({...r,formatters:t});return(f,n=[],a)=>a===void 0?w(f,n,l):w(f,n,{...r,...a,formatters:t})},W='"[Circular]"';class _{#e;#r;#t;constructor(t={}){this.#r=t.formatters}setStringify(t){this.#e=t}process(t){this.#t===void 0&&(this.#t=I({formatters:this.#r,stringify:l=>this.#n(l)}));const r=this.#t;return t.message!==void 0&&(t.message=this.#o(r,t.message,t.context??[])),t}#n(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return W}try{return this.#e(t)}catch(r){return JSON.stringify(`[unserializable: ${r instanceof Error?r.message:String(r)}]`)}}#o(t,r,l=[]){if(typeof r=="string")return t(r,l);if(typeof r=="object"&&r!==null){const f=r,n=Object.keys(f);for(let a=0;a<n.length;a+=1){const i=n[a],s=f[i];(typeof s=="string"||Array.isArray(s)||typeof s=="object")&&(f[i]=this.#o(t,s,l))}}return r}}export{_ as default};
|
|
@@ -1,74 +1,73 @@
|
|
|
1
|
-
import { M as Meta, P as Processor } from "../packem_shared/types.d-
|
|
1
|
+
import { M as Meta, P as Processor } from "../packem_shared/types.d-4ge_rME4.js";
|
|
2
2
|
import '@visulima/colorize';
|
|
3
3
|
import '@visulima/interactive-manager';
|
|
4
|
-
import 'type-fest';
|
|
5
4
|
/**
|
|
6
|
-
* Configuration options for the OpenTelemetry processor.
|
|
7
|
-
*/
|
|
5
|
+
* Configuration options for the OpenTelemetry processor.
|
|
6
|
+
*/
|
|
8
7
|
interface OpenTelemetryProcessorOptions {
|
|
9
8
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
* Field name for the span ID. Defaults to 'span_id'
|
|
10
|
+
*/
|
|
12
11
|
spanIdFieldName?: string;
|
|
13
12
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
* If specified, all trace fields will be nested under this key
|
|
14
|
+
*/
|
|
16
15
|
traceFieldName?: string;
|
|
17
16
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
* Field name for the trace flags. Defaults to 'trace_flags'
|
|
18
|
+
*/
|
|
20
19
|
traceFlagsFieldName?: string;
|
|
21
20
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
* Field name for the trace ID. Defaults to 'trace_id'
|
|
22
|
+
*/
|
|
24
23
|
traceIdFieldName?: string;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
|
-
* OpenTelemetry Processor.
|
|
28
|
-
*
|
|
29
|
-
* A processor that adds OpenTelemetry trace context to log metadata.
|
|
30
|
-
* Extracts trace ID, span ID, and trace flags from the active OpenTelemetry span
|
|
31
|
-
* and adds them to the log context for distributed tracing correlation.
|
|
32
|
-
* @template L - The log level type
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* import { createPail } from "@visulima/pail";
|
|
36
|
-
* import { OpenTelemetryProcessor } from "@visulima/pail/processor/opentelemetry";
|
|
37
|
-
*
|
|
38
|
-
* const logger = createPail({
|
|
39
|
-
* processors: [new OpenTelemetryProcessor()]
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* logger.info("Processing request");
|
|
43
|
-
* // Context includes: { trace_id: "...", span_id: "...", trace_flags: "01" }
|
|
44
|
-
* ```
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // With custom field names
|
|
48
|
-
* const logger = createPail({
|
|
49
|
-
* processors: [new OpenTelemetryProcessor({
|
|
50
|
-
* traceFieldName: "trace",
|
|
51
|
-
* traceIdFieldName: "traceId",
|
|
52
|
-
* spanIdFieldName: "spanId"
|
|
53
|
-
* })]
|
|
54
|
-
* });
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
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
|
+
*/
|
|
57
56
|
declare class OpenTelemetryProcessor<L extends string = string> implements Processor<L> {
|
|
58
57
|
#private;
|
|
59
58
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
* Creates a new OpenTelemetryProcessor instance.
|
|
60
|
+
* @param options Configuration options for field names and nesting
|
|
61
|
+
*/
|
|
63
62
|
constructor(options?: OpenTelemetryProcessorOptions);
|
|
64
63
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
*/
|
|
72
71
|
process(meta: Meta<L>): Meta<L>;
|
|
73
72
|
}
|
|
74
73
|
export { OpenTelemetryProcessor, OpenTelemetryProcessorOptions };
|