where-log 0.1.1 → 0.2.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/README.md +90 -3
- package/dist/index.cjs +560 -37
- package/dist/index.d.cts +107 -4
- package/dist/index.d.ts +107 -4
- package/dist/index.mjs +544 -37
- package/package.json +5 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,32 +1,135 @@
|
|
|
1
|
+
type LogContext = Record<string, unknown>;
|
|
2
|
+
|
|
3
|
+
type LogMode = "pretty" | "fast";
|
|
4
|
+
declare function formatLabeledValue(label: string | undefined, formattedValue: unknown): unknown;
|
|
5
|
+
|
|
6
|
+
type LogLevel = "info" | "success" | "warn" | "error" | "debug";
|
|
7
|
+
type LogConsoleMethod = "log" | "info" | "warn" | "error" | "debug";
|
|
8
|
+
|
|
1
9
|
type ParsedFrame = {
|
|
2
10
|
file: string;
|
|
3
11
|
line: number;
|
|
4
12
|
};
|
|
13
|
+
declare function parseFrameLine(frame: string): ParsedFrame | null;
|
|
14
|
+
declare function getCallerFromStack(stack?: string): ParsedFrame;
|
|
15
|
+
|
|
16
|
+
type LogLevelStyle = "compact";
|
|
5
17
|
type FormatterInput = {
|
|
6
18
|
location: string;
|
|
7
19
|
label?: string;
|
|
8
20
|
value: unknown;
|
|
9
21
|
formattedValue: unknown;
|
|
22
|
+
level?: LogLevel;
|
|
23
|
+
levelTag?: string;
|
|
10
24
|
};
|
|
11
25
|
type FormatterOutput = {
|
|
12
26
|
locationLine: unknown;
|
|
13
27
|
valueLine: unknown;
|
|
14
28
|
};
|
|
15
29
|
type LogOptions = {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
mode?: LogMode;
|
|
32
|
+
includeLocation?: boolean;
|
|
33
|
+
inspectDepth?: number;
|
|
34
|
+
maxArrayLength?: number;
|
|
35
|
+
redact?: string[];
|
|
16
36
|
colors?: boolean;
|
|
37
|
+
level?: LogLevel;
|
|
38
|
+
showLevelTag?: boolean;
|
|
39
|
+
levelTagStyle?: LogLevelStyle;
|
|
40
|
+
consoleMethod?: LogConsoleMethod;
|
|
41
|
+
context?: LogContext;
|
|
42
|
+
clockNow?: () => number;
|
|
43
|
+
warnThresholdMs?: number;
|
|
44
|
+
errorThresholdMs?: number;
|
|
45
|
+
includeDurationOnly?: boolean;
|
|
17
46
|
formatter?: (input: FormatterInput) => FormatterOutput;
|
|
18
47
|
};
|
|
19
|
-
|
|
20
|
-
|
|
48
|
+
type ResolvedLogArgs = {
|
|
49
|
+
label?: string;
|
|
50
|
+
value: unknown;
|
|
51
|
+
options?: LogOptions;
|
|
52
|
+
};
|
|
53
|
+
type OnceArgs = {
|
|
54
|
+
key: string;
|
|
55
|
+
label?: string;
|
|
56
|
+
value: unknown;
|
|
57
|
+
options?: LogOptions;
|
|
58
|
+
};
|
|
59
|
+
type TimeEndArgs = {
|
|
60
|
+
key: string;
|
|
61
|
+
label?: string;
|
|
62
|
+
value?: unknown;
|
|
63
|
+
options?: LogOptions;
|
|
64
|
+
};
|
|
21
65
|
declare function isLogOptions(value: unknown): value is LogOptions;
|
|
22
|
-
declare function
|
|
66
|
+
declare function resolveLogArgs(arg1: string | unknown, arg2?: unknown | LogOptions, arg3?: LogOptions): ResolvedLogArgs;
|
|
67
|
+
declare function resolveOnceArgs(key: string, arg2: string | unknown, arg3?: unknown | LogOptions, arg4?: LogOptions): OnceArgs;
|
|
68
|
+
declare function resolveTimeEndArgs(key: string, arg2?: string | unknown | LogOptions, arg3?: unknown | LogOptions, arg4?: LogOptions): TimeEndArgs;
|
|
69
|
+
declare function writeLine(method: LogConsoleMethod, line: unknown): void;
|
|
70
|
+
declare function mergeOptions(base: LogOptions | undefined, incoming: LogOptions | undefined): LogOptions | undefined;
|
|
71
|
+
declare function resolveTimingLevel(durationMs: number, options?: LogOptions): LogLevel;
|
|
23
72
|
declare function log(value: unknown, options?: LogOptions): void;
|
|
24
73
|
declare function log(label: string, value: unknown, options?: LogOptions): void;
|
|
74
|
+
declare function once(key: string, value: unknown, options?: LogOptions): void;
|
|
75
|
+
declare function once(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
76
|
+
declare function resetOnce(keys?: string[]): void;
|
|
77
|
+
declare function time(key: string, options?: LogOptions): void;
|
|
78
|
+
declare function timeEnd(key: string, options?: LogOptions): void;
|
|
79
|
+
declare function timeEnd(key: string, value: unknown, options?: LogOptions): void;
|
|
80
|
+
declare function timeEnd(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
81
|
+
declare function resetTimers(keys?: string[]): void;
|
|
82
|
+
declare function logDev(value: unknown, options?: LogOptions): void;
|
|
83
|
+
declare function logDev(label: string, value: unknown, options?: LogOptions): void;
|
|
84
|
+
declare function logProd(value: unknown, options?: LogOptions): void;
|
|
85
|
+
declare function logProd(label: string, value: unknown, options?: LogOptions): void;
|
|
86
|
+
type LoggerMethod = {
|
|
87
|
+
(value: unknown, options?: LogOptions): void;
|
|
88
|
+
(label: string, value: unknown, options?: LogOptions): void;
|
|
89
|
+
};
|
|
90
|
+
type OnceMethod = {
|
|
91
|
+
(key: string, value: unknown, options?: LogOptions): void;
|
|
92
|
+
(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
93
|
+
};
|
|
94
|
+
type TimeMethod = {
|
|
95
|
+
(key: string, options?: LogOptions): void;
|
|
96
|
+
};
|
|
97
|
+
type TimeEndMethod = {
|
|
98
|
+
(key: string, options?: LogOptions): void;
|
|
99
|
+
(key: string, value: unknown, options?: LogOptions): void;
|
|
100
|
+
(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
101
|
+
};
|
|
102
|
+
interface LoggerFn extends LoggerMethod {
|
|
103
|
+
info: LoggerMethod;
|
|
104
|
+
success: LoggerMethod;
|
|
105
|
+
warn: LoggerMethod;
|
|
106
|
+
error: LoggerMethod;
|
|
107
|
+
debug: LoggerMethod;
|
|
108
|
+
once: OnceMethod;
|
|
109
|
+
time: TimeMethod;
|
|
110
|
+
timeEnd: TimeEndMethod;
|
|
111
|
+
withContext: (context: LogContext) => LoggerFn;
|
|
112
|
+
resetOnce: (keys?: string[]) => void;
|
|
113
|
+
resetTimers: (keys?: string[]) => void;
|
|
114
|
+
}
|
|
115
|
+
declare function createLogger(presetOptions?: LogOptions): LoggerFn;
|
|
116
|
+
declare function withContext(context: LogContext, presetOptions?: LogOptions): LoggerFn;
|
|
117
|
+
declare const info: LoggerMethod;
|
|
118
|
+
declare const success: LoggerMethod;
|
|
119
|
+
declare const warn: LoggerMethod;
|
|
120
|
+
declare const error: LoggerMethod;
|
|
121
|
+
declare const debug: LoggerMethod;
|
|
25
122
|
declare const __internal: {
|
|
26
123
|
getCallerFromStack: typeof getCallerFromStack;
|
|
27
124
|
parseFrameLine: typeof parseFrameLine;
|
|
28
125
|
formatLabeledValue: typeof formatLabeledValue;
|
|
29
126
|
isLogOptions: typeof isLogOptions;
|
|
127
|
+
resolveLogArgs: typeof resolveLogArgs;
|
|
128
|
+
mergeOptions: typeof mergeOptions;
|
|
129
|
+
writeLine: typeof writeLine;
|
|
130
|
+
resolveOnceArgs: typeof resolveOnceArgs;
|
|
131
|
+
resolveTimeEndArgs: typeof resolveTimeEndArgs;
|
|
132
|
+
resolveTimingLevel: typeof resolveTimingLevel;
|
|
30
133
|
};
|
|
31
134
|
|
|
32
|
-
export { type FormatterInput, type FormatterOutput, type LogOptions, __internal, log };
|
|
135
|
+
export { type FormatterInput, type FormatterOutput, type LogConsoleMethod, type LogContext, type LogLevel, type LogMode, type LogOptions, type LoggerFn, type LoggerMethod, type OnceMethod, type TimeEndMethod, type TimeMethod, __internal, createLogger, debug, error, info, log, logDev, logProd, once, resetOnce, resetTimers, success, time, timeEnd, warn, withContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,135 @@
|
|
|
1
|
+
type LogContext = Record<string, unknown>;
|
|
2
|
+
|
|
3
|
+
type LogMode = "pretty" | "fast";
|
|
4
|
+
declare function formatLabeledValue(label: string | undefined, formattedValue: unknown): unknown;
|
|
5
|
+
|
|
6
|
+
type LogLevel = "info" | "success" | "warn" | "error" | "debug";
|
|
7
|
+
type LogConsoleMethod = "log" | "info" | "warn" | "error" | "debug";
|
|
8
|
+
|
|
1
9
|
type ParsedFrame = {
|
|
2
10
|
file: string;
|
|
3
11
|
line: number;
|
|
4
12
|
};
|
|
13
|
+
declare function parseFrameLine(frame: string): ParsedFrame | null;
|
|
14
|
+
declare function getCallerFromStack(stack?: string): ParsedFrame;
|
|
15
|
+
|
|
16
|
+
type LogLevelStyle = "compact";
|
|
5
17
|
type FormatterInput = {
|
|
6
18
|
location: string;
|
|
7
19
|
label?: string;
|
|
8
20
|
value: unknown;
|
|
9
21
|
formattedValue: unknown;
|
|
22
|
+
level?: LogLevel;
|
|
23
|
+
levelTag?: string;
|
|
10
24
|
};
|
|
11
25
|
type FormatterOutput = {
|
|
12
26
|
locationLine: unknown;
|
|
13
27
|
valueLine: unknown;
|
|
14
28
|
};
|
|
15
29
|
type LogOptions = {
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
mode?: LogMode;
|
|
32
|
+
includeLocation?: boolean;
|
|
33
|
+
inspectDepth?: number;
|
|
34
|
+
maxArrayLength?: number;
|
|
35
|
+
redact?: string[];
|
|
16
36
|
colors?: boolean;
|
|
37
|
+
level?: LogLevel;
|
|
38
|
+
showLevelTag?: boolean;
|
|
39
|
+
levelTagStyle?: LogLevelStyle;
|
|
40
|
+
consoleMethod?: LogConsoleMethod;
|
|
41
|
+
context?: LogContext;
|
|
42
|
+
clockNow?: () => number;
|
|
43
|
+
warnThresholdMs?: number;
|
|
44
|
+
errorThresholdMs?: number;
|
|
45
|
+
includeDurationOnly?: boolean;
|
|
17
46
|
formatter?: (input: FormatterInput) => FormatterOutput;
|
|
18
47
|
};
|
|
19
|
-
|
|
20
|
-
|
|
48
|
+
type ResolvedLogArgs = {
|
|
49
|
+
label?: string;
|
|
50
|
+
value: unknown;
|
|
51
|
+
options?: LogOptions;
|
|
52
|
+
};
|
|
53
|
+
type OnceArgs = {
|
|
54
|
+
key: string;
|
|
55
|
+
label?: string;
|
|
56
|
+
value: unknown;
|
|
57
|
+
options?: LogOptions;
|
|
58
|
+
};
|
|
59
|
+
type TimeEndArgs = {
|
|
60
|
+
key: string;
|
|
61
|
+
label?: string;
|
|
62
|
+
value?: unknown;
|
|
63
|
+
options?: LogOptions;
|
|
64
|
+
};
|
|
21
65
|
declare function isLogOptions(value: unknown): value is LogOptions;
|
|
22
|
-
declare function
|
|
66
|
+
declare function resolveLogArgs(arg1: string | unknown, arg2?: unknown | LogOptions, arg3?: LogOptions): ResolvedLogArgs;
|
|
67
|
+
declare function resolveOnceArgs(key: string, arg2: string | unknown, arg3?: unknown | LogOptions, arg4?: LogOptions): OnceArgs;
|
|
68
|
+
declare function resolveTimeEndArgs(key: string, arg2?: string | unknown | LogOptions, arg3?: unknown | LogOptions, arg4?: LogOptions): TimeEndArgs;
|
|
69
|
+
declare function writeLine(method: LogConsoleMethod, line: unknown): void;
|
|
70
|
+
declare function mergeOptions(base: LogOptions | undefined, incoming: LogOptions | undefined): LogOptions | undefined;
|
|
71
|
+
declare function resolveTimingLevel(durationMs: number, options?: LogOptions): LogLevel;
|
|
23
72
|
declare function log(value: unknown, options?: LogOptions): void;
|
|
24
73
|
declare function log(label: string, value: unknown, options?: LogOptions): void;
|
|
74
|
+
declare function once(key: string, value: unknown, options?: LogOptions): void;
|
|
75
|
+
declare function once(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
76
|
+
declare function resetOnce(keys?: string[]): void;
|
|
77
|
+
declare function time(key: string, options?: LogOptions): void;
|
|
78
|
+
declare function timeEnd(key: string, options?: LogOptions): void;
|
|
79
|
+
declare function timeEnd(key: string, value: unknown, options?: LogOptions): void;
|
|
80
|
+
declare function timeEnd(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
81
|
+
declare function resetTimers(keys?: string[]): void;
|
|
82
|
+
declare function logDev(value: unknown, options?: LogOptions): void;
|
|
83
|
+
declare function logDev(label: string, value: unknown, options?: LogOptions): void;
|
|
84
|
+
declare function logProd(value: unknown, options?: LogOptions): void;
|
|
85
|
+
declare function logProd(label: string, value: unknown, options?: LogOptions): void;
|
|
86
|
+
type LoggerMethod = {
|
|
87
|
+
(value: unknown, options?: LogOptions): void;
|
|
88
|
+
(label: string, value: unknown, options?: LogOptions): void;
|
|
89
|
+
};
|
|
90
|
+
type OnceMethod = {
|
|
91
|
+
(key: string, value: unknown, options?: LogOptions): void;
|
|
92
|
+
(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
93
|
+
};
|
|
94
|
+
type TimeMethod = {
|
|
95
|
+
(key: string, options?: LogOptions): void;
|
|
96
|
+
};
|
|
97
|
+
type TimeEndMethod = {
|
|
98
|
+
(key: string, options?: LogOptions): void;
|
|
99
|
+
(key: string, value: unknown, options?: LogOptions): void;
|
|
100
|
+
(key: string, label: string, value: unknown, options?: LogOptions): void;
|
|
101
|
+
};
|
|
102
|
+
interface LoggerFn extends LoggerMethod {
|
|
103
|
+
info: LoggerMethod;
|
|
104
|
+
success: LoggerMethod;
|
|
105
|
+
warn: LoggerMethod;
|
|
106
|
+
error: LoggerMethod;
|
|
107
|
+
debug: LoggerMethod;
|
|
108
|
+
once: OnceMethod;
|
|
109
|
+
time: TimeMethod;
|
|
110
|
+
timeEnd: TimeEndMethod;
|
|
111
|
+
withContext: (context: LogContext) => LoggerFn;
|
|
112
|
+
resetOnce: (keys?: string[]) => void;
|
|
113
|
+
resetTimers: (keys?: string[]) => void;
|
|
114
|
+
}
|
|
115
|
+
declare function createLogger(presetOptions?: LogOptions): LoggerFn;
|
|
116
|
+
declare function withContext(context: LogContext, presetOptions?: LogOptions): LoggerFn;
|
|
117
|
+
declare const info: LoggerMethod;
|
|
118
|
+
declare const success: LoggerMethod;
|
|
119
|
+
declare const warn: LoggerMethod;
|
|
120
|
+
declare const error: LoggerMethod;
|
|
121
|
+
declare const debug: LoggerMethod;
|
|
25
122
|
declare const __internal: {
|
|
26
123
|
getCallerFromStack: typeof getCallerFromStack;
|
|
27
124
|
parseFrameLine: typeof parseFrameLine;
|
|
28
125
|
formatLabeledValue: typeof formatLabeledValue;
|
|
29
126
|
isLogOptions: typeof isLogOptions;
|
|
127
|
+
resolveLogArgs: typeof resolveLogArgs;
|
|
128
|
+
mergeOptions: typeof mergeOptions;
|
|
129
|
+
writeLine: typeof writeLine;
|
|
130
|
+
resolveOnceArgs: typeof resolveOnceArgs;
|
|
131
|
+
resolveTimeEndArgs: typeof resolveTimeEndArgs;
|
|
132
|
+
resolveTimingLevel: typeof resolveTimingLevel;
|
|
30
133
|
};
|
|
31
134
|
|
|
32
|
-
export { type FormatterInput, type FormatterOutput, type LogOptions, __internal, log };
|
|
135
|
+
export { type FormatterInput, type FormatterOutput, type LogConsoleMethod, type LogContext, type LogLevel, type LogMode, type LogOptions, type LoggerFn, type LoggerMethod, type OnceMethod, type TimeEndMethod, type TimeMethod, __internal, createLogger, debug, error, info, log, logDev, logProd, once, resetOnce, resetTimers, success, time, timeEnd, warn, withContext };
|