@noego/logger 0.0.2 → 0.0.4
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/core/abstract_logger.cjs +6 -2
- package/dist/core/abstract_logger.cjs.map +1 -1
- package/dist/core/abstract_logger.d.cts +3 -1
- package/dist/core/abstract_logger.d.ts +3 -1
- package/dist/core/abstract_logger.js +7 -3
- package/dist/core/abstract_logger.js.map +1 -1
- package/dist/core/log_level.cjs +55 -37
- package/dist/core/log_level.cjs.map +1 -1
- package/dist/core/log_level.d.cts +17 -9
- package/dist/core/log_level.d.ts +17 -9
- package/dist/core/log_level.js +52 -36
- package/dist/core/log_level.js.map +1 -1
- package/dist/core/logging_manager.cjs +8 -4
- package/dist/core/logging_manager.cjs.map +1 -1
- package/dist/core/logging_manager.d.cts +9 -8
- package/dist/core/logging_manager.d.ts +9 -8
- package/dist/core/logging_manager.js +9 -5
- package/dist/core/logging_manager.js.map +1 -1
- package/dist/get_logger.d.cts +1 -1
- package/dist/get_logger.d.ts +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/transports/console.cjs.map +1 -1
- package/dist/transports/console.d.cts +1 -1
- package/dist/transports/console.d.ts +1 -1
- package/dist/transports/console.js.map +1 -1
- package/dist/transports/console_transport.cjs +196 -13
- package/dist/transports/console_transport.cjs.map +1 -1
- package/dist/transports/console_transport.d.cts +11 -1
- package/dist/transports/console_transport.d.ts +11 -1
- package/dist/transports/console_transport.js +196 -13
- package/dist/transports/console_transport.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,20 +1,203 @@
|
|
|
1
|
+
const MAX_LINE_LENGTH = 16 * 1024;
|
|
2
|
+
const MAX_STRING_LENGTH = 4 * 1024;
|
|
3
|
+
const MAX_DEPTH = 6;
|
|
4
|
+
const MAX_COLLECTION_ENTRIES = 50;
|
|
5
|
+
const MAX_NORMALIZED_VALUES = 200;
|
|
6
|
+
const TRUNCATION_SUFFIX = "...[truncated]";
|
|
7
|
+
const defaultStdoutWriter = (line) => console.log(line);
|
|
8
|
+
const defaultStderrWriter = (line) => console.error(line);
|
|
1
9
|
class ConsoleTransport {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.stdoutWriter = options.stdout ?? defaultStdoutWriter;
|
|
12
|
+
this.stderrWriter = options.stderr ?? defaultStderrWriter;
|
|
13
|
+
}
|
|
2
14
|
log(entry) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
let level = "UNKNOWN";
|
|
16
|
+
let formatted = "[unknown-time] [unknown-logger] [UNKNOWN] [formatting failed]";
|
|
17
|
+
try {
|
|
18
|
+
level = this.readLevel(entry);
|
|
19
|
+
formatted = this.formatEntry(entry, level);
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
const writer = level === "ERROR" || level === "FATAL" ? this.stderrWriter : this.stdoutWriter;
|
|
23
|
+
try {
|
|
24
|
+
writer(formatted);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
formatEntry(entry, level) {
|
|
29
|
+
const timestamp = toBoundedText(readProperty(entry, "timestamp"), "unknown-time", 128);
|
|
30
|
+
const logger = toBoundedText(readProperty(entry, "logger"), "unknown-logger", 256);
|
|
31
|
+
const message = toBoundedText(readProperty(entry, "message"), "[unavailable message]", MAX_STRING_LENGTH);
|
|
32
|
+
const context = readProperty(entry, "context");
|
|
33
|
+
const contextSuffix = context === void 0 ? "" : ` ${serializeContext(context)}`;
|
|
34
|
+
return truncate(`[${timestamp}] [${logger}] [${level}] ${message}${contextSuffix}`, MAX_LINE_LENGTH);
|
|
35
|
+
}
|
|
36
|
+
readLevel(entry) {
|
|
37
|
+
return toBoundedText(readProperty(entry, "level"), "UNKNOWN", 32).toUpperCase();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function readProperty(value, key) {
|
|
41
|
+
try {
|
|
42
|
+
return Reflect.get(value, key);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return `[Property access failed: ${describeFailure(error)}]`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function serializeContext(context) {
|
|
48
|
+
try {
|
|
49
|
+
const normalized = normalizeValue(context, {
|
|
50
|
+
active: /* @__PURE__ */ new WeakSet(),
|
|
51
|
+
remainingValues: MAX_NORMALIZED_VALUES
|
|
52
|
+
}, 0);
|
|
53
|
+
return truncate(JSON.stringify(normalized), MAX_LINE_LENGTH);
|
|
54
|
+
} catch {
|
|
55
|
+
return '"[Context serialization failed]"';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function normalizeValue(value, state, depth) {
|
|
59
|
+
if (state.remainingValues <= 0) {
|
|
60
|
+
return "[Value limit reached]";
|
|
61
|
+
}
|
|
62
|
+
state.remainingValues -= 1;
|
|
63
|
+
switch (typeof value) {
|
|
64
|
+
case "undefined":
|
|
65
|
+
return "[undefined]";
|
|
66
|
+
case "string":
|
|
67
|
+
return truncate(value, MAX_STRING_LENGTH);
|
|
68
|
+
case "boolean":
|
|
69
|
+
return value;
|
|
70
|
+
case "number":
|
|
71
|
+
return Number.isFinite(value) ? value : String(value);
|
|
72
|
+
case "bigint":
|
|
73
|
+
return `${value.toString()}n`;
|
|
74
|
+
case "symbol":
|
|
75
|
+
return toBoundedText(value, "[Symbol]", MAX_STRING_LENGTH);
|
|
76
|
+
case "function":
|
|
77
|
+
return describeFunction(value);
|
|
78
|
+
case "object":
|
|
79
|
+
return normalizeObjectValue(value, state, depth);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function normalizeObjectValue(value, state, depth) {
|
|
83
|
+
if (value === null) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (depth >= MAX_DEPTH) {
|
|
87
|
+
return `[Depth limit ${MAX_DEPTH} reached]`;
|
|
88
|
+
}
|
|
89
|
+
if (state.active.has(value)) {
|
|
90
|
+
return "[Circular]";
|
|
91
|
+
}
|
|
92
|
+
state.active.add(value);
|
|
93
|
+
try {
|
|
94
|
+
if (isError(value)) {
|
|
95
|
+
return normalizeError(value, state, depth + 1);
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(value)) {
|
|
98
|
+
return normalizeArray(value, state, depth + 1);
|
|
99
|
+
}
|
|
100
|
+
return normalizeRecord(value, state, depth + 1);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return `[Object serialization failed: ${describeFailure(error)}]`;
|
|
103
|
+
} finally {
|
|
104
|
+
state.active.delete(value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function normalizeError(error, state, depth) {
|
|
108
|
+
const normalized = createNormalizedRecord();
|
|
109
|
+
normalized.name = normalizeValue(readProperty(error, "name"), state, depth);
|
|
110
|
+
normalized.message = normalizeValue(readProperty(error, "message"), state, depth);
|
|
111
|
+
const stack = readProperty(error, "stack");
|
|
112
|
+
if (stack !== void 0) {
|
|
113
|
+
normalized.stack = normalizeValue(stack, state, depth);
|
|
114
|
+
}
|
|
115
|
+
const cause = readProperty(error, "cause");
|
|
116
|
+
if (cause !== void 0) {
|
|
117
|
+
normalized.cause = normalizeValue(cause, state, depth);
|
|
118
|
+
}
|
|
119
|
+
appendEnumerableProperties(error, normalized, state, depth, /* @__PURE__ */ new Set(["name", "message", "stack", "cause"]));
|
|
120
|
+
return normalized;
|
|
121
|
+
}
|
|
122
|
+
function normalizeArray(value, state, depth) {
|
|
123
|
+
const length = value.length;
|
|
124
|
+
const normalized = [];
|
|
125
|
+
const includedLength = Math.min(length, MAX_COLLECTION_ENTRIES);
|
|
126
|
+
for (let index = 0; index < includedLength; index += 1) {
|
|
127
|
+
normalized.push(normalizeOwnProperty(value, String(index), state, depth, "[Empty]"));
|
|
128
|
+
}
|
|
129
|
+
if (length > includedLength) {
|
|
130
|
+
normalized.push(`[${length - includedLength} more items]`);
|
|
131
|
+
}
|
|
132
|
+
return normalized;
|
|
133
|
+
}
|
|
134
|
+
function normalizeRecord(value, state, depth) {
|
|
135
|
+
const normalized = createNormalizedRecord();
|
|
136
|
+
appendEnumerableProperties(value, normalized, state, depth);
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
function appendEnumerableProperties(value, target, state, depth, excludedKeys = /* @__PURE__ */ new Set()) {
|
|
140
|
+
const keys = Object.keys(value).filter((key) => !excludedKeys.has(key));
|
|
141
|
+
const includedKeys = keys.slice(0, MAX_COLLECTION_ENTRIES);
|
|
142
|
+
for (const key of includedKeys) {
|
|
143
|
+
target[key] = normalizeOwnProperty(value, key, state, depth, "[Unavailable]");
|
|
144
|
+
}
|
|
145
|
+
if (keys.length > includedKeys.length) {
|
|
146
|
+
target["[Truncated properties]"] = `${keys.length - includedKeys.length} more properties`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function normalizeOwnProperty(value, key, state, depth, unavailableValue) {
|
|
150
|
+
try {
|
|
151
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
152
|
+
if (!descriptor) {
|
|
153
|
+
return unavailableValue;
|
|
16
154
|
}
|
|
155
|
+
if ("value" in descriptor) {
|
|
156
|
+
return normalizeValue(descriptor.value, state, depth);
|
|
157
|
+
}
|
|
158
|
+
return descriptor.get ? "[Getter]" : "[Setter]";
|
|
159
|
+
} catch (error) {
|
|
160
|
+
return `[Property serialization failed: ${describeFailure(error)}]`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function createNormalizedRecord() {
|
|
164
|
+
return /* @__PURE__ */ Object.create(null);
|
|
165
|
+
}
|
|
166
|
+
function describeFunction(value) {
|
|
167
|
+
try {
|
|
168
|
+
return truncate(value.name ? `[Function ${value.name}]` : "[Function]", MAX_STRING_LENGTH);
|
|
169
|
+
} catch {
|
|
170
|
+
return "[Function]";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function isError(value) {
|
|
174
|
+
try {
|
|
175
|
+
return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
|
|
176
|
+
} catch {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function describeFailure(error) {
|
|
181
|
+
if (error instanceof Error) {
|
|
182
|
+
return toBoundedText(error.message, error.name || "Error", 256);
|
|
183
|
+
}
|
|
184
|
+
return toBoundedText(error, "unknown failure", 256);
|
|
185
|
+
}
|
|
186
|
+
function toBoundedText(value, fallback, maxLength) {
|
|
187
|
+
try {
|
|
188
|
+
return truncate(typeof value === "string" ? value : String(value), maxLength);
|
|
189
|
+
} catch {
|
|
190
|
+
return fallback;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function truncate(value, maxLength) {
|
|
194
|
+
if (value.length <= maxLength) {
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
if (maxLength <= TRUNCATION_SUFFIX.length) {
|
|
198
|
+
return TRUNCATION_SUFFIX.slice(0, maxLength);
|
|
17
199
|
}
|
|
200
|
+
return `${value.slice(0, maxLength - TRUNCATION_SUFFIX.length)}${TRUNCATION_SUFFIX}`;
|
|
18
201
|
}
|
|
19
202
|
var console_transport_default = ConsoleTransport;
|
|
20
203
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transports/console_transport.ts"],"sourcesContent":["import type { LogEntry, LogTransport } from \"../core/log_transport.js\";\n\nexport class ConsoleTransport implements LogTransport {\n log(entry: LogEntry): void {\n const contextStr = entry.context !== undefined ? ` ${JSON.stringify(entry.context)}` : \"\";\n const formatted = `[${entry.timestamp}] [${entry.logger}] [${entry.level}] ${entry.message}${contextStr}`;\n\n switch (entry.level) {\n case \"ERROR\":\n case \"FATAL\":\n console.error(formatted);\n break;\n case \"WARN\":\n console.warn(formatted);\n break;\n default:\n console.log(formatted);\n break;\n }\n }\n}\n\nexport default ConsoleTransport;\n"],"mappings":"AAEO,MAAM,iBAAyC;AAAA,EACpD,IAAI,OAAuB;AACzB,UAAM,aAAa,MAAM,YAAY,SAAY,IAAI,KAAK,UAAU,MAAM,OAAO,CAAC,KAAK;AACvF,UAAM,YAAY,IAAI,MAAM,SAAS,MAAM,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK,MAAM,OAAO,GAAG,UAAU;AAEvG,YAAQ,MAAM,OAAO;AAAA,MACnB,KAAK;AAAA,MACL,KAAK;AACH,gBAAQ,MAAM,SAAS;AACvB;AAAA,MACF,KAAK;AACH,gBAAQ,KAAK,SAAS;AACtB;AAAA,MACF;AACE,gBAAQ,IAAI,SAAS;AACrB;AAAA,IACJ;AAAA,EACF;AACF;AAEA,IAAO,4BAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/transports/console_transport.ts"],"sourcesContent":["import type { LogEntry, LogTransport } from \"../core/log_transport.js\";\n\nconst MAX_LINE_LENGTH = 16 * 1024;\nconst MAX_STRING_LENGTH = 4 * 1024;\nconst MAX_DEPTH = 6;\nconst MAX_COLLECTION_ENTRIES = 50;\nconst MAX_NORMALIZED_VALUES = 200;\nconst TRUNCATION_SUFFIX = \"...[truncated]\";\n\nexport type ConsoleWriter = (line: string) => void;\n\nexport interface ConsoleTransportOptions {\n stdout?: ConsoleWriter;\n stderr?: ConsoleWriter;\n}\n\ntype NormalizedValue =\n | null\n | boolean\n | number\n | string\n | NormalizedValue[]\n | { [key: string]: NormalizedValue };\n\ninterface NormalizationState {\n readonly active: WeakSet<object>;\n remainingValues: number;\n}\n\nconst defaultStdoutWriter: ConsoleWriter = (line) => console.log(line);\nconst defaultStderrWriter: ConsoleWriter = (line) => console.error(line);\n\nexport class ConsoleTransport implements LogTransport {\n private readonly stdoutWriter: ConsoleWriter;\n private readonly stderrWriter: ConsoleWriter;\n\n constructor(options: ConsoleTransportOptions = {}) {\n this.stdoutWriter = options.stdout ?? defaultStdoutWriter;\n this.stderrWriter = options.stderr ?? defaultStderrWriter;\n }\n\n log(entry: LogEntry): void {\n let level = \"UNKNOWN\";\n let formatted = \"[unknown-time] [unknown-logger] [UNKNOWN] [formatting failed]\";\n\n try {\n level = this.readLevel(entry);\n formatted = this.formatEntry(entry, level);\n } catch {\n // Logging must never make the caller fail.\n }\n\n const writer = level === \"ERROR\" || level === \"FATAL\"\n ? this.stderrWriter\n : this.stdoutWriter;\n\n try {\n writer(formatted);\n } catch {\n // Console and injected writer failures are intentionally isolated.\n }\n }\n\n private formatEntry(entry: LogEntry, level: string): string {\n const timestamp = toBoundedText(readProperty(entry, \"timestamp\"), \"unknown-time\", 128);\n const logger = toBoundedText(readProperty(entry, \"logger\"), \"unknown-logger\", 256);\n const message = toBoundedText(readProperty(entry, \"message\"), \"[unavailable message]\", MAX_STRING_LENGTH);\n const context = readProperty(entry, \"context\");\n const contextSuffix = context === undefined ? \"\" : ` ${serializeContext(context)}`;\n\n return truncate(`[${timestamp}] [${logger}] [${level}] ${message}${contextSuffix}`, MAX_LINE_LENGTH);\n }\n\n private readLevel(entry: LogEntry): string {\n return toBoundedText(readProperty(entry, \"level\"), \"UNKNOWN\", 32).toUpperCase();\n }\n}\n\nfunction readProperty(value: object, key: PropertyKey): unknown {\n try {\n return Reflect.get(value, key);\n } catch (error) {\n return `[Property access failed: ${describeFailure(error)}]`;\n }\n}\n\nfunction serializeContext(context: unknown): string {\n try {\n const normalized = normalizeValue(context, {\n active: new WeakSet<object>(),\n remainingValues: MAX_NORMALIZED_VALUES,\n }, 0);\n\n return truncate(JSON.stringify(normalized), MAX_LINE_LENGTH);\n } catch {\n return '\"[Context serialization failed]\"';\n }\n}\n\nfunction normalizeValue(\n value: unknown,\n state: NormalizationState,\n depth: number,\n): NormalizedValue {\n if (state.remainingValues <= 0) {\n return \"[Value limit reached]\";\n }\n state.remainingValues -= 1;\n\n switch (typeof value) {\n case \"undefined\":\n return \"[undefined]\";\n case \"string\":\n return truncate(value, MAX_STRING_LENGTH);\n case \"boolean\":\n return value;\n case \"number\":\n return Number.isFinite(value) ? value : String(value);\n case \"bigint\":\n return `${value.toString()}n`;\n case \"symbol\":\n return toBoundedText(value, \"[Symbol]\", MAX_STRING_LENGTH);\n case \"function\":\n return describeFunction(value);\n case \"object\":\n return normalizeObjectValue(value, state, depth);\n }\n}\n\nfunction normalizeObjectValue(\n value: object | null,\n state: NormalizationState,\n depth: number,\n): NormalizedValue {\n if (value === null) {\n return null;\n }\n if (depth >= MAX_DEPTH) {\n return `[Depth limit ${MAX_DEPTH} reached]`;\n }\n if (state.active.has(value)) {\n return \"[Circular]\";\n }\n\n state.active.add(value);\n try {\n if (isError(value)) {\n return normalizeError(value, state, depth + 1);\n }\n if (Array.isArray(value)) {\n return normalizeArray(value, state, depth + 1);\n }\n return normalizeRecord(value, state, depth + 1);\n } catch (error) {\n return `[Object serialization failed: ${describeFailure(error)}]`;\n } finally {\n state.active.delete(value);\n }\n}\n\nfunction normalizeError(\n error: object,\n state: NormalizationState,\n depth: number,\n): { [key: string]: NormalizedValue } {\n const normalized = createNormalizedRecord();\n normalized.name = normalizeValue(readProperty(error, \"name\"), state, depth);\n normalized.message = normalizeValue(readProperty(error, \"message\"), state, depth);\n\n const stack = readProperty(error, \"stack\");\n if (stack !== undefined) {\n normalized.stack = normalizeValue(stack, state, depth);\n }\n\n const cause = readProperty(error, \"cause\");\n if (cause !== undefined) {\n normalized.cause = normalizeValue(cause, state, depth);\n }\n\n appendEnumerableProperties(error, normalized, state, depth, new Set([\"name\", \"message\", \"stack\", \"cause\"]));\n return normalized;\n}\n\nfunction normalizeArray(\n value: unknown[],\n state: NormalizationState,\n depth: number,\n): NormalizedValue[] {\n const length = value.length;\n const normalized: NormalizedValue[] = [];\n const includedLength = Math.min(length, MAX_COLLECTION_ENTRIES);\n\n for (let index = 0; index < includedLength; index += 1) {\n normalized.push(normalizeOwnProperty(value, String(index), state, depth, \"[Empty]\"));\n }\n if (length > includedLength) {\n normalized.push(`[${length - includedLength} more items]`);\n }\n\n return normalized;\n}\n\nfunction normalizeRecord(\n value: object,\n state: NormalizationState,\n depth: number,\n): { [key: string]: NormalizedValue } {\n const normalized = createNormalizedRecord();\n appendEnumerableProperties(value, normalized, state, depth);\n return normalized;\n}\n\nfunction appendEnumerableProperties(\n value: object,\n target: { [key: string]: NormalizedValue },\n state: NormalizationState,\n depth: number,\n excludedKeys: ReadonlySet<string> = new Set(),\n): void {\n const keys = Object.keys(value).filter((key) => !excludedKeys.has(key));\n const includedKeys = keys.slice(0, MAX_COLLECTION_ENTRIES);\n\n for (const key of includedKeys) {\n target[key] = normalizeOwnProperty(value, key, state, depth, \"[Unavailable]\");\n }\n if (keys.length > includedKeys.length) {\n target[\"[Truncated properties]\"] = `${keys.length - includedKeys.length} more properties`;\n }\n}\n\nfunction normalizeOwnProperty(\n value: object,\n key: string,\n state: NormalizationState,\n depth: number,\n unavailableValue: string,\n): NormalizedValue {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor) {\n return unavailableValue;\n }\n if (\"value\" in descriptor) {\n return normalizeValue(descriptor.value, state, depth);\n }\n return descriptor.get ? \"[Getter]\" : \"[Setter]\";\n } catch (error) {\n return `[Property serialization failed: ${describeFailure(error)}]`;\n }\n}\n\nfunction createNormalizedRecord(): { [key: string]: NormalizedValue } {\n return Object.create(null) as { [key: string]: NormalizedValue };\n}\n\nfunction describeFunction(value: Function): string {\n try {\n return truncate(value.name ? `[Function ${value.name}]` : \"[Function]\", MAX_STRING_LENGTH);\n } catch {\n return \"[Function]\";\n }\n}\n\nfunction isError(value: object): boolean {\n try {\n return value instanceof Error || Object.prototype.toString.call(value) === \"[object Error]\";\n } catch {\n return false;\n }\n}\n\nfunction describeFailure(error: unknown): string {\n if (error instanceof Error) {\n return toBoundedText(error.message, error.name || \"Error\", 256);\n }\n return toBoundedText(error, \"unknown failure\", 256);\n}\n\nfunction toBoundedText(value: unknown, fallback: string, maxLength: number): string {\n try {\n return truncate(typeof value === \"string\" ? value : String(value), maxLength);\n } catch {\n return fallback;\n }\n}\n\nfunction truncate(value: string, maxLength: number): string {\n if (value.length <= maxLength) {\n return value;\n }\n if (maxLength <= TRUNCATION_SUFFIX.length) {\n return TRUNCATION_SUFFIX.slice(0, maxLength);\n }\n return `${value.slice(0, maxLength - TRUNCATION_SUFFIX.length)}${TRUNCATION_SUFFIX}`;\n}\n\nexport default ConsoleTransport;\n"],"mappings":"AAEA,MAAM,kBAAkB,KAAK;AAC7B,MAAM,oBAAoB,IAAI;AAC9B,MAAM,YAAY;AAClB,MAAM,yBAAyB;AAC/B,MAAM,wBAAwB;AAC9B,MAAM,oBAAoB;AAsB1B,MAAM,sBAAqC,CAAC,SAAS,QAAQ,IAAI,IAAI;AACrE,MAAM,sBAAqC,CAAC,SAAS,QAAQ,MAAM,IAAI;AAEhE,MAAM,iBAAyC;AAAA,EAIpD,YAAY,UAAmC,CAAC,GAAG;AACjD,SAAK,eAAe,QAAQ,UAAU;AACtC,SAAK,eAAe,QAAQ,UAAU;AAAA,EACxC;AAAA,EAEA,IAAI,OAAuB;AACzB,QAAI,QAAQ;AACZ,QAAI,YAAY;AAEhB,QAAI;AACF,cAAQ,KAAK,UAAU,KAAK;AAC5B,kBAAY,KAAK,YAAY,OAAO,KAAK;AAAA,IAC3C,QAAQ;AAAA,IAER;AAEA,UAAM,SAAS,UAAU,WAAW,UAAU,UAC1C,KAAK,eACL,KAAK;AAET,QAAI;AACF,aAAO,SAAS;AAAA,IAClB,QAAQ;AAAA,IAER;AAAA,EACF;AAAA,EAEQ,YAAY,OAAiB,OAAuB;AAC1D,UAAM,YAAY,cAAc,aAAa,OAAO,WAAW,GAAG,gBAAgB,GAAG;AACrF,UAAM,SAAS,cAAc,aAAa,OAAO,QAAQ,GAAG,kBAAkB,GAAG;AACjF,UAAM,UAAU,cAAc,aAAa,OAAO,SAAS,GAAG,yBAAyB,iBAAiB;AACxG,UAAM,UAAU,aAAa,OAAO,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F,WAAO,SAAS,MAAM,OAAO,aAAa,MAAM,IAAI,MAAM,cAAc,iBAAiB;AAAA,EAC3F,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,QAAQ,OAAwB;AACvC,MAAI;AACF,WAAO,iBAAiB,SAAS,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AAAA,EAC7E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,gBAAgB,OAAwB;AAC/C,MAAI,iBAAiB,OAAO;AAC1B,WAAO,cAAc,MAAM,SAAS,MAAM,QAAQ,SAAS,GAAG;AAAA,EAChE;AACA,SAAO,cAAc,OAAO,mBAAmB,GAAG;AACpD;AAEA,SAAS,cAAc,OAAgB,UAAkB,WAA2B;AAClF,MAAI;AACF,WAAO,SAAS,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK,GAAG,SAAS;AAAA,EAC9E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,SAAS,OAAe,WAA2B;AAC1D,MAAI,MAAM,UAAU,WAAW;AAC7B,WAAO;AAAA,EACT;AACA,MAAI,aAAa,kBAAkB,QAAQ;AACzC,WAAO,kBAAkB,MAAM,GAAG,SAAS;AAAA,EAC7C;AACA,SAAO,GAAG,MAAM,MAAM,GAAG,YAAY,kBAAkB,MAAM,CAAC,GAAG,iBAAiB;AACpF;AAEA,IAAO,4BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noego/logger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A flexible logging library for Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@noego/ioc": "^0.
|
|
54
|
+
"@noego/ioc": "^0.3.1",
|
|
55
55
|
"@types/node": "^20.10.4",
|
|
56
56
|
"@vitest/ui": "^4.0.18",
|
|
57
57
|
"tsup": "^8.5.0",
|