@bazariodev/docket 0.0.0-stage → 0.0.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/CHANGELOG.md +1 -0
- package/LICENSE +21 -0
- package/README.md +443 -2
- package/dist/browser/constants.d.cts +14 -0
- package/dist/browser/constants.d.ts +14 -0
- package/dist/browser/index.cjs +192 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +29 -0
- package/dist/browser/index.d.ts +29 -0
- package/dist/browser/index.js +187 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/chunk-7ld72rnl.js +376 -0
- package/dist/chunk-7ld72rnl.js.map +1 -0
- package/dist/chunk-B-SP8Od_.js +437 -0
- package/dist/chunk-B-SP8Od_.js.map +1 -0
- package/dist/chunk-BLf-eCDO.cjs +53 -0
- package/dist/chunk-BLf-eCDO.cjs.map +1 -0
- package/dist/chunk-Bvq4tF_F.cjs +440 -0
- package/dist/chunk-Bvq4tF_F.cjs.map +1 -0
- package/dist/chunk-CEhpwtwJ.cjs +379 -0
- package/dist/chunk-CEhpwtwJ.cjs.map +1 -0
- package/dist/chunk-CSS3f4_M.js +46 -0
- package/dist/chunk-CSS3f4_M.js.map +1 -0
- package/dist/chunk-CXZYNALm.cjs +124 -0
- package/dist/chunk-CXZYNALm.cjs.map +1 -0
- package/dist/chunk-DYcNnkOV.js +50 -0
- package/dist/chunk-DYcNnkOV.js.map +1 -0
- package/dist/chunk-DqK_3eFr.cjs +53 -0
- package/dist/chunk-DqK_3eFr.cjs.map +1 -0
- package/dist/chunk-LRCHwVuE.js +110 -0
- package/dist/chunk-LRCHwVuE.js.map +1 -0
- package/dist/constants.d.cts +6 -0
- package/dist/constants.d.ts +6 -0
- package/dist/core/constants.d.cts +43 -0
- package/dist/core/constants.d.ts +43 -0
- package/dist/core/errors.d.cts +8 -0
- package/dist/core/errors.d.ts +8 -0
- package/dist/devtools/index.cjs +37 -0
- package/dist/devtools/index.cjs.map +1 -0
- package/dist/devtools/index.d.cts +11 -0
- package/dist/devtools/index.d.ts +11 -0
- package/dist/devtools/index.js +35 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/export/index.cjs +111 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +49 -0
- package/dist/export/index.d.ts +49 -0
- package/dist/export/index.js +109 -0
- package/dist/export/index.js.map +1 -0
- package/dist/history/constants.d.cts +35 -0
- package/dist/history/constants.d.ts +35 -0
- package/dist/history/index.cjs +1196 -0
- package/dist/history/index.cjs.map +1 -0
- package/dist/history/index.d.cts +113 -0
- package/dist/history/index.d.ts +113 -0
- package/dist/history/index.js +1194 -0
- package/dist/history/index.js.map +1 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +158 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/indexeddb/index.cjs +15 -0
- package/dist/indexeddb/index.cjs.map +1 -0
- package/dist/indexeddb/index.d.cts +46 -0
- package/dist/indexeddb/index.d.ts +46 -0
- package/dist/indexeddb/index.js +13 -0
- package/dist/indexeddb/index.js.map +1 -0
- package/dist/redaction/index.cjs +154 -0
- package/dist/redaction/index.cjs.map +1 -0
- package/dist/redaction/index.d.cts +70 -0
- package/dist/redaction/index.d.ts +70 -0
- package/dist/redaction/index.js +152 -0
- package/dist/redaction/index.js.map +1 -0
- package/dist/sip/constants.d.cts +5 -0
- package/dist/sip/constants.d.ts +5 -0
- package/dist/sip/index.cjs +336 -0
- package/dist/sip/index.cjs.map +1 -0
- package/dist/sip/index.d.cts +34 -0
- package/dist/sip/index.d.ts +34 -0
- package/dist/sip/index.js +333 -0
- package/dist/sip/index.js.map +1 -0
- package/dist/storage/constants.d.cts +11 -0
- package/dist/storage/constants.d.ts +11 -0
- package/dist/storage/contracts.d.cts +35 -0
- package/dist/storage/contracts.d.ts +35 -0
- package/package.json +127 -3
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var common = require('./chunk-CXZYNALm.cjs');
|
|
4
|
+
var constants = require('./chunk-BLf-eCDO.cjs');
|
|
5
|
+
var conversion = require('./chunk-CEhpwtwJ.cjs');
|
|
6
|
+
|
|
7
|
+
const LOGGING_ERRORS = /* @__PURE__ */ Object.freeze({
|
|
8
|
+
[constants.LOGGING_ERROR_CODES.RECURSIVE_LOGGING]: 'Recursive logging is rejected',
|
|
9
|
+
[constants.LOGGING_ERROR_CODES.ROOT_LOGGER_CACHE_LIMIT]:
|
|
10
|
+
'Root logger cache exceeds 1000 pairs',
|
|
11
|
+
[constants.LOGGING_ERROR_CODES.STOPPED]: 'Logging is stopped',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function loggingError(code) {
|
|
15
|
+
return Object.assign(new Error(LOGGING_ERRORS[code]), { code });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createLevels(options, reportError) {
|
|
19
|
+
const { now, scheduler, levelStorage, areas } = options;
|
|
20
|
+
const maxDuration = common.positive(
|
|
21
|
+
options.maxOverrideMs ?? constants.LOGGING_LIMITS.DEFAULT_LEVEL_OVERRIDE_MS,
|
|
22
|
+
'maxOverrideMs',
|
|
23
|
+
);
|
|
24
|
+
const states = new Map();
|
|
25
|
+
let stopped = false;
|
|
26
|
+
for (const { id, level = 'info' } of areas) {
|
|
27
|
+
common.assertLevel(level);
|
|
28
|
+
if (typeof id !== 'string' || !id || states.has(id))
|
|
29
|
+
throw new TypeError('Areas must have unique non-empty IDs');
|
|
30
|
+
states.set(id, {
|
|
31
|
+
level,
|
|
32
|
+
defaultLevel: level,
|
|
33
|
+
rank: common.levelRank(level),
|
|
34
|
+
until: undefined,
|
|
35
|
+
timer: undefined,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const requireArea = (area) => {
|
|
39
|
+
const state = states.get(area);
|
|
40
|
+
if (!state) throw new TypeError('Unknown log area');
|
|
41
|
+
return state;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function save() {
|
|
45
|
+
if (!levelStorage || stopped) return;
|
|
46
|
+
const overrides = {};
|
|
47
|
+
for (const [id, state] of states)
|
|
48
|
+
if (state.until)
|
|
49
|
+
common.define(overrides, id, { level: state.level, until: state.until });
|
|
50
|
+
try {
|
|
51
|
+
levelStorage.storage.setItem(levelStorage.key, JSON.stringify(overrides));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
reportError(error, constants.LOGGING_ERROR_SOURCES.STORAGE);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function reset(state) {
|
|
58
|
+
scheduler.clearTimeout(state.timer);
|
|
59
|
+
state.timer = undefined;
|
|
60
|
+
state.until = undefined;
|
|
61
|
+
state.level = state.defaultLevel;
|
|
62
|
+
state.rank = common.levelRank(state.level);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function apply(state, level, until) {
|
|
66
|
+
reset(state);
|
|
67
|
+
state.level = level;
|
|
68
|
+
state.rank = common.levelRank(level);
|
|
69
|
+
state.until = until;
|
|
70
|
+
state.timer = scheduler.setTimeout(
|
|
71
|
+
() => {
|
|
72
|
+
if (stopped) return;
|
|
73
|
+
if (until > now()) {
|
|
74
|
+
apply(state, level, until);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
reset(state);
|
|
78
|
+
save();
|
|
79
|
+
},
|
|
80
|
+
Math.min(constants.LOGGING_LIMITS.MAX_TIMER_DELAY_MS, Math.max(0, until - now())),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function reloadLevels() {
|
|
85
|
+
if (stopped) return;
|
|
86
|
+
for (const state of states.values()) reset(state);
|
|
87
|
+
if (!levelStorage) return;
|
|
88
|
+
try {
|
|
89
|
+
const saved = JSON.parse(
|
|
90
|
+
levelStorage.storage.getItem(levelStorage.key) ?? '{}',
|
|
91
|
+
);
|
|
92
|
+
if (!saved || typeof saved !== 'object') return;
|
|
93
|
+
const time = now();
|
|
94
|
+
for (const [id, state] of states) {
|
|
95
|
+
const override = Object.hasOwn(saved, id) && saved[id];
|
|
96
|
+
if (
|
|
97
|
+
override &&
|
|
98
|
+
common.levelRank(override.level) >= 0 &&
|
|
99
|
+
Number.isFinite(override.until) &&
|
|
100
|
+
override.until > time
|
|
101
|
+
)
|
|
102
|
+
apply(
|
|
103
|
+
state,
|
|
104
|
+
override.level,
|
|
105
|
+
Math.min(override.until, time + maxDuration),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
reportError(error, constants.LOGGING_ERROR_SOURCES.STORAGE);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
reloadLevels();
|
|
113
|
+
return {
|
|
114
|
+
requireArea,
|
|
115
|
+
enabled(area, level) {
|
|
116
|
+
const state = requireArea(area);
|
|
117
|
+
if (state.until && state.until <= now()) {
|
|
118
|
+
reset(state);
|
|
119
|
+
save();
|
|
120
|
+
}
|
|
121
|
+
return common.levelRank(level) >= state.rank;
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
setLevel(area, level, { durationMs = maxDuration } = {}) {
|
|
125
|
+
common.assertLevel(level);
|
|
126
|
+
common.positive(durationMs, 'durationMs');
|
|
127
|
+
const state = requireArea(area);
|
|
128
|
+
if (stopped) return;
|
|
129
|
+
apply(state, level, now() + Math.min(durationMs, maxDuration));
|
|
130
|
+
save();
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
resetLevel(area) {
|
|
134
|
+
if (stopped) return;
|
|
135
|
+
if (area !== undefined) reset(requireArea(area));
|
|
136
|
+
else for (const state of states.values()) reset(state);
|
|
137
|
+
save();
|
|
138
|
+
},
|
|
139
|
+
reloadLevels,
|
|
140
|
+
getLevels() {
|
|
141
|
+
const result = {};
|
|
142
|
+
for (const [id, state] of states) {
|
|
143
|
+
if (state.until && state.until <= now()) {
|
|
144
|
+
reset(state);
|
|
145
|
+
save();
|
|
146
|
+
}
|
|
147
|
+
common.define(
|
|
148
|
+
result,
|
|
149
|
+
id,
|
|
150
|
+
Object.freeze({
|
|
151
|
+
level: state.level,
|
|
152
|
+
defaultLevel: state.defaultLevel,
|
|
153
|
+
...(state.until ? { until: state.until } : {}),
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return Object.freeze(result);
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
stop() {
|
|
161
|
+
stopped = true;
|
|
162
|
+
for (const state of states.values()) scheduler.clearTimeout(state.timer);
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function createLogging(options) {
|
|
168
|
+
if (
|
|
169
|
+
!Array.isArray(options?.areas) ||
|
|
170
|
+
!options.redactor ||
|
|
171
|
+
typeof options.redactor.redact !== 'function'
|
|
172
|
+
)
|
|
173
|
+
throw new TypeError('Areas and an explicit redactor are required');
|
|
174
|
+
const {
|
|
175
|
+
redactor,
|
|
176
|
+
now = Date.now,
|
|
177
|
+
monotonicNow = () => globalThis.performance?.now() ?? Date.now(),
|
|
178
|
+
scheduler = common.scheduler,
|
|
179
|
+
stormLimit = constants.LOGGING_LIMITS.DEFAULT_STORM_LIMIT,
|
|
180
|
+
} = options;
|
|
181
|
+
const limits = common.resolveLimits(redactor.limits);
|
|
182
|
+
if (
|
|
183
|
+
!redactor.limits ||
|
|
184
|
+
Object.keys(limits).some((key) => !Object.hasOwn(redactor.limits, key))
|
|
185
|
+
)
|
|
186
|
+
throw new TypeError('Redactor limits are required');
|
|
187
|
+
common.assertStormLimit(stormLimit);
|
|
188
|
+
const runId = options.createRunId?.() ?? common.randomHex(16);
|
|
189
|
+
if (typeof runId !== 'string' || !runId)
|
|
190
|
+
throw new TypeError('Invalid run ID');
|
|
191
|
+
const sinks = new Set();
|
|
192
|
+
const roots = new Map();
|
|
193
|
+
const storms = new Map();
|
|
194
|
+
let context = common.copyBindings(options.context);
|
|
195
|
+
let seq = 0;
|
|
196
|
+
let closed = false;
|
|
197
|
+
let busy = false;
|
|
198
|
+
let scopeReported = false;
|
|
199
|
+
let reporting = false;
|
|
200
|
+
let stormTimer;
|
|
201
|
+
let stopPromise;
|
|
202
|
+
|
|
203
|
+
function onError(error, source) {
|
|
204
|
+
if (reporting) return;
|
|
205
|
+
reporting = true;
|
|
206
|
+
const wasBusy = busy;
|
|
207
|
+
busy = true;
|
|
208
|
+
common.report(options.onError, error, source);
|
|
209
|
+
busy = wasBusy;
|
|
210
|
+
reporting = false;
|
|
211
|
+
}
|
|
212
|
+
const levels = createLevels({ ...options, now, scheduler }, onError);
|
|
213
|
+
|
|
214
|
+
function emit(area, scope, binding, level, message, data, bypass = false) {
|
|
215
|
+
try {
|
|
216
|
+
if (busy) {
|
|
217
|
+
onError(
|
|
218
|
+
loggingError(constants.LOGGING_ERROR_CODES.RECURSIVE_LOGGING),
|
|
219
|
+
constants.LOGGING_ERROR_SOURCES.REENTRY,
|
|
220
|
+
);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (
|
|
224
|
+
closed ||
|
|
225
|
+
options.isActive?.() === false ||
|
|
226
|
+
sinks.size === 0 ||
|
|
227
|
+
(!bypass && !levels.enabled(area, level))
|
|
228
|
+
)
|
|
229
|
+
return;
|
|
230
|
+
if (!bypass && stormLimit !== false) {
|
|
231
|
+
const key = JSON.stringify([area, scope]);
|
|
232
|
+
let counter = storms.get(key);
|
|
233
|
+
if (!counter) {
|
|
234
|
+
const cacheKey =
|
|
235
|
+
storms.size < constants.LOGGING_LIMITS.STORM_SCOPE_PAIRS ? key : 'overflow';
|
|
236
|
+
counter = storms.get(cacheKey);
|
|
237
|
+
if (!counter) {
|
|
238
|
+
counter = {
|
|
239
|
+
area,
|
|
240
|
+
scope,
|
|
241
|
+
start: monotonicNow(),
|
|
242
|
+
count: 0,
|
|
243
|
+
dropped: 0,
|
|
244
|
+
};
|
|
245
|
+
storms.set(cacheKey, counter);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const time = monotonicNow();
|
|
249
|
+
if (
|
|
250
|
+
time - counter.start >= constants.LOGGING_LIMITS.STORM_WINDOW_MS ||
|
|
251
|
+
time < counter.start
|
|
252
|
+
) {
|
|
253
|
+
counter.start = time;
|
|
254
|
+
counter.count = 0;
|
|
255
|
+
}
|
|
256
|
+
if (counter.count++ >= stormLimit) {
|
|
257
|
+
counter.dropped++;
|
|
258
|
+
if (stormTimer === undefined)
|
|
259
|
+
stormTimer = scheduler.setTimeout(
|
|
260
|
+
summarize,
|
|
261
|
+
constants.LOGGING_LIMITS.STORM_SUMMARY_DELAY_MS,
|
|
262
|
+
);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const registrations = Array.from(sinks);
|
|
267
|
+
busy = true;
|
|
268
|
+
try {
|
|
269
|
+
let value;
|
|
270
|
+
try {
|
|
271
|
+
value = typeof data === 'function' ? data() : data;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
onError(error, constants.LOGGING_ERROR_SOURCES.DATA);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (options.isActive?.() === false || sinks.size === 0) return;
|
|
277
|
+
let record;
|
|
278
|
+
try {
|
|
279
|
+
record = conversion.ownRecord(
|
|
280
|
+
redactor.redact({
|
|
281
|
+
runId,
|
|
282
|
+
seq: ++seq,
|
|
283
|
+
at: now(),
|
|
284
|
+
area,
|
|
285
|
+
scope,
|
|
286
|
+
level,
|
|
287
|
+
message,
|
|
288
|
+
context: { ...context, ...binding },
|
|
289
|
+
data: value,
|
|
290
|
+
}),
|
|
291
|
+
limits,
|
|
292
|
+
);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
onError(error, constants.LOGGING_ERROR_SOURCES.REDACTOR);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (options.isActive?.() === false) return;
|
|
298
|
+
for (const registration of registrations) {
|
|
299
|
+
if (options.isActive?.() === false || !sinks.has(registration))
|
|
300
|
+
continue;
|
|
301
|
+
try {
|
|
302
|
+
registration.sink.write(record);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
onError(error, constants.LOGGING_ERROR_SOURCES.SINK);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
} finally {
|
|
308
|
+
busy = false;
|
|
309
|
+
}
|
|
310
|
+
} catch (error) {
|
|
311
|
+
busy = false;
|
|
312
|
+
onError(error, constants.LOGGING_ERROR_SOURCES.DATA);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function summarize() {
|
|
317
|
+
stormTimer = undefined;
|
|
318
|
+
for (const counter of storms.values()) {
|
|
319
|
+
if (!counter.dropped) continue;
|
|
320
|
+
const dropped = counter.dropped;
|
|
321
|
+
counter.dropped = 0;
|
|
322
|
+
emit(
|
|
323
|
+
counter.area,
|
|
324
|
+
counter.scope,
|
|
325
|
+
{},
|
|
326
|
+
'warn',
|
|
327
|
+
'logging.suppressed',
|
|
328
|
+
{ scope: counter.scope, dropped },
|
|
329
|
+
true,
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function logger(area, scope, binding = {}) {
|
|
335
|
+
const result = {};
|
|
336
|
+
for (const level of Object.values(constants.LEVELS))
|
|
337
|
+
result[level] = (message, data) =>
|
|
338
|
+
emit(area, scope, binding, level, message, data);
|
|
339
|
+
result.child = ({
|
|
340
|
+
scope: childScope = scope,
|
|
341
|
+
context: childContext = {},
|
|
342
|
+
} = {}) =>
|
|
343
|
+
logger(area, childScope, { ...binding, ...common.copyBindings(childContext) });
|
|
344
|
+
return Object.freeze(result);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function addSink(sink) {
|
|
348
|
+
if (!sink || typeof sink.write !== 'function')
|
|
349
|
+
throw new TypeError('A sink must have write');
|
|
350
|
+
if (closed) throw loggingError(constants.LOGGING_ERROR_CODES.STOPPED);
|
|
351
|
+
const registration = { sink };
|
|
352
|
+
sinks.add(registration);
|
|
353
|
+
return () => {
|
|
354
|
+
sinks.delete(registration);
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
for (const sink of options.sinks ?? []) addSink(sink);
|
|
358
|
+
|
|
359
|
+
async function lifecycle(registrations, methods) {
|
|
360
|
+
const failures = [];
|
|
361
|
+
for (const method of methods) {
|
|
362
|
+
await Promise.all(
|
|
363
|
+
registrations.map(async ({ sink }) => {
|
|
364
|
+
try {
|
|
365
|
+
const previous = busy;
|
|
366
|
+
busy = true;
|
|
367
|
+
let result;
|
|
368
|
+
try {
|
|
369
|
+
result = sink[method]?.();
|
|
370
|
+
} finally {
|
|
371
|
+
busy = previous;
|
|
372
|
+
}
|
|
373
|
+
await result;
|
|
374
|
+
} catch (error) {
|
|
375
|
+
failures.push(error);
|
|
376
|
+
onError(error, constants.LOGGING_ERROR_SOURCES.SINK);
|
|
377
|
+
}
|
|
378
|
+
}),
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
if (failures.length)
|
|
382
|
+
throw new AggregateError(failures, 'Logging lifecycle failed');
|
|
383
|
+
}
|
|
384
|
+
return Object.freeze({
|
|
385
|
+
runId,
|
|
386
|
+
getLogger(area, scope) {
|
|
387
|
+
levels.requireArea(area);
|
|
388
|
+
if (typeof scope !== 'string')
|
|
389
|
+
throw new TypeError('Scope must be a string');
|
|
390
|
+
const key = JSON.stringify([area, scope]);
|
|
391
|
+
const cached = roots.get(key);
|
|
392
|
+
if (cached) return cached;
|
|
393
|
+
const created = logger(area, scope);
|
|
394
|
+
if (roots.size < constants.LOGGING_LIMITS.ROOT_LOGGER_CACHE_PAIRS) {
|
|
395
|
+
roots.set(key, created);
|
|
396
|
+
return created;
|
|
397
|
+
}
|
|
398
|
+
if (!scopeReported) {
|
|
399
|
+
scopeReported = true;
|
|
400
|
+
onError(
|
|
401
|
+
loggingError(constants.LOGGING_ERROR_CODES.ROOT_LOGGER_CACHE_LIMIT),
|
|
402
|
+
constants.LOGGING_ERROR_SOURCES.SCOPE,
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
return created;
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
setContext(values) {
|
|
409
|
+
context = { ...context, ...common.copyBindings(values) };
|
|
410
|
+
for (const key of Object.keys(context))
|
|
411
|
+
if (context[key] === undefined) delete context[key];
|
|
412
|
+
},
|
|
413
|
+
setLevel: levels.setLevel,
|
|
414
|
+
resetLevel: levels.resetLevel,
|
|
415
|
+
reloadLevels: levels.reloadLevels,
|
|
416
|
+
getLevels: levels.getLevels,
|
|
417
|
+
addSink,
|
|
418
|
+
flush() {
|
|
419
|
+
const registrations = Array.from(sinks);
|
|
420
|
+
return Promise.resolve().then(() => lifecycle(registrations, ['flush']));
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
stop() {
|
|
424
|
+
if (!stopPromise) {
|
|
425
|
+
closed = true;
|
|
426
|
+
levels.stop();
|
|
427
|
+
scheduler.clearTimeout(stormTimer);
|
|
428
|
+
const registrations = Array.from(sinks);
|
|
429
|
+
stopPromise = Promise.resolve().then(() =>
|
|
430
|
+
lifecycle(registrations, ['flush', 'stop']),
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
return stopPromise;
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
exports.createLogging = createLogging;
|
|
439
|
+
exports.loggingError = loggingError;
|
|
440
|
+
//# sourceMappingURL=chunk-Bvq4tF_F.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-Bvq4tF_F.cjs","sources":["../src/core/errors.js","../src/core/levels.js","../src/core/hub.js"],"sourcesContent":["import { LOGGING_ERROR_CODES } from './constants.js';\n\nexport const LOGGING_ERRORS = /* @__PURE__ */ Object.freeze({\n [LOGGING_ERROR_CODES.RECURSIVE_LOGGING]: 'Recursive logging is rejected',\n [LOGGING_ERROR_CODES.ROOT_LOGGER_CACHE_LIMIT]:\n 'Root logger cache exceeds 1000 pairs',\n [LOGGING_ERROR_CODES.STOPPED]: 'Logging is stopped',\n});\n\nexport function loggingError(code) {\n return Object.assign(new Error(LOGGING_ERRORS[code]), { code });\n}\n","import { assertLevel, define, levelRank, positive } from './common.js';\nimport { LOGGING_ERROR_SOURCES, LOGGING_LIMITS } from './constants.js';\n\nexport function createLevels(options, reportError) {\n const { now, scheduler, levelStorage, areas } = options;\n const maxDuration = positive(\n options.maxOverrideMs ?? LOGGING_LIMITS.DEFAULT_LEVEL_OVERRIDE_MS,\n 'maxOverrideMs',\n );\n const states = new Map();\n let stopped = false;\n for (const { id, level = 'info' } of areas) {\n assertLevel(level);\n if (typeof id !== 'string' || !id || states.has(id))\n throw new TypeError('Areas must have unique non-empty IDs');\n states.set(id, {\n level,\n defaultLevel: level,\n rank: levelRank(level),\n until: undefined,\n timer: undefined,\n });\n }\n const requireArea = (area) => {\n const state = states.get(area);\n if (!state) throw new TypeError('Unknown log area');\n return state;\n };\n\n function save() {\n if (!levelStorage || stopped) return;\n const overrides = {};\n for (const [id, state] of states)\n if (state.until)\n define(overrides, id, { level: state.level, until: state.until });\n try {\n levelStorage.storage.setItem(levelStorage.key, JSON.stringify(overrides));\n } catch (error) {\n reportError(error, LOGGING_ERROR_SOURCES.STORAGE);\n }\n }\n\n function reset(state) {\n scheduler.clearTimeout(state.timer);\n state.timer = undefined;\n state.until = undefined;\n state.level = state.defaultLevel;\n state.rank = levelRank(state.level);\n }\n\n function apply(state, level, until) {\n reset(state);\n state.level = level;\n state.rank = levelRank(level);\n state.until = until;\n state.timer = scheduler.setTimeout(\n () => {\n if (stopped) return;\n if (until > now()) {\n apply(state, level, until);\n return;\n }\n reset(state);\n save();\n },\n Math.min(LOGGING_LIMITS.MAX_TIMER_DELAY_MS, Math.max(0, until - now())),\n );\n }\n\n function reloadLevels() {\n if (stopped) return;\n for (const state of states.values()) reset(state);\n if (!levelStorage) return;\n try {\n const saved = JSON.parse(\n levelStorage.storage.getItem(levelStorage.key) ?? '{}',\n );\n if (!saved || typeof saved !== 'object') return;\n const time = now();\n for (const [id, state] of states) {\n const override = Object.hasOwn(saved, id) && saved[id];\n if (\n override &&\n levelRank(override.level) >= 0 &&\n Number.isFinite(override.until) &&\n override.until > time\n )\n apply(\n state,\n override.level,\n Math.min(override.until, time + maxDuration),\n );\n }\n } catch (error) {\n reportError(error, LOGGING_ERROR_SOURCES.STORAGE);\n }\n }\n reloadLevels();\n return {\n requireArea,\n enabled(area, level) {\n const state = requireArea(area);\n if (state.until && state.until <= now()) {\n reset(state);\n save();\n }\n return levelRank(level) >= state.rank;\n },\n\n setLevel(area, level, { durationMs = maxDuration } = {}) {\n assertLevel(level);\n positive(durationMs, 'durationMs');\n const state = requireArea(area);\n if (stopped) return;\n apply(state, level, now() + Math.min(durationMs, maxDuration));\n save();\n },\n\n resetLevel(area) {\n if (stopped) return;\n if (area !== undefined) reset(requireArea(area));\n else for (const state of states.values()) reset(state);\n save();\n },\n reloadLevels,\n getLevels() {\n const result = {};\n for (const [id, state] of states) {\n if (state.until && state.until <= now()) {\n reset(state);\n save();\n }\n define(\n result,\n id,\n Object.freeze({\n level: state.level,\n defaultLevel: state.defaultLevel,\n ...(state.until ? { until: state.until } : {}),\n }),\n );\n }\n return Object.freeze(result);\n },\n\n stop() {\n stopped = true;\n for (const state of states.values()) scheduler.clearTimeout(state.timer);\n },\n };\n}\n","import {\n assertStormLimit,\n copyBindings,\n scheduler as hostScheduler,\n randomHex,\n report,\n resolveLimits,\n} from './common.js';\nimport {\n LEVELS,\n LOGGING_ERROR_CODES,\n LOGGING_ERROR_SOURCES,\n LOGGING_LIMITS,\n} from './constants.js';\nimport { ownRecord } from './conversion.js';\nimport { loggingError } from './errors.js';\nimport { createLevels } from './levels.js';\n\nexport function createLogging(options) {\n if (\n !Array.isArray(options?.areas) ||\n !options.redactor ||\n typeof options.redactor.redact !== 'function'\n )\n throw new TypeError('Areas and an explicit redactor are required');\n const {\n redactor,\n now = Date.now,\n monotonicNow = () => globalThis.performance?.now() ?? Date.now(),\n scheduler = hostScheduler,\n stormLimit = LOGGING_LIMITS.DEFAULT_STORM_LIMIT,\n } = options;\n const limits = resolveLimits(redactor.limits);\n if (\n !redactor.limits ||\n Object.keys(limits).some((key) => !Object.hasOwn(redactor.limits, key))\n )\n throw new TypeError('Redactor limits are required');\n assertStormLimit(stormLimit);\n const runId = options.createRunId?.() ?? randomHex(16);\n if (typeof runId !== 'string' || !runId)\n throw new TypeError('Invalid run ID');\n const sinks = new Set();\n const roots = new Map();\n const storms = new Map();\n let context = copyBindings(options.context);\n let seq = 0;\n let closed = false;\n let busy = false;\n let scopeReported = false;\n let reporting = false;\n let stormTimer;\n let stopPromise;\n\n function onError(error, source) {\n if (reporting) return;\n reporting = true;\n const wasBusy = busy;\n busy = true;\n report(options.onError, error, source);\n busy = wasBusy;\n reporting = false;\n }\n const levels = createLevels({ ...options, now, scheduler }, onError);\n\n function emit(area, scope, binding, level, message, data, bypass = false) {\n try {\n if (busy) {\n onError(\n loggingError(LOGGING_ERROR_CODES.RECURSIVE_LOGGING),\n LOGGING_ERROR_SOURCES.REENTRY,\n );\n return;\n }\n if (\n closed ||\n options.isActive?.() === false ||\n sinks.size === 0 ||\n (!bypass && !levels.enabled(area, level))\n )\n return;\n if (!bypass && stormLimit !== false) {\n const key = JSON.stringify([area, scope]);\n let counter = storms.get(key);\n if (!counter) {\n const cacheKey =\n storms.size < LOGGING_LIMITS.STORM_SCOPE_PAIRS ? key : 'overflow';\n counter = storms.get(cacheKey);\n if (!counter) {\n counter = {\n area,\n scope,\n start: monotonicNow(),\n count: 0,\n dropped: 0,\n };\n storms.set(cacheKey, counter);\n }\n }\n const time = monotonicNow();\n if (\n time - counter.start >= LOGGING_LIMITS.STORM_WINDOW_MS ||\n time < counter.start\n ) {\n counter.start = time;\n counter.count = 0;\n }\n if (counter.count++ >= stormLimit) {\n counter.dropped++;\n if (stormTimer === undefined)\n stormTimer = scheduler.setTimeout(\n summarize,\n LOGGING_LIMITS.STORM_SUMMARY_DELAY_MS,\n );\n return;\n }\n }\n const registrations = Array.from(sinks);\n busy = true;\n try {\n let value;\n try {\n value = typeof data === 'function' ? data() : data;\n } catch (error) {\n onError(error, LOGGING_ERROR_SOURCES.DATA);\n return;\n }\n if (options.isActive?.() === false || sinks.size === 0) return;\n let record;\n try {\n record = ownRecord(\n redactor.redact({\n runId,\n seq: ++seq,\n at: now(),\n area,\n scope,\n level,\n message,\n context: { ...context, ...binding },\n data: value,\n }),\n limits,\n );\n } catch (error) {\n onError(error, LOGGING_ERROR_SOURCES.REDACTOR);\n return;\n }\n if (options.isActive?.() === false) return;\n for (const registration of registrations) {\n if (options.isActive?.() === false || !sinks.has(registration))\n continue;\n try {\n registration.sink.write(record);\n } catch (error) {\n onError(error, LOGGING_ERROR_SOURCES.SINK);\n }\n }\n } finally {\n busy = false;\n }\n } catch (error) {\n busy = false;\n onError(error, LOGGING_ERROR_SOURCES.DATA);\n }\n }\n\n function summarize() {\n stormTimer = undefined;\n for (const counter of storms.values()) {\n if (!counter.dropped) continue;\n const dropped = counter.dropped;\n counter.dropped = 0;\n emit(\n counter.area,\n counter.scope,\n {},\n 'warn',\n 'logging.suppressed',\n { scope: counter.scope, dropped },\n true,\n );\n }\n }\n\n function logger(area, scope, binding = {}) {\n const result = {};\n for (const level of Object.values(LEVELS))\n result[level] = (message, data) =>\n emit(area, scope, binding, level, message, data);\n result.child = ({\n scope: childScope = scope,\n context: childContext = {},\n } = {}) =>\n logger(area, childScope, { ...binding, ...copyBindings(childContext) });\n return Object.freeze(result);\n }\n\n function addSink(sink) {\n if (!sink || typeof sink.write !== 'function')\n throw new TypeError('A sink must have write');\n if (closed) throw loggingError(LOGGING_ERROR_CODES.STOPPED);\n const registration = { sink };\n sinks.add(registration);\n return () => {\n sinks.delete(registration);\n };\n }\n for (const sink of options.sinks ?? []) addSink(sink);\n\n async function lifecycle(registrations, methods) {\n const failures = [];\n for (const method of methods) {\n await Promise.all(\n registrations.map(async ({ sink }) => {\n try {\n const previous = busy;\n busy = true;\n let result;\n try {\n result = sink[method]?.();\n } finally {\n busy = previous;\n }\n await result;\n } catch (error) {\n failures.push(error);\n onError(error, LOGGING_ERROR_SOURCES.SINK);\n }\n }),\n );\n }\n if (failures.length)\n throw new AggregateError(failures, 'Logging lifecycle failed');\n }\n return Object.freeze({\n runId,\n getLogger(area, scope) {\n levels.requireArea(area);\n if (typeof scope !== 'string')\n throw new TypeError('Scope must be a string');\n const key = JSON.stringify([area, scope]);\n const cached = roots.get(key);\n if (cached) return cached;\n const created = logger(area, scope);\n if (roots.size < LOGGING_LIMITS.ROOT_LOGGER_CACHE_PAIRS) {\n roots.set(key, created);\n return created;\n }\n if (!scopeReported) {\n scopeReported = true;\n onError(\n loggingError(LOGGING_ERROR_CODES.ROOT_LOGGER_CACHE_LIMIT),\n LOGGING_ERROR_SOURCES.SCOPE,\n );\n }\n return created;\n },\n\n setContext(values) {\n context = { ...context, ...copyBindings(values) };\n for (const key of Object.keys(context))\n if (context[key] === undefined) delete context[key];\n },\n setLevel: levels.setLevel,\n resetLevel: levels.resetLevel,\n reloadLevels: levels.reloadLevels,\n getLevels: levels.getLevels,\n addSink,\n flush() {\n const registrations = Array.from(sinks);\n return Promise.resolve().then(() => lifecycle(registrations, ['flush']));\n },\n\n stop() {\n if (!stopPromise) {\n closed = true;\n levels.stop();\n scheduler.clearTimeout(stormTimer);\n const registrations = Array.from(sinks);\n stopPromise = Promise.resolve().then(() =>\n lifecycle(registrations, ['flush', 'stop']),\n );\n }\n return stopPromise;\n },\n });\n}\n"],"names":["LOGGING_ERROR_CODES","positive","LOGGING_LIMITS","assertLevel","levelRank","define","LOGGING_ERROR_SOURCES","hostScheduler","resolveLimits","assertStormLimit","randomHex","copyBindings","report","ownRecord","LEVELS"],"mappings":";;;;;;AAEO,MAAM,cAAc,mBAAmB,MAAM,CAAC,MAAM,CAAC;AAC5D,EAAE,CAACA,6BAAmB,CAAC,iBAAiB,GAAG,+BAA+B;AAC1E,EAAE,CAACA,6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