@smoothbricks/lmao 0.2.2 → 0.2.3
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/allocator.wasm +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/JsBufferStrategy.d.ts +4 -3
- package/dist/lib/JsBufferStrategy.d.ts.map +1 -1
- package/dist/lib/JsBufferStrategy.js +18 -11
- package/dist/lib/arrow/lease.d.ts +10 -0
- package/dist/lib/arrow/lease.d.ts.map +1 -0
- package/dist/lib/arrow/lease.js +33 -0
- package/dist/lib/arrow/utils.d.ts +3 -4
- package/dist/lib/arrow/utils.d.ts.map +1 -1
- package/dist/lib/arrow/utils.js +12 -13
- package/dist/lib/arrow/vocabularyDictionary.d.ts +21 -0
- package/dist/lib/arrow/vocabularyDictionary.d.ts.map +1 -0
- package/dist/lib/arrow/vocabularyDictionary.js +95 -0
- package/dist/lib/bufferStrategy.d.ts +3 -2
- package/dist/lib/bufferStrategy.d.ts.map +1 -1
- package/dist/lib/cloudflare/traceRows.d.ts.map +1 -1
- package/dist/lib/cloudflare/traceRows.js +3 -2
- package/dist/lib/codegen/evaluatorGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/evaluatorGenerator.js +12 -11
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts +44 -82
- package/dist/lib/codegen/fixedPositionWriterGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/fixedPositionWriterGenerator.js +223 -162
- package/dist/lib/codegen/spanLoggerClosureMaterializer.d.ts +63 -0
- package/dist/lib/codegen/spanLoggerClosureMaterializer.d.ts.map +1 -0
- package/dist/lib/codegen/spanLoggerClosureMaterializer.js +447 -0
- package/dist/lib/codegen/spanLoggerGenerator.d.ts +36 -19
- package/dist/lib/codegen/spanLoggerGenerator.d.ts.map +1 -1
- package/dist/lib/codegen/spanLoggerGenerator.js +164 -158
- package/dist/lib/convertToArrow.d.ts +7 -2
- package/dist/lib/convertToArrow.d.ts.map +1 -1
- package/dist/lib/convertToArrow.js +499 -285
- package/dist/lib/defineOpContext.js +1 -1
- package/dist/lib/enumMetadata.d.ts +19 -0
- package/dist/lib/enumMetadata.d.ts.map +1 -0
- package/dist/lib/enumMetadata.js +86 -0
- package/dist/lib/flushScheduler.d.ts.map +1 -1
- package/dist/lib/flushScheduler.js +13 -4
- package/dist/lib/library.d.ts +16 -98
- package/dist/lib/library.d.ts.map +1 -1
- package/dist/lib/library.js +32 -525
- package/dist/lib/logBinding.d.ts +21 -27
- package/dist/lib/logBinding.d.ts.map +1 -1
- package/dist/lib/op.d.ts +30 -30
- package/dist/lib/op.d.ts.map +1 -1
- package/dist/lib/op.js +15 -22
- package/dist/lib/opContext/createOpGroup.d.ts +1 -1
- package/dist/lib/opContext/createOpGroup.d.ts.map +1 -1
- package/dist/lib/opContext/createOpGroup.js +22 -29
- package/dist/lib/opContext/defineOp.d.ts +4 -4
- package/dist/lib/opContext/defineOp.d.ts.map +1 -1
- package/dist/lib/opContext/defineOp.js +53 -10
- package/dist/lib/opContext/opGroupTypes.d.ts +2 -2
- package/dist/lib/opContext/opTypes.d.ts +1 -1
- package/dist/lib/opContext/opTypes.d.ts.map +1 -1
- package/dist/lib/opContext/spanContextTypes.d.ts +29 -14
- package/dist/lib/opContext/spanContextTypes.d.ts.map +1 -1
- package/dist/lib/opContext/types.d.ts +4 -4
- package/dist/lib/opContext/types.d.ts.map +1 -1
- package/dist/lib/physicalLayoutPlan.d.ts +89 -0
- package/dist/lib/physicalLayoutPlan.d.ts.map +1 -0
- package/dist/lib/physicalLayoutPlan.js +442 -0
- package/dist/lib/resolveMessage.d.ts +9 -0
- package/dist/lib/resolveMessage.d.ts.map +1 -0
- package/dist/lib/resolveMessage.js +63 -0
- package/dist/lib/result.d.ts +5 -7
- package/dist/lib/result.d.ts.map +1 -1
- package/dist/lib/result.js +19 -26
- package/dist/lib/runtimeHint.d.ts +35 -0
- package/dist/lib/runtimeHint.d.ts.map +1 -0
- package/dist/lib/runtimeHint.js +79 -0
- package/dist/lib/schema/types.d.ts +1 -1
- package/dist/lib/schema/types.d.ts.map +1 -1
- package/dist/lib/span-buffer/aot/v1.d.ts +2 -0
- package/dist/lib/span-buffer/aot/v1.d.ts.map +1 -0
- package/dist/lib/span-buffer/aot/v1.js +24 -0
- package/dist/lib/spanBuffer.d.ts +33 -4
- package/dist/lib/spanBuffer.d.ts.map +1 -1
- package/dist/lib/spanBuffer.js +583 -91
- package/dist/lib/spanBufferStats.d.ts +1 -1
- package/dist/lib/spanBufferStats.d.ts.map +1 -1
- package/dist/lib/spanContext.d.ts +27 -51
- package/dist/lib/spanContext.d.ts.map +1 -1
- package/dist/lib/spanContext.js +822 -344
- package/dist/lib/sqlite/sqlite-common.d.ts.map +1 -1
- package/dist/lib/sqlite/sqlite-common.js +20 -21
- package/dist/lib/testing/bun-harness.d.ts +8 -3
- package/dist/lib/testing/bun-harness.d.ts.map +1 -1
- package/dist/lib/testing/bun-harness.js +30 -18
- package/dist/lib/testing/extractFacts.d.ts +1 -1
- package/dist/lib/testing/extractFacts.d.ts.map +1 -1
- package/dist/lib/testing/extractFacts.js +55 -63
- package/dist/lib/testing/facts.d.ts +1 -1
- package/dist/lib/testing/facts.d.ts.map +1 -1
- package/dist/lib/testing/queryable-span.d.ts +1 -1
- package/dist/lib/testing/queryable-span.d.ts.map +1 -1
- package/dist/lib/testing/queryable-span.js +26 -28
- package/dist/lib/testing/span-query.d.ts.map +1 -1
- package/dist/lib/testing/span-query.js +19 -22
- package/dist/lib/testing/stdio-replay.d.ts.map +1 -1
- package/dist/lib/testing/stdio-replay.js +19 -8
- package/dist/lib/threadId.d.ts.map +1 -1
- package/dist/lib/threadId.js +6 -3
- package/dist/lib/traceRoot.d.ts +30 -8
- package/dist/lib/traceRoot.d.ts.map +1 -1
- package/dist/lib/traceRoot.es.d.ts +17 -15
- package/dist/lib/traceRoot.es.d.ts.map +1 -1
- package/dist/lib/traceRoot.es.js +68 -34
- package/dist/lib/traceRoot.js +11 -0
- package/dist/lib/traceRoot.node.d.ts +17 -19
- package/dist/lib/traceRoot.node.d.ts.map +1 -1
- package/dist/lib/traceRoot.node.js +66 -38
- package/dist/lib/traceTopology.d.ts +42 -0
- package/dist/lib/traceTopology.d.ts.map +1 -0
- package/dist/lib/traceTopology.js +260 -0
- package/dist/lib/tracer.d.ts +9 -5
- package/dist/lib/tracer.d.ts.map +1 -1
- package/dist/lib/tracer.js +65 -71
- package/dist/lib/tracers/ArrayQueueTracer.d.ts +1 -1
- package/dist/lib/tracers/ArrayQueueTracer.js +1 -1
- package/dist/lib/tracers/StdioTracer.d.ts.map +1 -1
- package/dist/lib/tracers/StdioTracer.js +15 -13
- package/dist/lib/tracers/TestTracer.d.ts +4 -6
- package/dist/lib/tracers/TestTracer.d.ts.map +1 -1
- package/dist/lib/tracers/TestTracer.js +6 -8
- package/dist/lib/types.d.ts +49 -32
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vocabularyRegistry.d.ts +25 -0
- package/dist/lib/vocabularyRegistry.d.ts.map +1 -0
- package/dist/lib/vocabularyRegistry.js +372 -0
- package/dist/lib/wasm/WasmBufferStrategy.d.ts +6 -10
- package/dist/lib/wasm/WasmBufferStrategy.d.ts.map +1 -1
- package/dist/lib/wasm/WasmBufferStrategy.js +44 -37
- package/dist/lib/wasm/wasmAllocator.d.ts +27 -22
- package/dist/lib/wasm/wasmAllocator.d.ts.map +1 -1
- package/dist/lib/wasm/wasmAllocator.js +66 -44
- package/dist/lib/wasm/wasmPhysicalLayout.d.ts +67 -0
- package/dist/lib/wasm/wasmPhysicalLayout.d.ts.map +1 -0
- package/dist/lib/wasm/wasmPhysicalLayout.js +179 -0
- package/dist/lib/wasm/wasmSpanBuffer.d.ts +79 -31
- package/dist/lib/wasm/wasmSpanBuffer.d.ts.map +1 -1
- package/dist/lib/wasm/wasmSpanBuffer.js +442 -272
- package/dist/lib/wasm/wasmTraceRoot.d.ts +24 -22
- package/dist/lib/wasm/wasmTraceRoot.d.ts.map +1 -1
- package/dist/lib/wasm/wasmTraceRoot.js +110 -71
- package/dist/vocabulary/register/v1.d.ts +2 -0
- package/dist/vocabulary/register/v1.d.ts.map +1 -0
- package/dist/vocabulary/register/v1.js +1 -0
- package/dist/wasm.d.ts +5 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +4 -0
- package/package.json +54 -6
- package/src/index.ts +1 -0
- package/src/lib/JsBufferStrategy.ts +27 -9
- package/src/lib/__tests__/arrow-builder-integration/arrow-conversion.test.ts +335 -37
- package/src/lib/__tests__/arrow-builder-integration/binary-arrow-conversion.test.ts +97 -26
- package/src/lib/__tests__/arrow-builder-integration/binary-comparison.test.ts +75 -15
- package/src/lib/__tests__/arrow-builder-integration/binary-format-compliance.test.ts +30 -6
- package/src/lib/__tests__/arrow-builder-integration/buffer-chaining.test.ts +18 -21
- package/src/lib/__tests__/arrow-builder-integration/foundation.test.ts +5 -2
- package/src/lib/__tests__/arrow-builder-integration/integration.test.ts +25 -7
- package/src/lib/__tests__/arrow-builder-integration/lazy-columns.test.ts +3 -2
- package/src/lib/__tests__/buffer-overflow.test.ts +24 -18
- package/src/lib/__tests__/capability-span-context.test.ts +505 -0
- package/src/lib/__tests__/capacity-tuning.test.ts +5 -3
- package/src/lib/__tests__/eager-columns.test.ts +345 -0
- package/src/lib/__tests__/enum-metadata-aot.test.ts +153 -0
- package/src/lib/__tests__/enum-metadata.test.ts +177 -0
- package/src/lib/__tests__/fixtures/empty-vocabulary-runtime.fixture.ts +15 -0
- package/src/lib/__tests__/flushScheduler.test.ts +5 -1
- package/src/lib/__tests__/identity-view.property.test.ts +179 -0
- package/src/lib/__tests__/library.test.ts +19 -235
- package/src/lib/__tests__/message-buffer-families.test.ts +878 -0
- package/src/lib/__tests__/nested-library-tasks.test.ts +14 -15
- package/src/lib/__tests__/op-metadata.test.ts +1 -1
- package/src/lib/__tests__/op-type-safety.test.ts +5 -16
- package/src/lib/__tests__/physical-layout-plan.test.ts +333 -0
- package/src/lib/__tests__/remap-descriptor-integration.test.ts +381 -0
- package/src/lib/__tests__/root-context-construction.test.ts +414 -0
- package/src/lib/__tests__/span-auto-runtime.test.ts +386 -0
- package/src/lib/__tests__/span-buffer-segment-stats.test.ts +221 -0
- package/src/lib/__tests__/span-lifecycle.test.ts +53 -25
- package/src/lib/__tests__/spanbuffer-materializer-parity.test.ts +266 -0
- package/src/lib/__tests__/sync-async-trace.test.ts +24 -23
- package/src/lib/__tests__/tag-writer-aot.test.ts +214 -0
- package/src/lib/__tests__/test-helpers.ts +67 -12
- package/src/lib/__tests__/threadId.test.ts +62 -0
- package/src/lib/__tests__/timestamp.test.ts +221 -93
- package/src/lib/__tests__/traceTopology.property.test.ts +383 -0
- package/src/lib/__tests__/type-narrowing.test.ts +63 -0
- package/src/lib/__tests__/vocabulary-dense-decoding.test.ts +405 -0
- package/src/lib/__tests__/vocabularyRegistry.test.ts +313 -0
- package/src/lib/arrow/lease.ts +43 -0
- package/src/lib/arrow/utils.ts +10 -14
- package/src/lib/arrow/vocabularyDictionary.ts +123 -0
- package/src/lib/bufferStrategy.ts +9 -1
- package/src/lib/cloudflare/traceRows.ts +3 -2
- package/src/lib/codegen/__tests__/evaluatorGenerator.test.ts +21 -141
- package/src/lib/codegen/__tests__/fixedPositionWriter-parity.test.ts +273 -0
- package/src/lib/codegen/__tests__/fixedPositionWriter-uint64.test.ts +61 -34
- package/src/lib/codegen/__tests__/nullBitmap.test.ts +33 -37
- package/src/lib/codegen/__tests__/spanLoggerGenerator.test.ts +34 -18
- package/src/lib/codegen/__tests__/spanLoggerMaterializerParity.test.ts +503 -0
- package/src/lib/codegen/evaluatorGenerator.ts +18 -13
- package/src/lib/codegen/fixedPositionWriterGenerator.ts +329 -245
- package/src/lib/codegen/spanLoggerClosureMaterializer.ts +598 -0
- package/src/lib/codegen/spanLoggerGenerator.ts +241 -177
- package/src/lib/convertToArrow.ts +598 -311
- package/src/lib/defineOpContext.ts +1 -1
- package/src/lib/enumMetadata.ts +121 -0
- package/src/lib/flushScheduler.ts +11 -5
- package/src/lib/library.ts +37 -595
- package/src/lib/logBinding.ts +21 -27
- package/src/lib/op.ts +75 -18
- package/src/lib/opContext/__tests__/retry.test.ts +27 -21
- package/src/lib/opContext/createOpGroup.ts +33 -31
- package/src/lib/opContext/defineOp.ts +88 -11
- package/src/lib/opContext/opGroupTypes.ts +2 -2
- package/src/lib/opContext/opTypes.ts +1 -1
- package/src/lib/opContext/spanContextTypes.ts +98 -17
- package/src/lib/opContext/types.ts +7 -3
- package/src/lib/physicalLayoutPlan.ts +598 -0
- package/src/lib/resolveMessage.ts +67 -0
- package/src/lib/result.ts +20 -33
- package/src/lib/runtimeHint.ts +98 -0
- package/src/lib/schema/__tests__/featureFlags.test.ts +2 -1
- package/src/lib/schema/builder.ts +1 -1
- package/src/lib/schema/types.ts +1 -1
- package/src/lib/span-buffer/aot/v1.ts +26 -0
- package/src/lib/spanBuffer.ts +658 -92
- package/src/lib/spanBufferStats.ts +1 -1
- package/src/lib/spanContext.ts +1350 -861
- package/src/lib/sqlite/sqlite-common.ts +20 -31
- package/src/lib/testing/__tests__/topology-traversal.test.ts +174 -0
- package/src/lib/testing/__tests__/vitest-harness.test.ts +2 -1
- package/src/lib/testing/bun-harness.ts +94 -43
- package/src/lib/testing/extractFacts.ts +64 -78
- package/src/lib/testing/facts.ts +1 -1
- package/src/lib/testing/queryable-span.ts +23 -30
- package/src/lib/testing/span-query.ts +16 -20
- package/src/lib/testing/stdio-replay.ts +25 -8
- package/src/lib/testing/vitest-harness.ts +1 -1
- package/src/lib/threadId.ts +6 -3
- package/src/lib/traceRoot.es.ts +77 -42
- package/src/lib/traceRoot.node.ts +75 -46
- package/src/lib/traceRoot.ts +41 -14
- package/src/lib/traceTopology.ts +279 -0
- package/src/lib/tracer.ts +109 -98
- package/src/lib/tracers/ArrayQueueTracer.ts +1 -1
- package/src/lib/tracers/StdioTracer.ts +15 -13
- package/src/lib/tracers/TestTracer.ts +6 -8
- package/src/lib/tracers/__tests__/ArrayQueueTracer.test.ts +15 -10
- package/src/lib/tracers/__tests__/TestTracer.test.ts +23 -13
- package/src/lib/types.ts +64 -33
- package/src/lib/vocabularyRegistry.ts +439 -0
- package/src/lib/wasm/WasmBufferStrategy.ts +56 -48
- package/src/lib/wasm/__tests__/WasmBufferStrategy.test.ts +215 -11
- package/src/lib/wasm/__tests__/allocatorFreeBlockClamp.test.ts +86 -0
- package/src/lib/wasm/__tests__/wasm-identity-view.test.ts +311 -0
- package/src/lib/wasm/__tests__/wasm-integration.test.ts +417 -44
- package/src/lib/wasm/__tests__/wasm-message-buffer-families.test.ts +588 -0
- package/src/lib/wasm/__tests__/wasmAllocator.test.ts +100 -668
- package/src/lib/wasm/__tests__/wasmSpanBuffer.test.ts +419 -63
- package/src/lib/wasm/__tests__/wasmTraceRoot.test.ts +24 -29
- package/src/lib/wasm/__tests__/wasmTracer.test.ts.disabled +2 -2
- package/src/lib/wasm/wasmAllocator.ts +131 -96
- package/src/lib/wasm/wasmPhysicalLayout.ts +309 -0
- package/src/lib/wasm/wasmSpanBuffer.ts +597 -341
- package/src/lib/wasm/wasmTraceRoot.ts +140 -78
- package/src/vocabulary/register/v1.ts +1 -0
- package/src/wasm.ts +19 -0
- package/src/lib/__tests__/remapped-buffer-view-integration.test.ts +0 -319
- package/src/lib/__tests__/remapped-buffer-view.test.ts +0 -635
- package/src/lib/wasm/allocator.zig +0 -948
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
//#region smoo/lmao!n/codegen-spanlogger.closure
|
|
2
|
+
/**
|
|
3
|
+
* Closure-composed (no-eval) materializer for state-bound SpanLogger classes.
|
|
4
|
+
*
|
|
5
|
+
* Production workerd forbids code generation from strings (EvalError), so the
|
|
6
|
+
* compiled renderer in spanLoggerGenerator.ts cannot run there. This module
|
|
7
|
+
* assembles the SAME class shape from per-field closures instead of source
|
|
8
|
+
* text, mirroring arrow-builder's closureMaterializers.ts:
|
|
9
|
+
* - one shared prototype per schema/config plan,
|
|
10
|
+
* - methods installed with { value, writable: true, configurable: true, enumerable: false },
|
|
11
|
+
* - accessors installed with { get, configurable: true, enumerable: false },
|
|
12
|
+
* - constructors assign instance properties in the same order (V8 hidden classes).
|
|
13
|
+
*
|
|
14
|
+
* Every closure body mirrors the compiled class member it replaces, including
|
|
15
|
+
* evaluation order (append -> message write -> fields), guard conditions, and
|
|
16
|
+
* thrown error messages that callers observe.
|
|
17
|
+
*/
|
|
18
|
+
import { ENTRY_TYPE_DEBUG, ENTRY_TYPE_ERROR, ENTRY_TYPE_FF_ACCESS, ENTRY_TYPE_FF_USAGE, ENTRY_TYPE_INFO, ENTRY_TYPE_TRACE, ENTRY_TYPE_WARN, } from '../schema/systemSchema.js';
|
|
19
|
+
function isIndexWritable(value) {
|
|
20
|
+
return typeof value === 'object' && value !== null;
|
|
21
|
+
}
|
|
22
|
+
function laneOf(value) {
|
|
23
|
+
if (isIndexWritable(value))
|
|
24
|
+
return value;
|
|
25
|
+
throw new TypeError('Expected an indexable column lane');
|
|
26
|
+
}
|
|
27
|
+
function bitmapOf(value) {
|
|
28
|
+
if (value instanceof Uint8Array)
|
|
29
|
+
return value;
|
|
30
|
+
throw new TypeError('Expected a Uint8Array bitmap lane');
|
|
31
|
+
}
|
|
32
|
+
function isRangeFillable(value) {
|
|
33
|
+
return typeof value === 'object' && value !== null && typeof Reflect.get(value, 'fill') === 'function';
|
|
34
|
+
}
|
|
35
|
+
function fillableOf(value) {
|
|
36
|
+
if (isRangeFillable(value))
|
|
37
|
+
return value;
|
|
38
|
+
throw new TypeError('Expected a fillable column lane');
|
|
39
|
+
}
|
|
40
|
+
/** Dynamic `this.with(...)` dispatch (the compiled methods call through `this`). */
|
|
41
|
+
function callFluentWith(self, attributes) {
|
|
42
|
+
const withFn = self.with;
|
|
43
|
+
if (typeof withFn !== 'function')
|
|
44
|
+
throw new TypeError('SpanLogger.with is not callable');
|
|
45
|
+
withFn.call(self, attributes);
|
|
46
|
+
}
|
|
47
|
+
const METHOD_DESCRIPTOR = { writable: true, configurable: true, enumerable: false };
|
|
48
|
+
const ACCESSOR_DESCRIPTOR = { configurable: true, enumerable: false };
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// Schema column fluent setters (state-bound mirror of the base ColumnWriter
|
|
51
|
+
// setters after the `this._buffer` -> `this._state._buffer` and
|
|
52
|
+
// `this._writeIndex` -> `(this._state._buffer._writeIndex - 1)` rewrites)
|
|
53
|
+
// ============================================================================
|
|
54
|
+
function makeStateBoundSetter(column) {
|
|
55
|
+
const { name, schemaType, mode } = column;
|
|
56
|
+
// Preallocated setters write through the raw backing properties; eager and
|
|
57
|
+
// lazy setters go through the buffer's public getters (which allocate lazy
|
|
58
|
+
// columns on first access).
|
|
59
|
+
const nullsKey = mode === 'preallocated' ? `_${name}_nulls` : `${name}_nulls`;
|
|
60
|
+
const valuesKey = mode === 'preallocated' ? `_${name}_values` : `${name}_values`;
|
|
61
|
+
const hasNulls = mode !== 'eager';
|
|
62
|
+
const lookupKey = `_${name}_enumLookup`;
|
|
63
|
+
const enumValuesKey = `${name}_enumValues`;
|
|
64
|
+
if (schemaType === 'boolean') {
|
|
65
|
+
if (hasNulls) {
|
|
66
|
+
return function (value) {
|
|
67
|
+
const buf = this._state._buffer;
|
|
68
|
+
const idx = buf._writeIndex - 1;
|
|
69
|
+
const byteIdx = idx >>> 3;
|
|
70
|
+
const bitMask = 1 << (idx & 7);
|
|
71
|
+
bitmapOf(buf[nullsKey])[byteIdx] |= bitMask;
|
|
72
|
+
const values = bitmapOf(buf[valuesKey]);
|
|
73
|
+
if (value)
|
|
74
|
+
values[byteIdx] |= bitMask;
|
|
75
|
+
else
|
|
76
|
+
values[byteIdx] &= ~bitMask;
|
|
77
|
+
return this;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return function (value) {
|
|
81
|
+
const buf = this._state._buffer;
|
|
82
|
+
const idx = buf._writeIndex - 1;
|
|
83
|
+
const byteIdx = idx >>> 3;
|
|
84
|
+
const bitMask = 1 << (idx & 7);
|
|
85
|
+
const values = bitmapOf(buf[valuesKey]);
|
|
86
|
+
if (value)
|
|
87
|
+
values[byteIdx] |= bitMask;
|
|
88
|
+
else
|
|
89
|
+
values[byteIdx] &= ~bitMask;
|
|
90
|
+
return this;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (schemaType === 'enum') {
|
|
94
|
+
// Base enum setter. Reachable only for enum fields absent from
|
|
95
|
+
// enumLookup.ordered (the fluent enum overrides shadow it otherwise) —
|
|
96
|
+
// the compiled class throws there too because its constructor-built
|
|
97
|
+
// `_<name>_enumLookup` Maps were dropped with the state-bound rewrite.
|
|
98
|
+
const makeEnumWrite = (writeNulls) => function (value) {
|
|
99
|
+
const buf = this._state._buffer;
|
|
100
|
+
const idx = buf._writeIndex - 1;
|
|
101
|
+
const lookup = this[lookupKey];
|
|
102
|
+
if (!(lookup instanceof Map)) {
|
|
103
|
+
throw new TypeError(`Enum lookup ${lookupKey} is not initialized (buffer has no enumValues).`);
|
|
104
|
+
}
|
|
105
|
+
const enumIndex = lookup.get(value);
|
|
106
|
+
if (enumIndex === undefined) {
|
|
107
|
+
const enumValues = buf[enumValuesKey];
|
|
108
|
+
throw new Error(`Invalid enum value "${value}" for field "${name}". Valid values: ${Array.isArray(enumValues) ? enumValues.join(', ') : ''}`);
|
|
109
|
+
}
|
|
110
|
+
if (writeNulls)
|
|
111
|
+
bitmapOf(buf[nullsKey])[idx >>> 3] |= 1 << (idx & 7);
|
|
112
|
+
laneOf(buf[valuesKey])[idx] = enumIndex;
|
|
113
|
+
return this;
|
|
114
|
+
};
|
|
115
|
+
return makeEnumWrite(hasNulls);
|
|
116
|
+
}
|
|
117
|
+
if (schemaType === 'binary') {
|
|
118
|
+
// Shallow-freeze binary payload objects (mirrors the compiled binary setter).
|
|
119
|
+
const freezeBinaryValue = (value) => {
|
|
120
|
+
if (typeof value === 'object' && value !== null && !(value instanceof Uint8Array))
|
|
121
|
+
Object.freeze(value);
|
|
122
|
+
};
|
|
123
|
+
if (hasNulls) {
|
|
124
|
+
return function (value) {
|
|
125
|
+
const buf = this._state._buffer;
|
|
126
|
+
const idx = buf._writeIndex - 1;
|
|
127
|
+
freezeBinaryValue(value);
|
|
128
|
+
bitmapOf(buf[nullsKey])[idx >>> 3] |= 1 << (idx & 7);
|
|
129
|
+
laneOf(buf[valuesKey])[idx] = value;
|
|
130
|
+
return this;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return function (value) {
|
|
134
|
+
const buf = this._state._buffer;
|
|
135
|
+
const idx = buf._writeIndex - 1;
|
|
136
|
+
freezeBinaryValue(value);
|
|
137
|
+
laneOf(buf[valuesKey])[idx] = value;
|
|
138
|
+
return this;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (hasNulls) {
|
|
142
|
+
return function (value) {
|
|
143
|
+
const buf = this._state._buffer;
|
|
144
|
+
const idx = buf._writeIndex - 1;
|
|
145
|
+
bitmapOf(buf[nullsKey])[idx >>> 3] |= 1 << (idx & 7);
|
|
146
|
+
laneOf(buf[valuesKey])[idx] = value;
|
|
147
|
+
return this;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return function (value) {
|
|
151
|
+
const buf = this._state._buffer;
|
|
152
|
+
const idx = buf._writeIndex - 1;
|
|
153
|
+
laneOf(buf[valuesKey])[idx] = value;
|
|
154
|
+
return this;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// ============================================================================
|
|
158
|
+
// SpanLogger materializer
|
|
159
|
+
// ============================================================================
|
|
160
|
+
/**
|
|
161
|
+
* Materialize a state-bound SpanLogger class from a plan without string
|
|
162
|
+
* codegen. Same observable behavior as the compiled renderer. Returned as
|
|
163
|
+
* `unknown` to flow through the same constructor type guard as the compiled
|
|
164
|
+
* factory (isSpanLoggerConstructor).
|
|
165
|
+
*/
|
|
166
|
+
export function materializeSpanLoggerClass(plan) {
|
|
167
|
+
const { helpers, enumLookup } = plan;
|
|
168
|
+
const family = plan.messageLayoutFamily;
|
|
169
|
+
const physical = plan.messagePhysicalLayout;
|
|
170
|
+
class GeneratedSpanLogger {
|
|
171
|
+
constructor(state) {
|
|
172
|
+
this._state = state;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const proto = GeneratedSpanLogger.prototype;
|
|
176
|
+
const defineMethod = (name, value) => {
|
|
177
|
+
Object.defineProperty(proto, name, { ...METHOD_DESCRIPTOR, value });
|
|
178
|
+
};
|
|
179
|
+
// --------------------------------------------------------------------------
|
|
180
|
+
// Message writes per layout family / physical layout
|
|
181
|
+
// --------------------------------------------------------------------------
|
|
182
|
+
/** Operational entry (info/warn/error): normalized message + optional fields. */
|
|
183
|
+
const makeOperationalLogMethod = (entryType) => {
|
|
184
|
+
if (family === 'static-only') {
|
|
185
|
+
return function () {
|
|
186
|
+
this._state._appendWriterEntry(entryType);
|
|
187
|
+
throw new TypeError('Dynamic log write reached a static-only callsite plan');
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return function (message, fields) {
|
|
191
|
+
const state = this._state;
|
|
192
|
+
const idx = state._appendWriterEntry(entryType);
|
|
193
|
+
laneOf(state._buffer.message_values)[idx] = helpers.normalizeOperationalTemplate(message);
|
|
194
|
+
if (fields !== undefined) {
|
|
195
|
+
callFluentWith(this, fields);
|
|
196
|
+
}
|
|
197
|
+
return this;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
/** Plain entry (debug/trace): raw message, no fields argument. */
|
|
201
|
+
const makePlainLogMethod = (entryType) => {
|
|
202
|
+
if (family === 'static-only') {
|
|
203
|
+
return function () {
|
|
204
|
+
this._state._appendWriterEntry(entryType);
|
|
205
|
+
throw new TypeError('Dynamic log write reached a static-only callsite plan');
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return function (message) {
|
|
209
|
+
const state = this._state;
|
|
210
|
+
const idx = state._appendWriterEntry(entryType);
|
|
211
|
+
laneOf(state._buffer.message_values)[idx] = message;
|
|
212
|
+
return this;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
/** Static template entry (_infoTemplate & co.) per physical layout. */
|
|
216
|
+
const makeTemplateLogMethod = (entryType) => {
|
|
217
|
+
if (family === 'dynamic-only') {
|
|
218
|
+
return function () {
|
|
219
|
+
this._state._appendWriterEntry(entryType);
|
|
220
|
+
throw new TypeError('Static log write reached a dynamic-only callsite plan');
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
switch (physical) {
|
|
224
|
+
case 'current':
|
|
225
|
+
return function (vocabularyIndex) {
|
|
226
|
+
const state = this._state;
|
|
227
|
+
const idx = state._appendWriterEntry(entryType);
|
|
228
|
+
const localMessageId = state._physicalLayoutPlan.encodeLocalMessage(vocabularyIndex);
|
|
229
|
+
if (localMessageId === 0) {
|
|
230
|
+
laneOf(state._buffer.message_values)[idx] = helpers.decodeVocabularyMessage(state._buffer._vocabularyGeneration, vocabularyIndex);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
laneOf(state._buffer._messageIds)[idx] = localMessageId;
|
|
234
|
+
}
|
|
235
|
+
return this;
|
|
236
|
+
};
|
|
237
|
+
case 'specialized':
|
|
238
|
+
return function (vocabularyIndex) {
|
|
239
|
+
const state = this._state;
|
|
240
|
+
const idx = state._appendWriterEntry(entryType);
|
|
241
|
+
laneOf(state._buffer._logHeaders)[idx] = vocabularyIndex + 1;
|
|
242
|
+
return this;
|
|
243
|
+
};
|
|
244
|
+
case 'packed':
|
|
245
|
+
return function (vocabularyIndex) {
|
|
246
|
+
const state = this._state;
|
|
247
|
+
const idx = state._appendWriterEntry(entryType);
|
|
248
|
+
if (vocabularyIndex > 0x00fffffe)
|
|
249
|
+
throw new RangeError('Packed message dense index exceeds 0xFFFFFE');
|
|
250
|
+
laneOf(state._buffer._rowHeaders)[idx] = (((vocabularyIndex + 1) << 8) | entryType) >>> 0;
|
|
251
|
+
return this;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
/** Row-lane setter for fixed system columns (line, error_code, ...). */
|
|
256
|
+
const makeRowLaneSetter = (valuesKey, nullsKey) => function (value) {
|
|
257
|
+
const buf = this._state._buffer;
|
|
258
|
+
const idx = buf._writeIndex - 1;
|
|
259
|
+
const values = buf[valuesKey];
|
|
260
|
+
if (values) {
|
|
261
|
+
laneOf(values)[idx] = value;
|
|
262
|
+
const nulls = buf[nullsKey];
|
|
263
|
+
if (nulls) {
|
|
264
|
+
helpers.setNullBit(bitmapOf(nulls), idx);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return this;
|
|
268
|
+
};
|
|
269
|
+
// --------------------------------------------------------------------------
|
|
270
|
+
// Prototype assembly — SAME member order as the compiled class body, so
|
|
271
|
+
// name collisions shadow identically (schema setters first, extension
|
|
272
|
+
// methods next, enum fluent overrides last).
|
|
273
|
+
// --------------------------------------------------------------------------
|
|
274
|
+
for (const column of plan.columns) {
|
|
275
|
+
defineMethod(column.name, makeStateBoundSetter(column));
|
|
276
|
+
}
|
|
277
|
+
defineMethod('info', makeOperationalLogMethod(ENTRY_TYPE_INFO));
|
|
278
|
+
defineMethod('_infoTemplate', makeTemplateLogMethod(ENTRY_TYPE_INFO));
|
|
279
|
+
defineMethod('debug', makePlainLogMethod(ENTRY_TYPE_DEBUG));
|
|
280
|
+
defineMethod('_debugTemplate', makeTemplateLogMethod(ENTRY_TYPE_DEBUG));
|
|
281
|
+
defineMethod('warn', makeOperationalLogMethod(ENTRY_TYPE_WARN));
|
|
282
|
+
defineMethod('_warnTemplate', makeTemplateLogMethod(ENTRY_TYPE_WARN));
|
|
283
|
+
defineMethod('error', makeOperationalLogMethod(ENTRY_TYPE_ERROR));
|
|
284
|
+
defineMethod('_errorTemplate', makeTemplateLogMethod(ENTRY_TYPE_ERROR));
|
|
285
|
+
defineMethod('trace', makePlainLogMethod(ENTRY_TYPE_TRACE));
|
|
286
|
+
defineMethod('_traceTemplate', makeTemplateLogMethod(ENTRY_TYPE_TRACE));
|
|
287
|
+
defineMethod('with', function (attributes) {
|
|
288
|
+
for (const key in attributes) {
|
|
289
|
+
const value = attributes[key];
|
|
290
|
+
if (value === null || value === undefined) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const setter = this[key];
|
|
294
|
+
if (typeof setter === 'function') {
|
|
295
|
+
setter.call(this, value);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return this;
|
|
299
|
+
});
|
|
300
|
+
defineMethod('ffAccess', family === 'static-only'
|
|
301
|
+
? function () {
|
|
302
|
+
this._state._appendWriterEntry(ENTRY_TYPE_FF_ACCESS);
|
|
303
|
+
throw new TypeError('Feature flag write reached a static-only callsite plan');
|
|
304
|
+
}
|
|
305
|
+
: function (flagName, value) {
|
|
306
|
+
const state = this._state;
|
|
307
|
+
const idx = state._appendWriterEntry(ENTRY_TYPE_FF_ACCESS);
|
|
308
|
+
laneOf(state._buffer.message_values)[idx] = flagName;
|
|
309
|
+
const ffValues = state._buffer.ff_value_values;
|
|
310
|
+
if (ffValues) {
|
|
311
|
+
const strValue = value === null || value === undefined ? 'null' : String(value);
|
|
312
|
+
laneOf(ffValues)[idx] = strValue;
|
|
313
|
+
const ffNulls = state._buffer.ff_value_nulls;
|
|
314
|
+
if (ffNulls) {
|
|
315
|
+
helpers.setNullBit(bitmapOf(ffNulls), idx);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
defineMethod('ffUsage', family === 'static-only'
|
|
320
|
+
? function () {
|
|
321
|
+
this._state._appendWriterEntry(ENTRY_TYPE_FF_USAGE);
|
|
322
|
+
throw new TypeError('Feature flag write reached a static-only callsite plan');
|
|
323
|
+
}
|
|
324
|
+
: function (flagName, context) {
|
|
325
|
+
const state = this._state;
|
|
326
|
+
const idx = state._appendWriterEntry(ENTRY_TYPE_FF_USAGE);
|
|
327
|
+
laneOf(state._buffer.message_values)[idx] = flagName;
|
|
328
|
+
if (context) {
|
|
329
|
+
callFluentWith(this, context);
|
|
330
|
+
}
|
|
331
|
+
return this;
|
|
332
|
+
});
|
|
333
|
+
defineMethod('line', makeRowLaneSetter('line_values', 'line_nulls'));
|
|
334
|
+
defineMethod('error_code', makeRowLaneSetter('error_code_values', 'error_code_nulls'));
|
|
335
|
+
defineMethod('exception_stack', makeRowLaneSetter('exception_stack_values', 'exception_stack_nulls'));
|
|
336
|
+
defineMethod('ff_value', makeRowLaneSetter('ff_value_values', 'ff_value_nulls'));
|
|
337
|
+
defineMethod('uint64_value', makeRowLaneSetter('uint64_value_values', 'uint64_value_nulls'));
|
|
338
|
+
Object.defineProperty(proto, 'scope', {
|
|
339
|
+
...ACCESSOR_DESCRIPTOR,
|
|
340
|
+
get() {
|
|
341
|
+
return this._state._buffer._scopeValues;
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
defineMethod('_setScope', function (attributes) {
|
|
345
|
+
const buf = this._state._buffer;
|
|
346
|
+
const current = buf._scopeValues || {};
|
|
347
|
+
const next = { ...current };
|
|
348
|
+
for (const key of Object.keys(attributes)) {
|
|
349
|
+
const value = attributes[key];
|
|
350
|
+
if (value === null) {
|
|
351
|
+
delete next[key];
|
|
352
|
+
}
|
|
353
|
+
else if (value !== undefined) {
|
|
354
|
+
next[key] = value;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
buf._scopeValues = Object.freeze(next);
|
|
358
|
+
});
|
|
359
|
+
defineMethod('_prefillScopedAttributesOn', makePrefillScopedAttributes(plan));
|
|
360
|
+
// Fluent enum overrides: convert the declared enum string to its
|
|
361
|
+
// schema-order index (shadow the base enum setters, exactly like the
|
|
362
|
+
// compiled class where they appear last in the class body).
|
|
363
|
+
for (const { fieldName } of enumLookup.ordered) {
|
|
364
|
+
const encode = enumLookup.byField[fieldName].encode;
|
|
365
|
+
defineMethod(fieldName, function (value) {
|
|
366
|
+
const idx = encode(value);
|
|
367
|
+
const buf = this._state._buffer;
|
|
368
|
+
const write = buf[fieldName];
|
|
369
|
+
if (typeof write !== 'function')
|
|
370
|
+
throw new TypeError(`Span buffer has no ${fieldName} setter method`);
|
|
371
|
+
write.call(buf, buf._writeIndex - 1, idx);
|
|
372
|
+
return this;
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return GeneratedSpanLogger;
|
|
376
|
+
}
|
|
377
|
+
function makeColumnPrefill(column, encode, helpers) {
|
|
378
|
+
const { name, schemaType } = column;
|
|
379
|
+
// Binary columns are not scope-fillable (object payloads can't be bulk-filled)
|
|
380
|
+
if (schemaType === 'binary')
|
|
381
|
+
return undefined;
|
|
382
|
+
const rawValuesKey = `_${name}_values`;
|
|
383
|
+
const valuesKey = `${name}_values`;
|
|
384
|
+
const nullsKey = `${name}_nulls`;
|
|
385
|
+
// Boolean uses bit-packed storage - bulk fill using helper
|
|
386
|
+
if (schemaType === 'boolean') {
|
|
387
|
+
return (buffer, startIdx, endIdx) => {
|
|
388
|
+
const scopeValue = buffer._scopeValues?.[name];
|
|
389
|
+
if (scopeValue !== null && scopeValue !== undefined && buffer[rawValuesKey] !== undefined) {
|
|
390
|
+
helpers.fillBooleanBitmapRange(bitmapOf(buffer[valuesKey]), startIdx, endIdx, Boolean(scopeValue));
|
|
391
|
+
helpers.fillNullBitmapRange(bitmapOf(buffer[nullsKey]), startIdx, endIdx);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
// For string arrays (category/text), use manual loop instead of fill()
|
|
396
|
+
if (schemaType === 'category' || schemaType === 'text') {
|
|
397
|
+
return (buffer, startIdx, endIdx) => {
|
|
398
|
+
const scopeValue = buffer._scopeValues?.[name];
|
|
399
|
+
if (scopeValue !== null && scopeValue !== undefined && buffer[rawValuesKey] !== undefined) {
|
|
400
|
+
const values = laneOf(buffer[valuesKey]);
|
|
401
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
402
|
+
values[i] = scopeValue;
|
|
403
|
+
}
|
|
404
|
+
helpers.fillNullBitmapRange(bitmapOf(buffer[nullsKey]), startIdx, endIdx);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
// Enum values are encoded to their schema-order index before filling
|
|
409
|
+
if (schemaType === 'enum' && encode !== undefined) {
|
|
410
|
+
return (buffer, startIdx, endIdx) => {
|
|
411
|
+
const scopeValue = buffer._scopeValues?.[name];
|
|
412
|
+
if (scopeValue !== null && scopeValue !== undefined && buffer[rawValuesKey] !== undefined) {
|
|
413
|
+
fillableOf(buffer[valuesKey]).fill(encode(scopeValue), startIdx, endIdx);
|
|
414
|
+
helpers.fillNullBitmapRange(bitmapOf(buffer[nullsKey]), startIdx, endIdx);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
return (buffer, startIdx, endIdx) => {
|
|
419
|
+
const scopeValue = buffer._scopeValues?.[name];
|
|
420
|
+
if (scopeValue !== null && scopeValue !== undefined && buffer[rawValuesKey] !== undefined) {
|
|
421
|
+
fillableOf(buffer[valuesKey]).fill(scopeValue, startIdx, endIdx);
|
|
422
|
+
helpers.fillNullBitmapRange(bitmapOf(buffer[nullsKey]), startIdx, endIdx);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function makePrefillScopedAttributes(plan) {
|
|
427
|
+
const { helpers, enumLookup } = plan;
|
|
428
|
+
const orderedEnumFields = new Set(enumLookup.ordered.map(({ fieldName }) => fieldName));
|
|
429
|
+
const prefills = [];
|
|
430
|
+
for (const column of plan.columns) {
|
|
431
|
+
const encode = orderedEnumFields.has(column.name) ? enumLookup.byField[column.name].encode : undefined;
|
|
432
|
+
const prefill = makeColumnPrefill(column, encode, helpers);
|
|
433
|
+
if (prefill !== undefined)
|
|
434
|
+
prefills.push(prefill);
|
|
435
|
+
}
|
|
436
|
+
// Initial buffer: rows 0-1 reserved for span-start/end, data starts at _writeIndex=2
|
|
437
|
+
// Overflow buffer: no reserved rows, data starts at _writeIndex=0
|
|
438
|
+
// Use buffer._writeIndex as startIdx to handle both cases correctly
|
|
439
|
+
return (buffer) => {
|
|
440
|
+
const startIdx = buffer._writeIndex;
|
|
441
|
+
const endIdx = buffer._capacity;
|
|
442
|
+
for (let i = 0; i < prefills.length; i++) {
|
|
443
|
+
prefills[i](buffer, startIdx, endIdx);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
//#endregion smoo/lmao!n/codegen-spanlogger.closure
|
|
@@ -15,15 +15,20 @@
|
|
|
15
15
|
*
|
|
16
16
|
* SpanLogger starts with _writeIndex = 1, so first _nextRow() makes it 2.
|
|
17
17
|
*/
|
|
18
|
-
import { type
|
|
18
|
+
import { type SchemaEnumLookupDescriptor } from '../enumMetadata.js';
|
|
19
|
+
import type { MessageLayoutFamily, MessagePhysicalLayout } from '../runtimeHint.js';
|
|
19
20
|
import type { InferSchema, LogSchema } from '../schema/types.js';
|
|
20
|
-
import type { AnySpanBuffer
|
|
21
|
+
import type { AnySpanBuffer } from '../types.js';
|
|
22
|
+
import type { VocabularyGeneration } from '../vocabularyRegistry.js';
|
|
23
|
+
import type { WriterState } from './fixedPositionWriterGenerator.js';
|
|
21
24
|
/**
|
|
22
25
|
* Helper functions injected into generated SpanLogger code.
|
|
23
26
|
* Singleton - same object shared by all generated SpanLogger classes.
|
|
24
27
|
*/
|
|
25
28
|
export declare const SPAN_LOGGER_HELPERS: {
|
|
29
|
+
normalizeOperationalTemplate: (template: string) => string;
|
|
26
30
|
setNullBit: (bitmap: Uint8Array, idx: number) => void;
|
|
31
|
+
decodeVocabularyMessage: (generation: VocabularyGeneration, denseIndex: number) => string;
|
|
27
32
|
fillNullBitmapRange: (bitmap: Uint8Array, startIdx: number, endIdx: number) => void;
|
|
28
33
|
fillBooleanBitmapRange: (bitmap: Uint8Array, startIdx: number, endIdx: number, value: boolean) => void;
|
|
29
34
|
};
|
|
@@ -34,12 +39,17 @@ export declare const SPAN_LOGGER_HELPERS: {
|
|
|
34
39
|
export interface BaseSpanLogger<T extends LogSchema> {
|
|
35
40
|
/** Log info-level message */
|
|
36
41
|
info(message: string): FluentLogEntry<T>;
|
|
42
|
+
info(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
37
43
|
/** Log debug-level message */
|
|
38
44
|
debug(message: string): FluentLogEntry<T>;
|
|
39
45
|
/** Log warning message */
|
|
40
46
|
warn(message: string): FluentLogEntry<T>;
|
|
47
|
+
warn(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
41
48
|
/** Log error message */
|
|
42
49
|
error(message: string): FluentLogEntry<T>;
|
|
50
|
+
error(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
51
|
+
/** Log trace-level message */
|
|
52
|
+
trace(message: string): FluentLogEntry<T>;
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
55
|
* Fluent interface returned by log methods (info, debug, warn, error, trace).
|
|
@@ -63,9 +73,12 @@ export type FluentLogEntry<T extends LogSchema> = {
|
|
|
63
73
|
/** Set uint64 value for this entry */
|
|
64
74
|
uint64_value(value: bigint): FluentLogEntry<T>;
|
|
65
75
|
info(message: string): FluentLogEntry<T>;
|
|
76
|
+
info(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
66
77
|
debug(message: string): FluentLogEntry<T>;
|
|
67
78
|
warn(message: string): FluentLogEntry<T>;
|
|
79
|
+
warn(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
68
80
|
error(message: string): FluentLogEntry<T>;
|
|
81
|
+
error(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
69
82
|
trace(message: string): FluentLogEntry<T>;
|
|
70
83
|
} & {
|
|
71
84
|
[K in keyof InferSchema<T>]: (value: InferSchema<T>[K]) => FluentLogEntry<T>;
|
|
@@ -81,35 +94,39 @@ export type FluentLogEntry<T extends LogSchema> = {
|
|
|
81
94
|
* This is the FULL type returned by createSpanLogger().
|
|
82
95
|
* Users see SpanLogger<T> which hides internal methods.
|
|
83
96
|
*/
|
|
84
|
-
export type SpanLoggerImpl<T extends LogSchema> =
|
|
97
|
+
export type SpanLoggerImpl<T extends LogSchema> = {
|
|
85
98
|
info(message: string): FluentLogEntry<T>;
|
|
99
|
+
info(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
86
100
|
debug(message: string): FluentLogEntry<T>;
|
|
87
101
|
warn(message: string): FluentLogEntry<T>;
|
|
102
|
+
warn(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
88
103
|
error(message: string): FluentLogEntry<T>;
|
|
104
|
+
error(template: string, fields: Partial<InferSchema<T>>): FluentLogEntry<T>;
|
|
89
105
|
trace(message: string): FluentLogEntry<T>;
|
|
106
|
+
_infoTemplate(vocabularyIndex: number): FluentLogEntry<T>;
|
|
107
|
+
_debugTemplate(vocabularyIndex: number): FluentLogEntry<T>;
|
|
108
|
+
_warnTemplate(vocabularyIndex: number): FluentLogEntry<T>;
|
|
109
|
+
_errorTemplate(vocabularyIndex: number): FluentLogEntry<T>;
|
|
110
|
+
_traceTemplate(vocabularyIndex: number): FluentLogEntry<T>;
|
|
90
111
|
readonly scope: Readonly<Record<string, unknown>>;
|
|
91
112
|
_setScope(attributes: ScopeUpdate<T>): void;
|
|
113
|
+
_prefillScopedAttributesOn(buffer: AnySpanBuffer): void;
|
|
114
|
+
} & {
|
|
115
|
+
[K in keyof InferSchema<T>]: (value: InferSchema<T>[K]) => FluentLogEntry<T>;
|
|
92
116
|
};
|
|
117
|
+
export type SpanLoggerConstructor<T extends LogSchema> = new (state: WriterState) => SpanLoggerImpl<T>;
|
|
93
118
|
export type ScopeUpdate<T extends LogSchema> = {
|
|
94
119
|
[K in keyof InferSchema<T>]?: InferSchema<T>[K] | null;
|
|
95
120
|
};
|
|
96
121
|
/**
|
|
97
|
-
* Create SpanLogger
|
|
98
|
-
* This is the cold-path function called at module creation time.
|
|
99
|
-
*
|
|
100
|
-
* SpanLogger extends ColumnWriter and adds:
|
|
101
|
-
* - info(), debug(), warn(), error() methods for log entries
|
|
102
|
-
* - _setScope() for setting scoped attributes
|
|
103
|
-
* - _getNextBuffer() override for SpanBuffer creation on overflow
|
|
104
|
-
*
|
|
105
|
-
* Note: Fluent attribute setters are inherited from ColumnWriter and write at _writeIndex.
|
|
106
|
-
*/
|
|
107
|
-
export declare function createSpanLoggerClass<T extends LogSchema>(schema: T): new (buffer: AnySpanBuffer) => SpanLoggerImpl<T>;
|
|
108
|
-
/**
|
|
109
|
-
* Create a SpanLogger instance for the given buffer.
|
|
122
|
+
* Create the state-only SpanLogger constructor selected for one schema/layout family.
|
|
110
123
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
124
|
+
* Selects the materializer via activeMaterializerMode(): the compiled renderer
|
|
125
|
+
* (string codegen) where `new Function` is allowed, the closure-composed
|
|
126
|
+
* materializer where it is forbidden (e.g. workerd). Cache keys are
|
|
127
|
+
* mode-prefixed so a forced override never returns the other mode's class.
|
|
113
128
|
*/
|
|
114
|
-
export declare function
|
|
129
|
+
export declare function createSpanLoggerClass<T extends LogSchema>(schema: T, messageLayoutFamily?: MessageLayoutFamily, messagePhysicalLayout?: MessagePhysicalLayout, eagerColumns?: readonly string[], enumLookup?: SchemaEnumLookupDescriptor): SpanLoggerConstructor<T>;
|
|
130
|
+
/** Create a SpanLogger bound to an existing SpanContext writer state. */
|
|
131
|
+
export declare function createSpanLogger<T extends LogSchema>(schema: T, state: WriterState): SpanLoggerImpl<T>;
|
|
115
132
|
//# sourceMappingURL=spanLoggerGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spanLoggerGenerator.d.ts","sourceRoot":"","sources":["../../../src/lib/codegen/spanLoggerGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"spanLoggerGenerator.d.ts","sourceRoot":"","sources":["../../../src/lib/codegen/spanLoggerGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;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