@little-nebulae/log 0.1.0 → 0.3.0
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/dist/index.d.ts +77 -148
- package/dist/index.js +73 -51
- package/package.json +19 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,213 +1,142 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
import { Tagged } from "type-fest";
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const LOG_LEVEL_ENUM: {
|
|
5
4
|
readonly INFO: "info";
|
|
6
5
|
readonly WARN: "warn";
|
|
7
6
|
readonly ERROR: "error";
|
|
8
7
|
readonly FATAL: "fatal";
|
|
9
8
|
};
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const DEFAULT_MINIMUM_LOG_LEVEL: {
|
|
9
|
+
export declare const DEFAULT_MINIMUM_LOG_LEVEL_ENUM: {
|
|
12
10
|
readonly DEVELOPMENT: "info";
|
|
13
11
|
readonly PRODUCTION: "warn";
|
|
14
12
|
};
|
|
15
|
-
export declare const
|
|
13
|
+
export declare const DEFAULT_LOG_DIR_NAME_ENUM: {
|
|
16
14
|
readonly ROOT: "logs";
|
|
17
15
|
readonly MAIN: "main-thread";
|
|
18
16
|
readonly WORKER: "worker-threads";
|
|
19
17
|
};
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/schemas/operation.d.ts
|
|
22
18
|
export type OperationId = Tagged<string, "OperationId">;
|
|
23
19
|
export declare const OperationIdSchema: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
24
|
-
export declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
export type OperationPerformance = z.infer<typeof OperationPerformanceSchema>;
|
|
30
|
-
export declare const OperationSchema: z.ZodObject<{
|
|
20
|
+
export declare function createOperationSchema<Name extends string, InputSchema extends z.ZodType, OutputSchema extends z.ZodType>({ name, inputSchema, outputSchema }: {
|
|
21
|
+
name: Name;
|
|
22
|
+
inputSchema: InputSchema;
|
|
23
|
+
outputSchema: OutputSchema;
|
|
24
|
+
}): z.ZodObject<{
|
|
31
25
|
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
32
|
-
name: z.
|
|
26
|
+
name: z.ZodLiteral<Name>;
|
|
33
27
|
source: z.ZodString;
|
|
34
28
|
success: z.ZodBoolean;
|
|
35
|
-
input:
|
|
36
|
-
output:
|
|
29
|
+
input: InputSchema;
|
|
30
|
+
output: OutputSchema;
|
|
37
31
|
performance: z.ZodObject<{
|
|
38
32
|
start: z.ZodInt;
|
|
39
33
|
end: z.ZodInt;
|
|
40
34
|
duration: z.ZodInt;
|
|
41
35
|
}, z.core.$strip>;
|
|
42
36
|
}, z.core.$strip>;
|
|
43
|
-
export type
|
|
44
|
-
export declare const
|
|
37
|
+
export type OperationSchemaType = ReturnType<typeof createOperationSchema>;
|
|
38
|
+
export declare const OperationPerformanceSchema: z.ZodObject<{
|
|
39
|
+
start: z.ZodInt;
|
|
40
|
+
end: z.ZodInt;
|
|
41
|
+
duration: z.ZodInt;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type OperationPerformance = z.infer<typeof OperationPerformanceSchema>;
|
|
44
|
+
export declare function createConcurrentOperationsSchema<Name extends string, InputSchema extends z.ZodType, OutputSchema extends z.ZodType, OperationsSchema extends z.ZodTuple<readonly [OperationSchemaType, ...OperationSchemaType[]]>>({ name, inputSchema, outputSchema, operationsSchema }: {
|
|
45
|
+
name: Name;
|
|
46
|
+
inputSchema: InputSchema;
|
|
47
|
+
outputSchema: OutputSchema;
|
|
48
|
+
operationsSchema: OperationsSchema;
|
|
49
|
+
}): z.ZodObject<{
|
|
45
50
|
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
46
|
-
name: z.
|
|
51
|
+
name: z.ZodLiteral<Name>;
|
|
47
52
|
source: z.ZodString;
|
|
48
53
|
success: z.ZodBoolean;
|
|
49
|
-
input:
|
|
50
|
-
output:
|
|
54
|
+
input: InputSchema;
|
|
55
|
+
output: OutputSchema;
|
|
51
56
|
performance: z.ZodObject<{
|
|
52
57
|
start: z.ZodInt;
|
|
53
58
|
end: z.ZodInt;
|
|
54
59
|
duration: z.ZodInt;
|
|
55
60
|
}, z.core.$strip>;
|
|
56
|
-
operations:
|
|
57
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
58
|
-
name: z.ZodString;
|
|
59
|
-
source: z.ZodString;
|
|
60
|
-
success: z.ZodBoolean;
|
|
61
|
-
input: z.ZodUnknown;
|
|
62
|
-
output: z.ZodUnknown;
|
|
63
|
-
performance: z.ZodObject<{
|
|
64
|
-
start: z.ZodInt;
|
|
65
|
-
end: z.ZodInt;
|
|
66
|
-
duration: z.ZodInt;
|
|
67
|
-
}, z.core.$strip>;
|
|
68
|
-
}, z.core.$strip>>;
|
|
61
|
+
operations: OperationsSchema;
|
|
69
62
|
}, z.core.$strip>;
|
|
70
|
-
export type
|
|
71
|
-
export
|
|
63
|
+
export type ConcurrentOperationsSchemaType = ReturnType<typeof createConcurrentOperationsSchema>;
|
|
64
|
+
export type SequentialOperationsTuple = z.ZodTuple<readonly [OperationSchemaType | ConcurrentOperationsSchemaType, ...(OperationSchemaType | ConcurrentOperationsSchemaType)[]]>;
|
|
65
|
+
export declare function createSequentialOperationsSchema<Name extends string, InputSchema extends z.ZodType, OutputSchema extends z.ZodType, OperationsSchema extends SequentialOperationsTuple>({ name, inputSchema, outputSchema, operationsSchema }: {
|
|
66
|
+
name: Name;
|
|
67
|
+
inputSchema: InputSchema;
|
|
68
|
+
outputSchema: OutputSchema;
|
|
69
|
+
operationsSchema: OperationsSchema;
|
|
70
|
+
}): z.ZodObject<{
|
|
72
71
|
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
73
|
-
name: z.
|
|
72
|
+
name: z.ZodLiteral<Name>;
|
|
74
73
|
source: z.ZodString;
|
|
75
74
|
success: z.ZodBoolean;
|
|
76
|
-
input:
|
|
77
|
-
output:
|
|
75
|
+
input: InputSchema;
|
|
76
|
+
output: OutputSchema;
|
|
78
77
|
performance: z.ZodObject<{
|
|
79
78
|
start: z.ZodInt;
|
|
80
79
|
end: z.ZodInt;
|
|
81
80
|
duration: z.ZodInt;
|
|
82
81
|
}, z.core.$strip>;
|
|
83
|
-
operations:
|
|
84
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
85
|
-
name: z.ZodString;
|
|
86
|
-
source: z.ZodString;
|
|
87
|
-
success: z.ZodBoolean;
|
|
88
|
-
input: z.ZodUnknown;
|
|
89
|
-
output: z.ZodUnknown;
|
|
90
|
-
performance: z.ZodObject<{
|
|
91
|
-
start: z.ZodInt;
|
|
92
|
-
end: z.ZodInt;
|
|
93
|
-
duration: z.ZodInt;
|
|
94
|
-
}, z.core.$strip>;
|
|
95
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
96
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
97
|
-
name: z.ZodString;
|
|
98
|
-
source: z.ZodString;
|
|
99
|
-
success: z.ZodBoolean;
|
|
100
|
-
input: z.ZodUnknown;
|
|
101
|
-
output: z.ZodUnknown;
|
|
102
|
-
performance: z.ZodObject<{
|
|
103
|
-
start: z.ZodInt;
|
|
104
|
-
end: z.ZodInt;
|
|
105
|
-
duration: z.ZodInt;
|
|
106
|
-
}, z.core.$strip>;
|
|
107
|
-
operations: z.ZodArray<z.ZodObject<{
|
|
108
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
109
|
-
name: z.ZodString;
|
|
110
|
-
source: z.ZodString;
|
|
111
|
-
success: z.ZodBoolean;
|
|
112
|
-
input: z.ZodUnknown;
|
|
113
|
-
output: z.ZodUnknown;
|
|
114
|
-
performance: z.ZodObject<{
|
|
115
|
-
start: z.ZodInt;
|
|
116
|
-
end: z.ZodInt;
|
|
117
|
-
duration: z.ZodInt;
|
|
118
|
-
}, z.core.$strip>;
|
|
119
|
-
}, z.core.$strip>>;
|
|
120
|
-
}, z.core.$strip>]>>;
|
|
82
|
+
operations: OperationsSchema;
|
|
121
83
|
}, z.core.$strip>;
|
|
122
|
-
export type SequentialOperations = z.infer<typeof SequentialOperationsSchema>;
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/schemas/log.d.ts
|
|
125
84
|
export type LogId = Tagged<OperationId, "LogId">;
|
|
126
85
|
export declare const LogIdSchema: z.ZodPipe<z.ZodUUID, z.ZodTransform<LogId, string>>;
|
|
127
|
-
export declare
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export declare const LogContextSchema: z.ZodObject<{
|
|
135
|
-
who: z.ZodString;
|
|
136
|
-
didWhat: z.ZodString;
|
|
137
|
-
inWhere: z.ZodExactOptional<z.ZodString>;
|
|
138
|
-
atWhen: z.ZodDate;
|
|
139
|
-
}, z.core.$strip>;
|
|
140
|
-
export type LogContext = z.infer<typeof LogContextSchema>;
|
|
141
|
-
export declare const LogSchema: z.ZodObject<{
|
|
142
|
-
name: z.ZodString;
|
|
86
|
+
export declare function createLogSchema<Name extends string, InputSchema extends z.ZodType, OutputSchema extends z.ZodType, OperationsSchema extends SequentialOperationsTuple>({ name, inputSchema, outputSchema, operationsSchema }: {
|
|
87
|
+
name: Name;
|
|
88
|
+
inputSchema: InputSchema;
|
|
89
|
+
outputSchema: OutputSchema;
|
|
90
|
+
operationsSchema: OperationsSchema;
|
|
91
|
+
}): z.ZodObject<{
|
|
92
|
+
name: z.ZodLiteral<Name>;
|
|
143
93
|
source: z.ZodString;
|
|
144
94
|
success: z.ZodBoolean;
|
|
145
|
-
input:
|
|
146
|
-
output:
|
|
95
|
+
input: InputSchema;
|
|
96
|
+
output: OutputSchema;
|
|
147
97
|
performance: z.ZodObject<{
|
|
148
98
|
start: z.ZodInt;
|
|
149
99
|
end: z.ZodInt;
|
|
150
100
|
duration: z.ZodInt;
|
|
151
101
|
}, z.core.$strip>;
|
|
152
|
-
operations:
|
|
153
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
154
|
-
name: z.ZodString;
|
|
155
|
-
source: z.ZodString;
|
|
156
|
-
success: z.ZodBoolean;
|
|
157
|
-
input: z.ZodUnknown;
|
|
158
|
-
output: z.ZodUnknown;
|
|
159
|
-
performance: z.ZodObject<{
|
|
160
|
-
start: z.ZodInt;
|
|
161
|
-
end: z.ZodInt;
|
|
162
|
-
duration: z.ZodInt;
|
|
163
|
-
}, z.core.$strip>;
|
|
164
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
165
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
166
|
-
name: z.ZodString;
|
|
167
|
-
source: z.ZodString;
|
|
168
|
-
success: z.ZodBoolean;
|
|
169
|
-
input: z.ZodUnknown;
|
|
170
|
-
output: z.ZodUnknown;
|
|
171
|
-
performance: z.ZodObject<{
|
|
172
|
-
start: z.ZodInt;
|
|
173
|
-
end: z.ZodInt;
|
|
174
|
-
duration: z.ZodInt;
|
|
175
|
-
}, z.core.$strip>;
|
|
176
|
-
operations: z.ZodArray<z.ZodObject<{
|
|
177
|
-
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<OperationId, string>>;
|
|
178
|
-
name: z.ZodString;
|
|
179
|
-
source: z.ZodString;
|
|
180
|
-
success: z.ZodBoolean;
|
|
181
|
-
input: z.ZodUnknown;
|
|
182
|
-
output: z.ZodUnknown;
|
|
183
|
-
performance: z.ZodObject<{
|
|
184
|
-
start: z.ZodInt;
|
|
185
|
-
end: z.ZodInt;
|
|
186
|
-
duration: z.ZodInt;
|
|
187
|
-
}, z.core.$strip>;
|
|
188
|
-
}, z.core.$strip>>;
|
|
189
|
-
}, z.core.$strip>]>>;
|
|
102
|
+
operations: OperationsSchema;
|
|
190
103
|
id: z.ZodPipe<z.ZodUUID, z.ZodTransform<LogId, string>>;
|
|
191
104
|
level: z.ZodEnum<{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
105
|
+
readonly INFO: "info";
|
|
106
|
+
readonly WARN: "warn";
|
|
107
|
+
readonly ERROR: "error";
|
|
108
|
+
readonly FATAL: "fatal";
|
|
196
109
|
}>;
|
|
197
110
|
context: z.ZodObject<{
|
|
198
111
|
who: z.ZodString;
|
|
199
112
|
didWhat: z.ZodString;
|
|
200
113
|
inWhere: z.ZodExactOptional<z.ZodString>;
|
|
201
|
-
atWhen: z.
|
|
114
|
+
atWhen: z.ZodInt;
|
|
202
115
|
}, z.core.$strip>;
|
|
203
|
-
message: z.ZodString;
|
|
204
116
|
}, z.core.$strip>;
|
|
205
|
-
export type Log = z.infer<typeof
|
|
206
|
-
|
|
207
|
-
|
|
117
|
+
export type Log<Name extends string = string, InputSchema extends z.ZodType = z.ZodType, OutputSchema extends z.ZodType = z.ZodType, OperationsSchema extends SequentialOperationsTuple = SequentialOperationsTuple> = z.infer<ReturnType<typeof createLogSchema<Name, InputSchema, OutputSchema, OperationsSchema>>>;
|
|
118
|
+
export declare const LogLevelSchema: z.ZodEnum<{
|
|
119
|
+
readonly INFO: "info";
|
|
120
|
+
readonly WARN: "warn";
|
|
121
|
+
readonly ERROR: "error";
|
|
122
|
+
readonly FATAL: "fatal";
|
|
123
|
+
}>;
|
|
124
|
+
export type LogLevel = z.infer<typeof LogLevelSchema>;
|
|
125
|
+
export declare const LogContextSchema: z.ZodObject<{
|
|
126
|
+
who: z.ZodString;
|
|
127
|
+
didWhat: z.ZodString;
|
|
128
|
+
inWhere: z.ZodExactOptional<z.ZodString>;
|
|
129
|
+
atWhen: z.ZodInt;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export type LogContext = z.infer<typeof LogContextSchema>;
|
|
132
|
+
export declare abstract class Logger {
|
|
133
|
+
abstract [LOG_LEVEL_ENUM.INFO]<TLog extends Log>(log: TLog, ...rest: unknown[]): void;
|
|
134
|
+
abstract [LOG_LEVEL_ENUM.WARN]<TLog extends Log>(log: TLog, ...rest: unknown[]): void;
|
|
135
|
+
abstract [LOG_LEVEL_ENUM.ERROR]<TLog extends Log>(log: TLog, ...rest: unknown[]): void;
|
|
136
|
+
abstract [LOG_LEVEL_ENUM.FATAL]<TLog extends Log>(log: TLog, ...rest: unknown[]): void;
|
|
137
|
+
}
|
|
208
138
|
interface ComposeLogMessageParams extends LogContext {
|
|
209
139
|
level: LogLevel;
|
|
210
140
|
}
|
|
211
141
|
export declare function composeLogMessage({ level, who, didWhat, inWhere, atWhen }: ComposeLogMessageParams): string;
|
|
212
|
-
//#endregion
|
|
213
142
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,73 +1,95 @@
|
|
|
1
|
-
import { NonEmptyStringSchema, PositiveIntegerSchema } from "@little-nebulae/zod";
|
|
1
|
+
import { NonEmptyStringSchema, PositiveIntegerSchema } from "@little-nebulae/zod-schemas";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
// src/constants.ts
|
|
4
|
+
const LOG_LEVEL_ENUM = {
|
|
5
5
|
INFO: "info",
|
|
6
6
|
WARN: "warn",
|
|
7
7
|
ERROR: "error",
|
|
8
8
|
FATAL: "fatal"
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
LOG_LEVEL.ERROR,
|
|
14
|
-
LOG_LEVEL.FATAL
|
|
15
|
-
];
|
|
16
|
-
const DEFAULT_MINIMUM_LOG_LEVEL = {
|
|
17
|
-
DEVELOPMENT: LOG_LEVEL.INFO,
|
|
18
|
-
PRODUCTION: LOG_LEVEL.WARN
|
|
10
|
+
const DEFAULT_MINIMUM_LOG_LEVEL_ENUM = {
|
|
11
|
+
DEVELOPMENT: LOG_LEVEL_ENUM.INFO,
|
|
12
|
+
PRODUCTION: LOG_LEVEL_ENUM.WARN
|
|
19
13
|
};
|
|
20
|
-
const
|
|
14
|
+
const DEFAULT_LOG_DIR_NAME_ENUM = {
|
|
21
15
|
ROOT: "logs",
|
|
22
16
|
MAIN: "main-thread",
|
|
23
17
|
WORKER: "worker-threads"
|
|
24
18
|
};
|
|
25
|
-
|
|
26
|
-
//#region src/utils.ts
|
|
27
|
-
function composeLogMessage({ level, who, didWhat, inWhere, atWhen }) {
|
|
28
|
-
return `[${level.toUpperCase()}] ${who} ${didWhat}${inWhere ? " " + inWhere : ""} ${atWhen.toISOString()}.`;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/schemas/operation.ts
|
|
19
|
+
// src/schemas/operation/id.ts
|
|
32
20
|
const OperationIdSchema = z.uuidv7().transform((id) => id);
|
|
21
|
+
// src/schemas/operation/performance.ts
|
|
33
22
|
const OperationPerformanceSchema = z.object({
|
|
34
23
|
start: PositiveIntegerSchema,
|
|
35
24
|
end: PositiveIntegerSchema,
|
|
36
25
|
duration: PositiveIntegerSchema
|
|
37
26
|
}).refine(({ start, end }) => end > start);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
27
|
+
// src/schemas/operation/index.ts
|
|
28
|
+
function createOperationSchema({ name, inputSchema, outputSchema }) {
|
|
29
|
+
return z.object({
|
|
30
|
+
id: OperationIdSchema,
|
|
31
|
+
name: z.literal(name),
|
|
32
|
+
source: NonEmptyStringSchema,
|
|
33
|
+
success: z.boolean(),
|
|
34
|
+
input: inputSchema,
|
|
35
|
+
output: outputSchema,
|
|
36
|
+
performance: OperationPerformanceSchema
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// src/schemas/operation/concurrent.ts
|
|
40
|
+
function createConcurrentOperationsSchema({ name, inputSchema, outputSchema, operationsSchema }) {
|
|
41
|
+
const SingleOperationSchema = createOperationSchema({
|
|
42
|
+
name,
|
|
43
|
+
inputSchema,
|
|
44
|
+
outputSchema
|
|
45
|
+
});
|
|
46
|
+
return z.object({
|
|
47
|
+
...SingleOperationSchema.shape,
|
|
48
|
+
operations: operationsSchema
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// src/schemas/operation/sequential.ts
|
|
52
|
+
function createSequentialOperationsSchema({ name, inputSchema, outputSchema, operationsSchema }) {
|
|
53
|
+
const SingleOperationSchema = createOperationSchema({
|
|
54
|
+
name,
|
|
55
|
+
inputSchema,
|
|
56
|
+
outputSchema
|
|
57
|
+
});
|
|
58
|
+
return z.object({
|
|
59
|
+
...SingleOperationSchema.shape,
|
|
60
|
+
operations: operationsSchema
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// src/schemas/log/context.ts
|
|
59
64
|
const LogContextSchema = z.object({
|
|
60
65
|
who: NonEmptyStringSchema,
|
|
61
66
|
didWhat: NonEmptyStringSchema,
|
|
62
67
|
inWhere: NonEmptyStringSchema.exactOptional(),
|
|
63
|
-
atWhen:
|
|
68
|
+
atWhen: PositiveIntegerSchema
|
|
64
69
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
// src/schemas/log/id.ts
|
|
71
|
+
const LogIdSchema = z.uuidv7().transform((id) => id);
|
|
72
|
+
// src/schemas/log/level.ts
|
|
73
|
+
const LogLevelSchema = z.enum(LOG_LEVEL_ENUM);
|
|
74
|
+
// src/schemas/log/index.ts
|
|
75
|
+
function createLogSchema({ name, inputSchema, outputSchema, operationsSchema }) {
|
|
76
|
+
const SequentialOperationsSchema = createSequentialOperationsSchema({
|
|
77
|
+
name,
|
|
78
|
+
inputSchema,
|
|
79
|
+
outputSchema,
|
|
80
|
+
operationsSchema
|
|
81
|
+
});
|
|
82
|
+
return z.object({
|
|
83
|
+
...SequentialOperationsSchema.shape,
|
|
84
|
+
id: LogIdSchema,
|
|
85
|
+
level: LogLevelSchema,
|
|
86
|
+
context: LogContextSchema
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// src/logger.ts
|
|
90
|
+
var Logger = class {};
|
|
91
|
+
// src/utils.ts
|
|
92
|
+
function composeLogMessage({ level, who, didWhat, inWhere, atWhen }) {
|
|
93
|
+
return `[${level.toUpperCase()}] ${who} ${didWhat}${inWhere ? " " + inWhere : ""} ${new Date(atWhen).toISOString()}.`;
|
|
94
|
+
}
|
|
95
|
+
export { DEFAULT_LOG_DIR_NAME_ENUM, DEFAULT_MINIMUM_LOG_LEVEL_ENUM, LOG_LEVEL_ENUM, LogContextSchema, LogIdSchema, LogLevelSchema, Logger, OperationIdSchema, OperationPerformanceSchema, composeLogMessage, createConcurrentOperationsSchema, createLogSchema, createOperationSchema, createSequentialOperationsSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@little-nebulae/log",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -17,32 +17,33 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@arethetypeswrong/core": "0.18.5",
|
|
20
|
-
"@little-nebulae/
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"oxlint": "1.88.0",
|
|
27
|
-
"oxlint-tsgolint": "7.0.2004",
|
|
20
|
+
"@little-nebulae/zod-schemas": "0.3.0",
|
|
21
|
+
"@oxc-node/cli": "1.0.3",
|
|
22
|
+
"@types/node": "26.6.11",
|
|
23
|
+
"oxfmt": "0.80.0",
|
|
24
|
+
"oxlint": "1.95.0",
|
|
25
|
+
"oxlint-tsgolint": "7.0.2009",
|
|
28
26
|
"publint": "0.3.25",
|
|
29
|
-
"tsdown": "0.23.
|
|
30
|
-
"type-fest": "
|
|
31
|
-
"typescript": "7.0
|
|
32
|
-
"vitest": "5.
|
|
27
|
+
"tsdown": "0.23.7",
|
|
28
|
+
"type-fest": "6.0.3",
|
|
29
|
+
"typescript": "7.1.0-beta",
|
|
30
|
+
"vitest": "5.1.2",
|
|
33
31
|
"zod": "4.6.7"
|
|
34
32
|
},
|
|
35
33
|
"peerDependencies": {
|
|
36
|
-
"@little-nebulae/
|
|
37
|
-
"
|
|
38
|
-
"@little-nebulae/zod": "0",
|
|
39
|
-
"type-fest": "^5.0.0",
|
|
34
|
+
"@little-nebulae/zod-schemas": "0",
|
|
35
|
+
"type-fest": "^6.0.0",
|
|
40
36
|
"zod": "^4.0.0"
|
|
41
37
|
},
|
|
42
38
|
"devEngines": {
|
|
43
39
|
"packageManager": {
|
|
44
40
|
"name": "pnpm",
|
|
45
|
-
"version": "12.
|
|
41
|
+
"version": "12.23.0",
|
|
42
|
+
"onFail": "warn"
|
|
43
|
+
},
|
|
44
|
+
"runtime": {
|
|
45
|
+
"name": "node",
|
|
46
|
+
"version": "26.14.0",
|
|
46
47
|
"onFail": "warn"
|
|
47
48
|
}
|
|
48
49
|
},
|