halua 2.0.2 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +356 -7
- package/lib/AGENTS.md +143 -0
- package/lib/index.cjs +752 -432
- package/lib/index.d.ts +232 -157
- package/lib/index.js +739 -403
- package/package.json +35 -15
- package/lib/index.d.cts +0 -157
package/lib/index.d.ts
CHANGED
|
@@ -1,157 +1,232 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
level
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
declare interface Argument {
|
|
2
|
+
type: ArgumentType;
|
|
3
|
+
value: any;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare type ArgumentType = "undefined" | "null" | "boolean" | "string" | "number" | "array" | "object" | "symbol" | "typedarray" | "arraybuffer" | "bigint" | "map" | "set" | "weakmap" | "weakset" | "date" | "nan" | "infinity" | "function" | "error";
|
|
7
|
+
|
|
8
|
+
declare interface BaseDispatcherOptions {
|
|
9
|
+
level?: LogLevel;
|
|
10
|
+
exact?: LogLevel | Array<LogLevel>;
|
|
11
|
+
spacing?: boolean;
|
|
12
|
+
printTimestamp?: boolean;
|
|
13
|
+
printLevel?: boolean;
|
|
14
|
+
/** RegExp for redacting sensitive data (keys in objs/maps + content matches in strings). Takes precedence over any logger-level redactDataRegExp. */
|
|
15
|
+
redactDataRegExp?: RegExp;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare interface ConsoleDispatcherOptions extends Omit<BaseDispatcherOptions, "spacing"> {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare interface ConsoleLike {
|
|
22
|
+
debug: (...args: any[]) => void;
|
|
23
|
+
info: (...args: any[]) => void;
|
|
24
|
+
warn: (...args: any[]) => void;
|
|
25
|
+
error: (...args: any[]) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Default RegExp for redacting sensitive data in logs.
|
|
30
|
+
* Matches common sensitive key names (e.g. password, apiKey, token, email, ssn)
|
|
31
|
+
* via substring (for camelCase/snake_case keys) and common sensitive value patterns
|
|
32
|
+
* (JWTs, emails, SSNs, credit cards, bearer tokens).
|
|
33
|
+
* Use with `redactDataRegExp` option on loggers or dispatchers.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DefaultRedactRegExp: RegExp;
|
|
36
|
+
|
|
37
|
+
export declare interface Dispatcher {
|
|
38
|
+
/** indicates min level to log */
|
|
39
|
+
level: LogLevel | undefined;
|
|
40
|
+
/** indicates exact levels to log */
|
|
41
|
+
exact: Array<LogLevel> | null;
|
|
42
|
+
/** indicates if objects should contain spaces and tabs */
|
|
43
|
+
spacing?: boolean;
|
|
44
|
+
printTimestamp?: boolean;
|
|
45
|
+
printLevel?: boolean;
|
|
46
|
+
/** RegExp for redacting sensitive data in this dispatcher's output (takes precedence over logger-level) */
|
|
47
|
+
redactDataRegExp?: RegExp;
|
|
48
|
+
/** primary dispatch: receives the execution meta, the primary log values (args), and optional errorMeta
|
|
49
|
+
* (only populated for calls that went through .error(err, meta) or .assert(cond, err, meta)).
|
|
50
|
+
* The errorMeta is deliberately kept separate from args so it does not pollute the "log values" list
|
|
51
|
+
* and can be rendered specially by Text/JSON/Console dispatchers (e.g. top-level "meta" field in JSON).
|
|
52
|
+
*/
|
|
53
|
+
dispatch: (meta: DispatcherExecuteMeta, args: any[], errorMeta?: Record<string, any>) => void;
|
|
54
|
+
formatArg?: (value: any) => any;
|
|
55
|
+
formatTimestamp?: (value: number) => string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export declare class DispatcherBase implements Dispatcher {
|
|
59
|
+
sendMethod: SendMethod;
|
|
60
|
+
formatArg: ((value: any) => any) | undefined;
|
|
61
|
+
level: LogLevel | undefined;
|
|
62
|
+
exact: Array<LogLevel> | null;
|
|
63
|
+
printTimestamp: boolean;
|
|
64
|
+
printLevel: boolean;
|
|
65
|
+
redactDataRegExp?: RegExp;
|
|
66
|
+
_lastTimestampSec: number;
|
|
67
|
+
_lastTimestampStr: string;
|
|
68
|
+
constructor(send?: SendMethod, options?: BaseDispatcherOptions);
|
|
69
|
+
dispatch(meta: DispatcherExecuteMeta, args: any[], errorMeta?: Record<string, any>): void;
|
|
70
|
+
formatTimestamp(t: number): string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare interface DispatcherExecuteMeta {
|
|
74
|
+
timestamp: number;
|
|
75
|
+
level: LogLevel;
|
|
76
|
+
/** optional default redact regexp from the logger instance (per-dispatcher options override it) */
|
|
77
|
+
redactDataRegExp?: RegExp;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export declare function format(arg: Argument, spacing?: boolean): string;
|
|
81
|
+
|
|
82
|
+
export declare function getType(arg: any): ArgumentType;
|
|
83
|
+
|
|
84
|
+
declare class Halua<ErrorMeta = Record<string, any>> implements HaluaLogger<ErrorMeta> {
|
|
85
|
+
private options;
|
|
86
|
+
private readonly passedDispatchers;
|
|
87
|
+
private dispatchers;
|
|
88
|
+
private balancer;
|
|
89
|
+
private stamps;
|
|
90
|
+
constructor(passed: PassedDispatcher, options?: HaluaOptions);
|
|
91
|
+
create<EM = ErrorMeta>(arg1?: PassedDispatcher | HaluaOptions, arg2?: HaluaOptions | undefined): HaluaLogger<EM>;
|
|
92
|
+
child(...args: any[]): HaluaLogger<ErrorMeta>;
|
|
93
|
+
setDispatchers(dispatcher: PassedDispatcher): void;
|
|
94
|
+
appendDispatchers(dispatcher: PassedDispatcher): void;
|
|
95
|
+
logTo(level: LogLevel, ...args: any[]): void;
|
|
96
|
+
trace(...args: any[]): void;
|
|
97
|
+
debug(...args: any[]): void;
|
|
98
|
+
info(...args: any[]): void;
|
|
99
|
+
warn(...args: any[]): void;
|
|
100
|
+
notice(...args: any[]): void;
|
|
101
|
+
error(error: unknown, meta?: ErrorMeta): void;
|
|
102
|
+
fatal(...args: any[]): void;
|
|
103
|
+
assert(assertion: boolean, error: unknown, meta?: ErrorMeta): void;
|
|
104
|
+
stamp(label: string, id?: any): () => void;
|
|
105
|
+
stampEnd(id: any): void;
|
|
106
|
+
private endStamp;
|
|
107
|
+
private updateBalancer;
|
|
108
|
+
private sendToBalancer;
|
|
109
|
+
private supposeIsDispatcher;
|
|
110
|
+
private isDispatcherSpec;
|
|
111
|
+
private buildDispatchers;
|
|
112
|
+
private bindMethods;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export declare const halua: Halua<Record<string, any>>;
|
|
116
|
+
|
|
117
|
+
export declare interface HaluaLogger<ErrorMeta = Record<string, any>> {
|
|
118
|
+
create: {
|
|
119
|
+
<EM = ErrorMeta>(dispatcher: PassedDispatcher): HaluaLogger<EM>;
|
|
120
|
+
<EM = ErrorMeta>(options: HaluaOptions): HaluaLogger<EM>;
|
|
121
|
+
<EM = ErrorMeta>(arg1?: PassedDispatcher | HaluaOptions, options?: HaluaOptions): HaluaLogger<EM>;
|
|
122
|
+
};
|
|
123
|
+
child: (...args: any[]) => HaluaLogger<ErrorMeta>;
|
|
124
|
+
setDispatchers: (dispatcher: PassedDispatcher) => void;
|
|
125
|
+
appendDispatchers: (dispatcher: PassedDispatcher) => void;
|
|
126
|
+
logTo: (level: LogLevel, ...args: any[]) => void;
|
|
127
|
+
trace: (...args: any[]) => void;
|
|
128
|
+
debug: (...args: any[]) => void;
|
|
129
|
+
info: (...args: any[]) => void;
|
|
130
|
+
warn: (...args: any[]) => void;
|
|
131
|
+
notice: (...args: any[]) => void;
|
|
132
|
+
error: (error: unknown, meta?: ErrorMeta) => void;
|
|
133
|
+
fatal: (...args: any[]) => void;
|
|
134
|
+
assert: (assertion: boolean, error: unknown, meta?: ErrorMeta) => void;
|
|
135
|
+
stamp: (label: string, id?: any) => () => void;
|
|
136
|
+
stampEnd: (id: any) => void;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare interface HaluaOptions {
|
|
140
|
+
level?: LogLevel;
|
|
141
|
+
withArgs?: Array<any>;
|
|
142
|
+
/** RegExp used to redact sensitive data (keys in objects/maps, content in strings). Overrides per-dispatcher if set on dispatcher. */
|
|
143
|
+
redactDataRegExp?: RegExp;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export declare enum Level {
|
|
147
|
+
Trace = "TRACE",
|
|
148
|
+
Debug = "DEBUG",
|
|
149
|
+
Info = "INFO",
|
|
150
|
+
Notice = "NOTICE",
|
|
151
|
+
Warn = "WARN",
|
|
152
|
+
Error = "ERROR",
|
|
153
|
+
Fatal = "FATAL"
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
declare type LogLevel = string;
|
|
157
|
+
|
|
158
|
+
export declare function NewConsoleColoredDispatcher(console: ConsoleLike, options?: ConsoleDispatcherOptions): () => {
|
|
159
|
+
readonly console: ConsoleLike;
|
|
160
|
+
dispatch(meta: DispatcherExecuteMeta, rawArgs: any[], errorMeta?: Record<string, any>): void;
|
|
161
|
+
sendMethod: SendMethod;
|
|
162
|
+
formatArg: ((value: any) => any) | undefined;
|
|
163
|
+
level: LogLevel | undefined;
|
|
164
|
+
exact: Array< LogLevel> | null;
|
|
165
|
+
printTimestamp: boolean;
|
|
166
|
+
printLevel: boolean;
|
|
167
|
+
redactDataRegExp?: RegExp;
|
|
168
|
+
_lastTimestampSec: number;
|
|
169
|
+
_lastTimestampStr: string;
|
|
170
|
+
formatTimestamp(t: number): string;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export declare function NewConsoleDispatcher(console: ConsoleLike, options?: ConsoleDispatcherOptions): () => {
|
|
174
|
+
readonly console: ConsoleLike;
|
|
175
|
+
dispatch(meta: DispatcherExecuteMeta, rawArgs: any[], errorMeta?: Record<string, any>): void;
|
|
176
|
+
sendMethod: SendMethod;
|
|
177
|
+
formatArg: ((value: any) => any) | undefined;
|
|
178
|
+
level: LogLevel | undefined;
|
|
179
|
+
exact: Array< LogLevel> | null;
|
|
180
|
+
printTimestamp: boolean;
|
|
181
|
+
printLevel: boolean;
|
|
182
|
+
redactDataRegExp?: RegExp;
|
|
183
|
+
_lastTimestampSec: number;
|
|
184
|
+
_lastTimestampStr: string;
|
|
185
|
+
formatTimestamp(t: number): string;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export declare function NewJSONDispatcher(send: (data: string, errorMeta?: Record<string, any>) => void, options?: BaseDispatcherOptions): () => {
|
|
189
|
+
dispatch(meta: DispatcherExecuteMeta, rawArgs: any[], errorMeta?: Record<string, any>): void;
|
|
190
|
+
formatTimestamp(t: number): string;
|
|
191
|
+
sendMethod: SendMethod;
|
|
192
|
+
formatArg: ((value: any) => any) | undefined;
|
|
193
|
+
level: LogLevel | undefined;
|
|
194
|
+
exact: Array< LogLevel> | null;
|
|
195
|
+
printTimestamp: boolean;
|
|
196
|
+
printLevel: boolean;
|
|
197
|
+
redactDataRegExp?: RegExp;
|
|
198
|
+
_lastTimestampSec: number;
|
|
199
|
+
_lastTimestampStr: string;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export declare function NewTextDispatcher(send: (data: string, errorMeta?: Record<string, any>) => void, options?: BaseDispatcherOptions): () => {
|
|
203
|
+
sendMethod: SendMethod;
|
|
204
|
+
formatArg: ((value: any) => any) | undefined;
|
|
205
|
+
level: LogLevel | undefined;
|
|
206
|
+
exact: Array< LogLevel> | null;
|
|
207
|
+
printTimestamp: boolean;
|
|
208
|
+
printLevel: boolean;
|
|
209
|
+
redactDataRegExp?: RegExp;
|
|
210
|
+
_lastTimestampSec: number;
|
|
211
|
+
_lastTimestampStr: string;
|
|
212
|
+
dispatch(meta: DispatcherExecuteMeta, args: any[], errorMeta?: Record<string, any>): void;
|
|
213
|
+
formatTimestamp(t: number): string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
declare type PassedDispatcher = (() => Dispatcher) | Array<() => Dispatcher>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Recursively redacts sensitive data from a value according to regexp.
|
|
220
|
+
* - Strings (and strings inside arrays): matched substrings replaced by "^_^"
|
|
221
|
+
* - Objects/Maps: if *key* matches regexp, the corresponding value is replaced by "^_^" entirely
|
|
222
|
+
* - Handles circulars safely (returns "[Circular]")
|
|
223
|
+
* - Also redacts inside Error messages
|
|
224
|
+
* - Other types passed through
|
|
225
|
+
*/
|
|
226
|
+
export declare function redact(value: any, regexp?: RegExp): any;
|
|
227
|
+
|
|
228
|
+
declare type SendMethod = (data: string, errorMeta?: Record<string, any>) => void;
|
|
229
|
+
|
|
230
|
+
export declare function toJSONValue(value: any): any;
|
|
231
|
+
|
|
232
|
+
export { }
|