halua 3.0.0 → 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/package.json
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "halua",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
|
+
"description": "Tiny zero-dependency logger with pluggable dispatchers, child contexts, minor levels (e.g. INFO+5) and safe formatting",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "lib/index.
|
|
7
|
-
"module": "lib/index.
|
|
6
|
+
"main": "lib/index.cjs",
|
|
7
|
+
"module": "lib/index.js",
|
|
8
8
|
"types": "lib/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./lib/index.d.ts",
|
|
13
|
+
"default": "./lib/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./lib/index.d.ts",
|
|
17
|
+
"default": "./lib/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
9
21
|
"files": [
|
|
10
|
-
"lib"
|
|
22
|
+
"lib",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
11
25
|
],
|
|
12
26
|
"scripts": {
|
|
13
27
|
"test": "vitest",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
28
|
+
"dev": "vitest",
|
|
29
|
+
"bench": "node benchmarks/main-bench.js",
|
|
30
|
+
"build": "vite build",
|
|
31
|
+
"prepare": "pnpm run lint && pnpm run test run && pnpm run build",
|
|
32
|
+
"format:check": "prettier --check \"**/*.{ts,js,json,md,yml,yaml}\"",
|
|
33
|
+
"format": "prettier --write \"**/*.{ts,js,json,md,yml,yaml}\"",
|
|
34
|
+
"lint": "pnpm run format:check",
|
|
17
35
|
"postversion": "git push && git push --tags"
|
|
18
36
|
},
|
|
19
37
|
"repository": {
|
|
@@ -35,13 +53,15 @@
|
|
|
35
53
|
},
|
|
36
54
|
"homepage": "https://github.com/inshinrei/halua#readme",
|
|
37
55
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"typescript": "
|
|
44
|
-
"
|
|
56
|
+
"@microsoft/api-extractor": "7.58.7",
|
|
57
|
+
"@types/node": "25.9.1",
|
|
58
|
+
"prettier": "3.8.3",
|
|
59
|
+
"tinybench": "6.0.2",
|
|
60
|
+
"ts-node": "10.9.2",
|
|
61
|
+
"typescript": "6.0.3",
|
|
62
|
+
"vite": "6.4.2",
|
|
63
|
+
"vite-plugin-dts": "5.0.1",
|
|
64
|
+
"vitest": "4.1.7"
|
|
45
65
|
},
|
|
46
66
|
"publishConfig": {
|
|
47
67
|
"access": "public"
|
package/lib/index.d.cts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
declare enum Level {
|
|
2
|
-
Trace = "TRACE",
|
|
3
|
-
Debug = "DEBUG",
|
|
4
|
-
Info = "INFO",
|
|
5
|
-
Notice = "NOTICE",
|
|
6
|
-
Warn = "WARN",
|
|
7
|
-
Error = "ERROR",
|
|
8
|
-
Fatal = "FATAL"
|
|
9
|
-
}
|
|
10
|
-
type LogLevel = string;
|
|
11
|
-
|
|
12
|
-
interface HandlerExecuteMeta {
|
|
13
|
-
timestamp: number;
|
|
14
|
-
level: LogLevel;
|
|
15
|
-
}
|
|
16
|
-
interface Handler {
|
|
17
|
-
/** indicates min level to log */
|
|
18
|
-
level: LogLevel | undefined;
|
|
19
|
-
/** indicates exact levels to log */
|
|
20
|
-
exact: Array<LogLevel> | null;
|
|
21
|
-
/** indicates if objects should contain spaces and tabs */
|
|
22
|
-
spacing?: boolean;
|
|
23
|
-
printTimestamp?: boolean;
|
|
24
|
-
printLevel?: boolean;
|
|
25
|
-
execute: (meta: HandlerExecuteMeta) => Generator<YieldMessage, void, NextMessage>;
|
|
26
|
-
formatArg?: (value: any) => any;
|
|
27
|
-
formatTimestamp?: (value: number) => string;
|
|
28
|
-
}
|
|
29
|
-
interface BaseHandlerOptions {
|
|
30
|
-
level?: LogLevel;
|
|
31
|
-
exact?: LogLevel | Array<LogLevel>;
|
|
32
|
-
spacing?: boolean;
|
|
33
|
-
printTimestamp?: boolean;
|
|
34
|
-
printLevel?: boolean;
|
|
35
|
-
}
|
|
36
|
-
interface NextMessage {
|
|
37
|
-
type: NextMessageType;
|
|
38
|
-
value: any;
|
|
39
|
-
prev?: string;
|
|
40
|
-
}
|
|
41
|
-
interface YieldMessage {
|
|
42
|
-
type: YieldMessageType;
|
|
43
|
-
}
|
|
44
|
-
type YieldMessageType = "pass" | "done" | "init";
|
|
45
|
-
type NextMessageType = "arg" | "done" | "init";
|
|
46
|
-
|
|
47
|
-
interface HaluaLogger {
|
|
48
|
-
create: {
|
|
49
|
-
(handler: PassedHandler): HaluaLogger;
|
|
50
|
-
(options: HaluaOptions): HaluaLogger;
|
|
51
|
-
(arg1?: PassedHandler | HaluaOptions, options?: HaluaOptions): HaluaLogger;
|
|
52
|
-
};
|
|
53
|
-
child: (...args: any[]) => HaluaLogger;
|
|
54
|
-
setHandlers: (handler: PassedHandler) => void;
|
|
55
|
-
appendHandlers: (handler: PassedHandler) => void;
|
|
56
|
-
logTo: (level: LogLevel, ...args: any[]) => void;
|
|
57
|
-
trace: (...args: any[]) => void;
|
|
58
|
-
debug: (...args: any[]) => void;
|
|
59
|
-
info: (...args: any[]) => void;
|
|
60
|
-
warn: (...args: any[]) => void;
|
|
61
|
-
notice: (...args: any[]) => void;
|
|
62
|
-
error: (...args: any[]) => void;
|
|
63
|
-
fatal: (...args: any[]) => void;
|
|
64
|
-
assert: (assertion: boolean, ...args: any[]) => void;
|
|
65
|
-
}
|
|
66
|
-
interface HaluaOptions {
|
|
67
|
-
level?: LogLevel;
|
|
68
|
-
withArgs?: Array<any>;
|
|
69
|
-
}
|
|
70
|
-
type PassedHandler = (() => Handler) | Array<() => Handler>;
|
|
71
|
-
|
|
72
|
-
declare class Halua implements HaluaLogger {
|
|
73
|
-
private options;
|
|
74
|
-
private readonly passedHandlers;
|
|
75
|
-
private handlers;
|
|
76
|
-
private balancer;
|
|
77
|
-
constructor(passed: PassedHandler, options?: HaluaOptions);
|
|
78
|
-
create(arg1?: PassedHandler | HaluaOptions, arg2?: HaluaOptions | undefined): HaluaLogger;
|
|
79
|
-
child(...args: any[]): HaluaLogger;
|
|
80
|
-
setHandlers(handler: PassedHandler): void;
|
|
81
|
-
appendHandlers(handler: PassedHandler): void;
|
|
82
|
-
logTo(level: LogLevel, ...args: any[]): void;
|
|
83
|
-
trace(...args: any[]): void;
|
|
84
|
-
debug(...args: any[]): void;
|
|
85
|
-
info(...args: any[]): void;
|
|
86
|
-
warn(...args: any[]): void;
|
|
87
|
-
notice(...args: any[]): void;
|
|
88
|
-
error(...args: any[]): void;
|
|
89
|
-
fatal(...args: any[]): void;
|
|
90
|
-
assert(assertion: boolean, ...args: any[]): void;
|
|
91
|
-
private updateBalancer;
|
|
92
|
-
private sendToBalancer;
|
|
93
|
-
private supposeIsHandler;
|
|
94
|
-
private buildHandlers;
|
|
95
|
-
private bindMethods;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
type SendMethod = (data: string) => void;
|
|
99
|
-
|
|
100
|
-
interface OutputConsole {
|
|
101
|
-
debug: (...args: any[]) => void;
|
|
102
|
-
info: (...args: any[]) => void;
|
|
103
|
-
warn: (...args: any[]) => void;
|
|
104
|
-
error: (...args: any[]) => void;
|
|
105
|
-
}
|
|
106
|
-
interface ConsoleHandlerOptions extends Omit<BaseHandlerOptions, "spacing"> {
|
|
107
|
-
}
|
|
108
|
-
declare function NewConsoleHandler(console: OutputConsole, options?: ConsoleHandlerOptions): () => {
|
|
109
|
-
level: LogLevel | undefined;
|
|
110
|
-
exact: Array<LogLevel> | null;
|
|
111
|
-
readonly console: OutputConsole;
|
|
112
|
-
readonly formatArg: (arg: any) => any;
|
|
113
|
-
applyOptionalOptions(options: ConsoleHandlerOptions): void;
|
|
114
|
-
execute(meta: {
|
|
115
|
-
timestamp: number;
|
|
116
|
-
level: string;
|
|
117
|
-
}): Generator<YieldMessage, void, NextMessage>;
|
|
118
|
-
sendMethod: SendMethod;
|
|
119
|
-
printTimestamp: boolean;
|
|
120
|
-
printLevel: boolean;
|
|
121
|
-
formatTimestamp(t: number): string;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
interface JSONLogHandlerOptions extends BaseHandlerOptions {
|
|
125
|
-
}
|
|
126
|
-
declare function NewJSONHandler(send: (data: string) => void, options?: JSONLogHandlerOptions): () => {
|
|
127
|
-
level: LogLevel | undefined;
|
|
128
|
-
exact: Array<LogLevel> | null;
|
|
129
|
-
readonly formatArg: (arg: any) => string;
|
|
130
|
-
execute(meta: HandlerExecuteMeta): Generator<YieldMessage, void, NextMessage>;
|
|
131
|
-
formatTimestamp(t: number): string;
|
|
132
|
-
applyOptionalOptions(options: JSONLogHandlerOptions): void;
|
|
133
|
-
sendMethod: SendMethod;
|
|
134
|
-
printTimestamp: boolean;
|
|
135
|
-
printLevel: boolean;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
interface TextLogHandlerOptions extends BaseHandlerOptions {
|
|
139
|
-
}
|
|
140
|
-
declare function NewTextHandler(send: (data: string) => void, options?: TextLogHandlerOptions): () => {
|
|
141
|
-
level: LogLevel | undefined;
|
|
142
|
-
exact: Array<LogLevel> | null;
|
|
143
|
-
readonly formatArg: (value: any) => string;
|
|
144
|
-
applyOptionalOptions(options: TextLogHandlerOptions): void;
|
|
145
|
-
sendMethod: SendMethod;
|
|
146
|
-
printTimestamp: boolean;
|
|
147
|
-
printLevel: boolean;
|
|
148
|
-
execute(meta: {
|
|
149
|
-
timestamp: number;
|
|
150
|
-
level: string;
|
|
151
|
-
}): Generator<YieldMessage, void, NextMessage>;
|
|
152
|
-
formatTimestamp(t: number): string;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
declare const halua: Halua;
|
|
156
|
-
|
|
157
|
-
export { type HaluaLogger, type Handler, Level, NewConsoleHandler, NewJSONHandler, NewTextHandler, halua };
|