@telorun/kernel 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller-loader.d.ts +6 -1
- package/dist/controller-loader.d.ts.map +1 -1
- package/dist/controller-loader.js +2 -0
- package/dist/controller-loader.js.map +1 -1
- package/dist/controller-loaders/bundle-builder.d.ts +2 -1
- package/dist/controller-loaders/bundle-builder.d.ts.map +1 -1
- package/dist/controller-loaders/bundle-builder.js +14 -9
- package/dist/controller-loaders/bundle-builder.js.map +1 -1
- package/dist/controller-loaders/npm-loader.d.ts +8 -2
- package/dist/controller-loaders/npm-loader.d.ts.map +1 -1
- package/dist/controller-loaders/npm-loader.js +19 -10
- package/dist/controller-loaders/npm-loader.js.map +1 -1
- package/dist/controllers/logging/console-sink-controller.d.ts +15 -0
- package/dist/controllers/logging/console-sink-controller.d.ts.map +1 -0
- package/dist/controllers/logging/console-sink-controller.js +40 -0
- package/dist/controllers/logging/console-sink-controller.js.map +1 -0
- package/dist/controllers/logging/file-sink-controller.d.ts +11 -0
- package/dist/controllers/logging/file-sink-controller.d.ts.map +1 -0
- package/dist/controllers/logging/file-sink-controller.js +33 -0
- package/dist/controllers/logging/file-sink-controller.js.map +1 -0
- package/dist/controllers/logging/sink-identity.d.ts +37 -0
- package/dist/controllers/logging/sink-identity.d.ts.map +1 -0
- package/dist/controllers/logging/sink-identity.js +40 -0
- package/dist/controllers/logging/sink-identity.js.map +1 -0
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +25 -0
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js +1 -0
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/evaluation-context.d.ts +27 -1
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/evaluation-context.js +84 -16
- package/dist/evaluation-context.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal-context.d.ts +4 -0
- package/dist/internal-context.d.ts.map +1 -1
- package/dist/kernel.d.ts +26 -0
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +78 -5
- package/dist/kernel.js.map +1 -1
- package/dist/logging/bootstrap-writer.d.ts +23 -0
- package/dist/logging/bootstrap-writer.d.ts.map +1 -0
- package/dist/logging/bootstrap-writer.js +31 -0
- package/dist/logging/bootstrap-writer.js.map +1 -0
- package/dist/logging/color-precedence.d.ts +27 -0
- package/dist/logging/color-precedence.d.ts.map +1 -0
- package/dist/logging/color-precedence.js +47 -0
- package/dist/logging/color-precedence.js.map +1 -0
- package/dist/logging/console-sink.d.ts +45 -0
- package/dist/logging/console-sink.d.ts.map +1 -0
- package/dist/logging/console-sink.js +56 -0
- package/dist/logging/console-sink.js.map +1 -0
- package/dist/logging/debug-wire-sink.d.ts +38 -0
- package/dist/logging/debug-wire-sink.d.ts.map +1 -0
- package/dist/logging/debug-wire-sink.js +85 -0
- package/dist/logging/debug-wire-sink.js.map +1 -0
- package/dist/logging/drop-accounting.d.ts +34 -0
- package/dist/logging/drop-accounting.d.ts.map +1 -0
- package/dist/logging/drop-accounting.js +98 -0
- package/dist/logging/drop-accounting.js.map +1 -0
- package/dist/logging/encode-json.d.ts +28 -0
- package/dist/logging/encode-json.d.ts.map +1 -0
- package/dist/logging/encode-json.js +86 -0
- package/dist/logging/encode-json.js.map +1 -0
- package/dist/logging/encode-pretty.d.ts +7 -0
- package/dist/logging/encode-pretty.d.ts.map +1 -0
- package/dist/logging/encode-pretty.js +104 -0
- package/dist/logging/encode-pretty.js.map +1 -0
- package/dist/logging/file-sink.d.ts +33 -0
- package/dist/logging/file-sink.d.ts.map +1 -0
- package/dist/logging/file-sink.js +72 -0
- package/dist/logging/file-sink.js.map +1 -0
- package/dist/logging/index.d.ts +39 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +27 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/kernel-logging.d.ts +110 -0
- package/dist/logging/kernel-logging.d.ts.map +1 -0
- package/dist/logging/kernel-logging.js +199 -0
- package/dist/logging/kernel-logging.js.map +1 -0
- package/dist/logging/log-sink.d.ts +9 -0
- package/dist/logging/log-sink.d.ts.map +1 -0
- package/dist/logging/log-sink.js +8 -0
- package/dist/logging/log-sink.js.map +1 -0
- package/dist/logging/logging-host.d.ts +14 -0
- package/dist/logging/logging-host.d.ts.map +1 -0
- package/dist/logging/logging-host.js +27 -0
- package/dist/logging/logging-host.js.map +1 -0
- package/dist/logging/logging-pipeline.d.ts +89 -0
- package/dist/logging/logging-pipeline.d.ts.map +1 -0
- package/dist/logging/logging-pipeline.js +349 -0
- package/dist/logging/logging-pipeline.js.map +1 -0
- package/dist/logging/normalize-attributes.d.ts +48 -0
- package/dist/logging/normalize-attributes.d.ts.map +1 -0
- package/dist/logging/normalize-attributes.js +140 -0
- package/dist/logging/normalize-attributes.js.map +1 -0
- package/dist/logging/record-buffer.d.ts +24 -0
- package/dist/logging/record-buffer.d.ts.map +1 -0
- package/dist/logging/record-buffer.js +78 -0
- package/dist/logging/record-buffer.js.map +1 -0
- package/dist/logging/redact-attributes.d.ts +45 -0
- package/dist/logging/redact-attributes.d.ts.map +1 -0
- package/dist/logging/redact-attributes.js +152 -0
- package/dist/logging/redact-attributes.js.map +1 -0
- package/dist/logging/sampler.d.ts +34 -0
- package/dist/logging/sampler.d.ts.map +1 -0
- package/dist/logging/sampler.js +52 -0
- package/dist/logging/sampler.js.map +1 -0
- package/dist/logging/scope-config.d.ts +32 -0
- package/dist/logging/scope-config.d.ts.map +1 -0
- package/dist/logging/scope-config.js +2 -0
- package/dist/logging/scope-config.js.map +1 -0
- package/dist/logging/span-id.d.ts +24 -0
- package/dist/logging/span-id.d.ts.map +1 -0
- package/dist/logging/span-id.js +85 -0
- package/dist/logging/span-id.js.map +1 -0
- package/dist/logging/to-error-value.d.ts +3 -0
- package/dist/logging/to-error-value.d.ts.map +1 -0
- package/dist/logging/to-error-value.js +79 -0
- package/dist/logging/to-error-value.js.map +1 -0
- package/dist/logging/trace-parent.d.ts +54 -0
- package/dist/logging/trace-parent.d.ts.map +1 -0
- package/dist/logging/trace-parent.js +92 -0
- package/dist/logging/trace-parent.js.map +1 -0
- package/dist/manifest-schemas.d.ts +1 -1
- package/dist/manifest-schemas.d.ts.map +1 -1
- package/dist/manifest-schemas.js +12 -0
- package/dist/manifest-schemas.js.map +1 -1
- package/dist/module-context.d.ts +16 -0
- package/dist/module-context.d.ts.map +1 -1
- package/dist/module-context.js +6 -0
- package/dist/module-context.js.map +1 -1
- package/dist/resource-context.d.ts +15 -1
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +45 -0
- package/dist/resource-context.js.map +1 -1
- package/dist/schema-compiled-values.d.ts.map +1 -1
- package/dist/schema-compiled-values.js +7 -0
- package/dist/schema-compiled-values.js.map +1 -1
- package/dist/schema-validator.d.ts +8 -1
- package/dist/schema-validator.d.ts.map +1 -1
- package/dist/schema-validator.js +13 -3
- package/dist/schema-validator.js.map +1 -1
- package/package.json +3 -3
- package/src/controller-loader.ts +7 -1
- package/src/controller-loaders/bundle-builder.ts +18 -10
- package/src/controller-loaders/npm-loader.ts +32 -11
- package/src/controllers/logging/console-sink-controller.ts +46 -0
- package/src/controllers/logging/file-sink-controller.ts +40 -0
- package/src/controllers/logging/sink-identity.ts +53 -0
- package/src/controllers/module/import-controller.ts +27 -0
- package/src/controllers/resource-definition/resource-definition-controller.ts +1 -0
- package/src/evaluation-context.ts +93 -15
- package/src/index.ts +54 -0
- package/src/internal-context.ts +4 -0
- package/src/kernel.ts +98 -8
- package/src/logging/bootstrap-writer.ts +38 -0
- package/src/logging/color-precedence.ts +62 -0
- package/src/logging/console-sink.ts +86 -0
- package/src/logging/debug-wire-sink.ts +85 -0
- package/src/logging/drop-accounting.ts +108 -0
- package/src/logging/encode-json.ts +98 -0
- package/src/logging/encode-pretty.ts +117 -0
- package/src/logging/file-sink.ts +87 -0
- package/src/logging/index.ts +65 -0
- package/src/logging/kernel-logging.ts +266 -0
- package/src/logging/log-sink.ts +18 -0
- package/src/logging/logging-host.ts +33 -0
- package/src/logging/logging-pipeline.ts +465 -0
- package/src/logging/normalize-attributes.ts +228 -0
- package/src/logging/record-buffer.ts +72 -0
- package/src/logging/redact-attributes.ts +168 -0
- package/src/logging/sampler.ts +76 -0
- package/src/logging/scope-config.ts +32 -0
- package/src/logging/span-id.ts +84 -0
- package/src/logging/to-error-value.ts +89 -0
- package/src/logging/trace-parent.ts +110 -0
- package/src/manifest-schemas.ts +12 -0
- package/src/module-context.ts +23 -0
- package/src/resource-context.ts +48 -0
- package/src/schema-compiled-values.ts +6 -0
- package/src/schema-validator.ts +20 -5
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _FileSink_buffer, _FileSink_encode, _FileSink_fd, _FileSink_timer, _FileSink_closed;
|
|
13
|
+
import { closeSync, openSync, writeSync } from "node:fs";
|
|
14
|
+
import { encodeJsonLine } from "./encode-json.js";
|
|
15
|
+
import { encodePrettyLine } from "./encode-pretty.js";
|
|
16
|
+
import { DEFAULT_BUFFER_POLICY } from "./log-sink.js";
|
|
17
|
+
import { RecordBuffer } from "./record-buffer.js";
|
|
18
|
+
export class FileSink {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.syncFlushable = true;
|
|
21
|
+
_FileSink_buffer.set(this, void 0);
|
|
22
|
+
_FileSink_encode.set(this, void 0);
|
|
23
|
+
_FileSink_fd.set(this, void 0);
|
|
24
|
+
_FileSink_timer.set(this, void 0);
|
|
25
|
+
_FileSink_closed.set(this, false);
|
|
26
|
+
this.sinkId = options.sinkId;
|
|
27
|
+
this.level = options.level;
|
|
28
|
+
const policy = options.policy ?? DEFAULT_BUFFER_POLICY;
|
|
29
|
+
__classPrivateFieldSet(this, _FileSink_buffer, new RecordBuffer(policy, options.onDrop), "f");
|
|
30
|
+
const encoding = options.encoding ?? "json";
|
|
31
|
+
__classPrivateFieldSet(this, _FileSink_encode, encoding === "pretty"
|
|
32
|
+
? (record) => encodePrettyLine(record, { color: false })
|
|
33
|
+
: (record) => encodeJsonLine(record, { encodeBytes: options.encodeBytes }), "f");
|
|
34
|
+
__classPrivateFieldSet(this, _FileSink_fd, openSync(options.destination, "a"), "f");
|
|
35
|
+
__classPrivateFieldSet(this, _FileSink_timer, setInterval(() => this.flushSync(), policy.flushIntervalMs), "f");
|
|
36
|
+
// A pending flush tick must never be the reason a process stays alive; the
|
|
37
|
+
// shutdown flush is what guarantees the tail is written.
|
|
38
|
+
__classPrivateFieldGet(this, _FileSink_timer, "f").unref?.();
|
|
39
|
+
}
|
|
40
|
+
write(record) {
|
|
41
|
+
if (__classPrivateFieldGet(this, _FileSink_closed, "f"))
|
|
42
|
+
return;
|
|
43
|
+
__classPrivateFieldGet(this, _FileSink_buffer, "f").push(record);
|
|
44
|
+
}
|
|
45
|
+
async flush() {
|
|
46
|
+
this.flushSync();
|
|
47
|
+
}
|
|
48
|
+
flushSync() {
|
|
49
|
+
if (__classPrivateFieldGet(this, _FileSink_closed, "f"))
|
|
50
|
+
return;
|
|
51
|
+
const records = __classPrivateFieldGet(this, _FileSink_buffer, "f").drain();
|
|
52
|
+
if (records.length === 0)
|
|
53
|
+
return;
|
|
54
|
+
let payload = "";
|
|
55
|
+
for (const record of records)
|
|
56
|
+
payload += __classPrivateFieldGet(this, _FileSink_encode, "f").call(this, record);
|
|
57
|
+
writeSync(__classPrivateFieldGet(this, _FileSink_fd, "f"), payload);
|
|
58
|
+
}
|
|
59
|
+
async close() {
|
|
60
|
+
if (__classPrivateFieldGet(this, _FileSink_closed, "f"))
|
|
61
|
+
return;
|
|
62
|
+
this.flushSync();
|
|
63
|
+
__classPrivateFieldSet(this, _FileSink_closed, true, "f");
|
|
64
|
+
if (__classPrivateFieldGet(this, _FileSink_timer, "f")) {
|
|
65
|
+
clearInterval(__classPrivateFieldGet(this, _FileSink_timer, "f"));
|
|
66
|
+
__classPrivateFieldSet(this, _FileSink_timer, undefined, "f");
|
|
67
|
+
}
|
|
68
|
+
closeSync(__classPrivateFieldGet(this, _FileSink_fd, "f"));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
_FileSink_buffer = new WeakMap(), _FileSink_encode = new WeakMap(), _FileSink_fd = new WeakMap(), _FileSink_timer = new WeakMap(), _FileSink_closed = new WeakMap();
|
|
72
|
+
//# sourceMappingURL=file-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-sink.js","sourceRoot":"","sources":["../../src/logging/file-sink.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAqB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,gBAAgB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AK,CAAC,MAAiB;QACrB,IAAI,uBAAA,IAAI,wBAAQ;YAAE,OAAO;QACzB,uBAAA,IAAI,wBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,SAAS;QACP,IAAI,uBAAA,IAAI,wBAAQ;YAAE,OAAO;QACzB,MAAM,OAAO,GAAG,uBAAA,IAAI,wBAAQ,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACjC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,OAAO,IAAI,uBAAA,IAAI,wBAAQ,MAAZ,IAAI,EAAS,MAAM,CAAC,CAAC;QAC9D,SAAS,CAAC,uBAAA,IAAI,oBAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,uBAAA,IAAI,wBAAQ;YAAE,OAAO;QACzB,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,uBAAA,IAAI,oBAAW,IAAI,MAAA,CAAC;QACpB,IAAI,uBAAA,IAAI,uBAAO,EAAE,CAAC;YAChB,aAAa,CAAC,uBAAA,IAAI,uBAAO,CAAC,CAAC;YAC3B,uBAAA,IAAI,mBAAU,SAAS,MAAA,CAAC;QAC1B,CAAC;QACD,SAAS,CAAC,uBAAA,IAAI,oBAAI,CAAC,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging — the Node.js implementation of `kernel/specs/logging.md`.
|
|
3
|
+
*
|
|
4
|
+
* The record model, severity scale, and `Logger` surface live in `@telorun/sdk`
|
|
5
|
+
* because module authors consume them; everything here is the runtime half —
|
|
6
|
+
* the pipeline, the encodings, the sinks, and the policies that gate emission.
|
|
7
|
+
* The redaction path grammar lives in `@telorun/analyzer` so `telo check` and
|
|
8
|
+
* the runtime share one parser rather than two that can drift.
|
|
9
|
+
*/
|
|
10
|
+
export { BOOTSTRAP_SINK_ID, createBootstrapWriter } from "./bootstrap-writer.js";
|
|
11
|
+
export { decideColor } from "./color-precedence.js";
|
|
12
|
+
export type { ColorDecisionInput, ColorSetting } from "./color-precedence.js";
|
|
13
|
+
export { ConsoleSink } from "./console-sink.js";
|
|
14
|
+
export { DEBUG_WIRE_SINK_ID, DebugWireSink } from "./debug-wire-sink.js";
|
|
15
|
+
export type { ConsoleDestination, ConsoleEncoding, ConsoleSinkOptions } from "./console-sink.js";
|
|
16
|
+
export { DropRegistry, PIPELINE_SINK_ID } from "./drop-accounting.js";
|
|
17
|
+
export type { DropReport } from "./drop-accounting.js";
|
|
18
|
+
export { base64Bytes, encodeJson, encodeJsonLine, toJsonProfile } from "./encode-json.js";
|
|
19
|
+
export type { BytesEncoder, JsonEncodeOptions } from "./encode-json.js";
|
|
20
|
+
export { encodePretty, encodePrettyLine } from "./encode-pretty.js";
|
|
21
|
+
export type { PrettyEncodeOptions } from "./encode-pretty.js";
|
|
22
|
+
export { FileSink } from "./file-sink.js";
|
|
23
|
+
export type { FileEncoding, FileSinkOptions } from "./file-sink.js";
|
|
24
|
+
export { BLOCK_UNSUPPORTED, blockUnsupportedMessage, DEFAULT_BUFFER_POLICY, } from "./log-sink.js";
|
|
25
|
+
export type { DropCause, LogSinkInstance, OnFull, SinkBufferPolicy } from "./log-sink.js";
|
|
26
|
+
export { LoggingPipeline, ROOT_SCOPE_CONFIG } from "./logging-pipeline.js";
|
|
27
|
+
export type { PipelineOptions, ScopeConfig, TraceContextProvider } from "./logging-pipeline.js";
|
|
28
|
+
export { DEFAULT_ATTRIBUTE_LIMITS, normalizeAttributes, } from "./normalize-attributes.js";
|
|
29
|
+
export type { AttributeLimits, NormalizedAttributes, NormalizeOptions } from "./normalize-attributes.js";
|
|
30
|
+
export { compileRedactionPolicy, DEFAULT_CENSOR, EMPTY_REDACTION_POLICY, redactAttributes, redactError, } from "./redact-attributes.js";
|
|
31
|
+
export type { CompiledRedactionPath, RedactionPolicy } from "./redact-attributes.js";
|
|
32
|
+
export { RecordBuffer } from "./record-buffer.js";
|
|
33
|
+
export { Sampler } from "./sampler.js";
|
|
34
|
+
export type { SamplingConfig } from "./sampler.js";
|
|
35
|
+
export { formatSpanCounter, formatSpanId, newTraceId, normalizeSpanId, normalizeTraceId, saltSpanId, } from "./span-id.js";
|
|
36
|
+
export { toErrorValue } from "./to-error-value.js";
|
|
37
|
+
export { formatTraceParent, parseTraceParent, parseTraceState, TRACE_FLAG_RANDOM, TRACE_FLAG_SAMPLED, } from "./trace-parent.js";
|
|
38
|
+
export type { TraceContext } from "./trace-parent.js";
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1F,YA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EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging — the Node.js implementation of `kernel/specs/logging.md`.
|
|
3
|
+
*
|
|
4
|
+
* The record model, severity scale, and `Logger` surface live in `@telorun/sdk`
|
|
5
|
+
* because module authors consume them; everything here is the runtime half —
|
|
6
|
+
* the pipeline, the encodings, the sinks, and the policies that gate emission.
|
|
7
|
+
* The redaction path grammar lives in `@telorun/analyzer` so `telo check` and
|
|
8
|
+
* the runtime share one parser rather than two that can drift.
|
|
9
|
+
*/
|
|
10
|
+
export { BOOTSTRAP_SINK_ID, createBootstrapWriter } from "./bootstrap-writer.js";
|
|
11
|
+
export { decideColor } from "./color-precedence.js";
|
|
12
|
+
export { ConsoleSink } from "./console-sink.js";
|
|
13
|
+
export { DEBUG_WIRE_SINK_ID, DebugWireSink } from "./debug-wire-sink.js";
|
|
14
|
+
export { DropRegistry, PIPELINE_SINK_ID } from "./drop-accounting.js";
|
|
15
|
+
export { base64Bytes, encodeJson, encodeJsonLine, toJsonProfile } from "./encode-json.js";
|
|
16
|
+
export { encodePretty, encodePrettyLine } from "./encode-pretty.js";
|
|
17
|
+
export { FileSink } from "./file-sink.js";
|
|
18
|
+
export { BLOCK_UNSUPPORTED, blockUnsupportedMessage, DEFAULT_BUFFER_POLICY, } from "./log-sink.js";
|
|
19
|
+
export { LoggingPipeline, ROOT_SCOPE_CONFIG } from "./logging-pipeline.js";
|
|
20
|
+
export { DEFAULT_ATTRIBUTE_LIMITS, normalizeAttributes, } from "./normalize-attributes.js";
|
|
21
|
+
export { compileRedactionPolicy, DEFAULT_CENSOR, EMPTY_REDACTION_POLICY, redactAttributes, redactError, } from "./redact-attributes.js";
|
|
22
|
+
export { RecordBuffer } from "./record-buffer.js";
|
|
23
|
+
export { Sampler } from "./sampler.js";
|
|
24
|
+
export { formatSpanCounter, formatSpanId, newTraceId, normalizeSpanId, normalizeTraceId, saltSpanId, } from "./span-id.js";
|
|
25
|
+
export { toErrorValue } from "./to-error-value.js";
|
|
26
|
+
export { formatTraceParent, parseTraceParent, parseTraceState, TRACE_FLAG_RANDOM, TRACE_FLAG_SAMPLED, } from "./trace-parent.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type LogAttributes, type Logger, type ResourceRef } from "@telorun/sdk";
|
|
2
|
+
import type { DropCause } from "./log-sink.js";
|
|
3
|
+
import { type LoggingHost } from "./logging-host.js";
|
|
4
|
+
import { LoggingPipeline, type ScopeConfig, type TraceContextProvider } from "./logging-pipeline.js";
|
|
5
|
+
/**
|
|
6
|
+
* The kernel's ownership of the logging pipeline — `kernel/specs/logging.md`
|
|
7
|
+
* §12.
|
|
8
|
+
*
|
|
9
|
+
* Sequencing is the whole job here. An internal console writer covers process
|
|
10
|
+
* start through manifest validation, because declared sinks cannot instantiate
|
|
11
|
+
* before the block that declares them has been validated. Once the manifest
|
|
12
|
+
* resolves, the declared configuration takes over: eager sinks attach, buffered
|
|
13
|
+
* records replay, and the bootstrap writer steps aside.
|
|
14
|
+
*/
|
|
15
|
+
/** The raw `logging:` block as authored, after CEL evaluation. */
|
|
16
|
+
export interface LoggingManifestBlock {
|
|
17
|
+
level?: string;
|
|
18
|
+
attributes?: LogAttributes;
|
|
19
|
+
redact?: {
|
|
20
|
+
paths?: string[];
|
|
21
|
+
censor?: string;
|
|
22
|
+
remove?: boolean;
|
|
23
|
+
};
|
|
24
|
+
sampling?: {
|
|
25
|
+
first?: number;
|
|
26
|
+
thereafter?: number;
|
|
27
|
+
tick?: string;
|
|
28
|
+
sampleErrors?: boolean;
|
|
29
|
+
};
|
|
30
|
+
sinks?: unknown[];
|
|
31
|
+
}
|
|
32
|
+
/** The module-context tree as far as logging is concerned — just enough to walk
|
|
33
|
+
* children and read each one's resolved scope config, declared structurally so
|
|
34
|
+
* this file stays independent of the concrete `ModuleContext`. */
|
|
35
|
+
export interface LoggingContextNode {
|
|
36
|
+
readonly children?: readonly LoggingContextNode[];
|
|
37
|
+
getLoggingConfig?(): ScopeConfig | undefined;
|
|
38
|
+
}
|
|
39
|
+
export declare class KernelLogging {
|
|
40
|
+
#private;
|
|
41
|
+
readonly pipeline: LoggingPipeline;
|
|
42
|
+
readonly host: LoggingHost;
|
|
43
|
+
constructor(options: {
|
|
44
|
+
env: Record<string, string | undefined>;
|
|
45
|
+
stdout: NodeJS.WritableStream;
|
|
46
|
+
stderr: NodeJS.WritableStream;
|
|
47
|
+
/** The process's real stderr — §8.4's fallback diagnostic stream. Kept
|
|
48
|
+
* distinct from the kernel's injectable `stderr` so a captured stream can
|
|
49
|
+
* never swallow the report that the capture itself failed. */
|
|
50
|
+
fallbackStream?: {
|
|
51
|
+
write(chunk: string): unknown;
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
get rootScope(): ScopeConfig;
|
|
55
|
+
setTraceContextProvider(provider: TraceContextProvider | undefined): void;
|
|
56
|
+
recordDrop(sinkId: string, cause: DropCause, count?: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Adopt the manifest's declared configuration. Called as soon as the
|
|
59
|
+
* `logging:` block has been validated — after that point the bootstrap default
|
|
60
|
+
* is no longer in force.
|
|
61
|
+
*/
|
|
62
|
+
applyRootConfig(block: LoggingManifestBlock | undefined, secretValues?: ReadonlySet<string>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Detach the bootstrap writer and stop holding records for replay. Called once
|
|
65
|
+
* every declared sink has attached: the buffer exists to cover the pre-attach
|
|
66
|
+
* window, and a consumer connecting later (the debug wire) wants the live
|
|
67
|
+
* stream rather than the whole process history.
|
|
68
|
+
*
|
|
69
|
+
* When the manifest declares no sinks at all, the runtime behaves exactly as
|
|
70
|
+
* if a single `Telo.ConsoleSink` were declared — "pretty logs on stderr in a
|
|
71
|
+
* terminal, JSON when piped", with no imports.
|
|
72
|
+
*
|
|
73
|
+
* That equivalence is why the bootstrap writer is *replaced* here rather than
|
|
74
|
+
* promoted in place. The bootstrap writer is pinned at `info` (§12.3), but a
|
|
75
|
+
* declared `Telo.ConsoleSink` with no explicit `level:` takes the resolved
|
|
76
|
+
* scope threshold — so promoting the fixed-`info` writer would silently ignore
|
|
77
|
+
* a root `logging.level`, in both directions (a `debug` never lowers the gate,
|
|
78
|
+
* a `warn` never raises it). The fresh sink is built at the resolved threshold,
|
|
79
|
+
* so `logging: { level: debug }` with no `sinks:` behaves as documented.
|
|
80
|
+
*/
|
|
81
|
+
sealBootstrap(manifests: readonly {
|
|
82
|
+
kind?: string;
|
|
83
|
+
}[]): void;
|
|
84
|
+
/** A logger scoped to a module context, stamped with a resource identity. */
|
|
85
|
+
createLogger(scope: ScopeConfig | undefined, resource?: ResourceRef): Logger;
|
|
86
|
+
/**
|
|
87
|
+
* Every module context's resolved logging configuration, keyed by its dotted
|
|
88
|
+
* import-alias path (`Api.Domain.Db`); the root is keyed `""`.
|
|
89
|
+
*
|
|
90
|
+
* This closes §12.2's loop between reading and configuring: the `scope` on a
|
|
91
|
+
* log line is exactly the path you write in the manifest to change that
|
|
92
|
+
* instance's level, and this answers "what level did that path actually
|
|
93
|
+
* resolve to" without re-deriving the cascade by hand. The tree walk is
|
|
94
|
+
* logging logic, so it lives here rather than on the orchestrator.
|
|
95
|
+
*/
|
|
96
|
+
scopesFrom(rootContext: LoggingContextNode | undefined): Map<string, ScopeConfig>;
|
|
97
|
+
/** The kernel's own logger — used for diagnostics the kernel emits about
|
|
98
|
+
* itself, which §13.1 requires to go through this pipeline rather than to
|
|
99
|
+
* `process.stderr` or `console.*`. */
|
|
100
|
+
kernelLogger(): Logger;
|
|
101
|
+
shutdown(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Merge a `logging:` block over an inherited configuration. Config cascades and
|
|
105
|
+
* may be narrowed at each hop, which is what makes a dependency you do not own
|
|
106
|
+
* diagnosable — raising `Api`'s level lifts everything beneath it without
|
|
107
|
+
* editing `Api`'s manifest (§12.2).
|
|
108
|
+
*/
|
|
109
|
+
export declare function buildScopeConfig(block: LoggingManifestBlock | undefined, inherited: ScopeConfig): ScopeConfig;
|
|
110
|
+
//# sourceMappingURL=kernel-logging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel-logging.d.ts","sourceRoot":"","sources":["../../src/logging/kernel-logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGrG;;;;;;;;;GASG;AAEH,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACjE,QAAQ,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC1F,KAAK,CAAC,EAAE,OAAO,EAAE,C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E,WAAW,CAAC;IAcjF;;2CAEuC;IACvC,YAAY,IAAI,MAAM;IAIhB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,oBAAoB,GAAG,SAAS,EACvC,SAAS,EAAE,WAAW,GACrB,WAAW,CAoBb"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _KernelLogging_rootScope, _KernelLogging_bootstrap, _KernelLogging_sealed, _KernelLogging_streams;
|
|
13
|
+
import { parseLevelName, SEVERITY, } from "@telorun/sdk";
|
|
14
|
+
import { BOOTSTRAP_SINK_ID, createBootstrapWriter } from "./bootstrap-writer.js";
|
|
15
|
+
import { ConsoleSink } from "./console-sink.js";
|
|
16
|
+
import { compileRedactionPolicy, EMPTY_REDACTION_POLICY } from "./redact-attributes.js";
|
|
17
|
+
import { createLoggingHost } from "./logging-host.js";
|
|
18
|
+
import { LoggingPipeline } from "./logging-pipeline.js";
|
|
19
|
+
const DEFAULT_SAMPLING_TICK_MS = 1000;
|
|
20
|
+
/** How many sinks the root Application declared. Zero means the runtime behaves
|
|
21
|
+
* exactly as if a single `Telo.ConsoleSink` were declared (§12.1), which is why
|
|
22
|
+
* the bootstrap writer is replaced by a threshold-aware one rather than left as
|
|
23
|
+
* the fixed-`info` writer. */
|
|
24
|
+
function declaredSinkCount(manifests) {
|
|
25
|
+
const root = manifests.find((m) => m.kind === "Telo.Application");
|
|
26
|
+
return root?.logging?.sinks?.length ?? 0;
|
|
27
|
+
}
|
|
28
|
+
export class KernelLogging {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
_KernelLogging_rootScope.set(this, void 0);
|
|
31
|
+
_KernelLogging_bootstrap.set(this, void 0);
|
|
32
|
+
_KernelLogging_sealed.set(this, false);
|
|
33
|
+
/** Kept so the zero-config console sink can be rebuilt at the resolved
|
|
34
|
+
* threshold once the manifest is known (see {@link sealBootstrap}). */
|
|
35
|
+
_KernelLogging_streams.set(this, void 0);
|
|
36
|
+
__classPrivateFieldSet(this, _KernelLogging_streams, { env: options.env, stdout: options.stdout, stderr: options.stderr }, "f");
|
|
37
|
+
this.pipeline = new LoggingPipeline({
|
|
38
|
+
fallbackStream: options.fallbackStream ?? {
|
|
39
|
+
write: (chunk) => process.stderr.write(chunk),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
// §12.3: a fixed default of `info` until the manifest resolves. This phase
|
|
43
|
+
// is the only one not manifest-governed, and it is deliberately not
|
|
44
|
+
// configurable by any other means.
|
|
45
|
+
__classPrivateFieldSet(this, _KernelLogging_rootScope, {
|
|
46
|
+
threshold: SEVERITY.info,
|
|
47
|
+
redaction: EMPTY_REDACTION_POLICY,
|
|
48
|
+
}, "f");
|
|
49
|
+
__classPrivateFieldSet(this, _KernelLogging_bootstrap, createBootstrapWriter(options), "f");
|
|
50
|
+
this.pipeline.attach(__classPrivateFieldGet(this, _KernelLogging_bootstrap, "f"));
|
|
51
|
+
this.host = createLoggingHost(this.pipeline, () => __classPrivateFieldGet(this, _KernelLogging_rootScope, "f").threshold, (sinkId, cause, count) => this.recordDrop(sinkId, cause, count));
|
|
52
|
+
}
|
|
53
|
+
get rootScope() {
|
|
54
|
+
return __classPrivateFieldGet(this, _KernelLogging_rootScope, "f");
|
|
55
|
+
}
|
|
56
|
+
setTraceContextProvider(provider) {
|
|
57
|
+
this.pipeline.setTraceContextProvider(provider);
|
|
58
|
+
}
|
|
59
|
+
recordDrop(sinkId, cause, count = 1) {
|
|
60
|
+
// Routed through the pipeline so the recovery warning §10.4 requires is
|
|
61
|
+
// emitted as an ordinary record and reaches every sink.
|
|
62
|
+
this.pipeline.recordDrop(sinkId, cause, count);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adopt the manifest's declared configuration. Called as soon as the
|
|
66
|
+
* `logging:` block has been validated — after that point the bootstrap default
|
|
67
|
+
* is no longer in force.
|
|
68
|
+
*/
|
|
69
|
+
applyRootConfig(block, secretValues) {
|
|
70
|
+
__classPrivateFieldSet(this, _KernelLogging_rootScope, buildScopeConfig(block, {
|
|
71
|
+
threshold: SEVERITY.info,
|
|
72
|
+
redaction: EMPTY_REDACTION_POLICY,
|
|
73
|
+
secretValues,
|
|
74
|
+
}), "f");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Detach the bootstrap writer and stop holding records for replay. Called once
|
|
78
|
+
* every declared sink has attached: the buffer exists to cover the pre-attach
|
|
79
|
+
* window, and a consumer connecting later (the debug wire) wants the live
|
|
80
|
+
* stream rather than the whole process history.
|
|
81
|
+
*
|
|
82
|
+
* When the manifest declares no sinks at all, the runtime behaves exactly as
|
|
83
|
+
* if a single `Telo.ConsoleSink` were declared — "pretty logs on stderr in a
|
|
84
|
+
* terminal, JSON when piped", with no imports.
|
|
85
|
+
*
|
|
86
|
+
* That equivalence is why the bootstrap writer is *replaced* here rather than
|
|
87
|
+
* promoted in place. The bootstrap writer is pinned at `info` (§12.3), but a
|
|
88
|
+
* declared `Telo.ConsoleSink` with no explicit `level:` takes the resolved
|
|
89
|
+
* scope threshold — so promoting the fixed-`info` writer would silently ignore
|
|
90
|
+
* a root `logging.level`, in both directions (a `debug` never lowers the gate,
|
|
91
|
+
* a `warn` never raises it). The fresh sink is built at the resolved threshold,
|
|
92
|
+
* so `logging: { level: debug }` with no `sinks:` behaves as documented.
|
|
93
|
+
*/
|
|
94
|
+
sealBootstrap(manifests) {
|
|
95
|
+
if (__classPrivateFieldGet(this, _KernelLogging_sealed, "f"))
|
|
96
|
+
return;
|
|
97
|
+
__classPrivateFieldSet(this, _KernelLogging_sealed, true, "f");
|
|
98
|
+
if (__classPrivateFieldGet(this, _KernelLogging_bootstrap, "f")) {
|
|
99
|
+
this.pipeline.detach(__classPrivateFieldGet(this, _KernelLogging_bootstrap, "f"));
|
|
100
|
+
__classPrivateFieldSet(this, _KernelLogging_bootstrap, undefined, "f");
|
|
101
|
+
}
|
|
102
|
+
// Drop the replay buffer *before* attaching the zero-config sink, so the
|
|
103
|
+
// records the bootstrap writer already wrote live are not replayed into it.
|
|
104
|
+
this.pipeline.sealBootstrap();
|
|
105
|
+
if (declaredSinkCount(manifests) === 0) {
|
|
106
|
+
this.pipeline.attach(new ConsoleSink({
|
|
107
|
+
sinkId: BOOTSTRAP_SINK_ID,
|
|
108
|
+
level: __classPrivateFieldGet(this, _KernelLogging_rootScope, "f").threshold,
|
|
109
|
+
destination: "stderr",
|
|
110
|
+
encoding: "auto",
|
|
111
|
+
color: "auto",
|
|
112
|
+
env: __classPrivateFieldGet(this, _KernelLogging_streams, "f").env,
|
|
113
|
+
stdout: __classPrivateFieldGet(this, _KernelLogging_streams, "f").stdout,
|
|
114
|
+
stderr: __classPrivateFieldGet(this, _KernelLogging_streams, "f").stderr,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** A logger scoped to a module context, stamped with a resource identity. */
|
|
119
|
+
createLogger(scope, resource) {
|
|
120
|
+
return this.pipeline.createLogger(scope ?? __classPrivateFieldGet(this, _KernelLogging_rootScope, "f"), resource);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Every module context's resolved logging configuration, keyed by its dotted
|
|
124
|
+
* import-alias path (`Api.Domain.Db`); the root is keyed `""`.
|
|
125
|
+
*
|
|
126
|
+
* This closes §12.2's loop between reading and configuring: the `scope` on a
|
|
127
|
+
* log line is exactly the path you write in the manifest to change that
|
|
128
|
+
* instance's level, and this answers "what level did that path actually
|
|
129
|
+
* resolve to" without re-deriving the cascade by hand. The tree walk is
|
|
130
|
+
* logging logic, so it lives here rather than on the orchestrator.
|
|
131
|
+
*/
|
|
132
|
+
scopesFrom(rootContext) {
|
|
133
|
+
const scopes = new Map();
|
|
134
|
+
scopes.set("", __classPrivateFieldGet(this, _KernelLogging_rootScope, "f"));
|
|
135
|
+
const visit = (context) => {
|
|
136
|
+
for (const child of context.children ?? []) {
|
|
137
|
+
const config = child.getLoggingConfig?.();
|
|
138
|
+
if (config?.scope)
|
|
139
|
+
scopes.set(config.scope, config);
|
|
140
|
+
visit(child);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
if (rootContext)
|
|
144
|
+
visit(rootContext);
|
|
145
|
+
return scopes;
|
|
146
|
+
}
|
|
147
|
+
/** The kernel's own logger — used for diagnostics the kernel emits about
|
|
148
|
+
* itself, which §13.1 requires to go through this pipeline rather than to
|
|
149
|
+
* `process.stderr` or `console.*`. */
|
|
150
|
+
kernelLogger() {
|
|
151
|
+
return this.pipeline.createLogger(__classPrivateFieldGet(this, _KernelLogging_rootScope, "f"), undefined);
|
|
152
|
+
}
|
|
153
|
+
async shutdown() {
|
|
154
|
+
await this.pipeline.close();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
_KernelLogging_rootScope = new WeakMap(), _KernelLogging_bootstrap = new WeakMap(), _KernelLogging_sealed = new WeakMap(), _KernelLogging_streams = new WeakMap();
|
|
158
|
+
/**
|
|
159
|
+
* Merge a `logging:` block over an inherited configuration. Config cascades and
|
|
160
|
+
* may be narrowed at each hop, which is what makes a dependency you do not own
|
|
161
|
+
* diagnosable — raising `Api`'s level lifts everything beneath it without
|
|
162
|
+
* editing `Api`'s manifest (§12.2).
|
|
163
|
+
*/
|
|
164
|
+
export function buildScopeConfig(block, inherited) {
|
|
165
|
+
if (!block)
|
|
166
|
+
return inherited;
|
|
167
|
+
const level = block.level ? parseLevelName(block.level) : undefined;
|
|
168
|
+
return {
|
|
169
|
+
threshold: level ?? inherited.threshold,
|
|
170
|
+
redaction: block.redact
|
|
171
|
+
? compileRedactionPolicy({
|
|
172
|
+
paths: block.redact.paths,
|
|
173
|
+
censor: block.redact.censor,
|
|
174
|
+
remove: block.redact.remove,
|
|
175
|
+
})
|
|
176
|
+
: inherited.redaction,
|
|
177
|
+
sampling: block.sampling ? toSamplingConfig(block.sampling) : inherited.sampling,
|
|
178
|
+
secretValues: inherited.secretValues,
|
|
179
|
+
scope: inherited.scope,
|
|
180
|
+
module: inherited.module,
|
|
181
|
+
attributes: block.attributes ?? inherited.attributes,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function toSamplingConfig(sampling) {
|
|
185
|
+
return {
|
|
186
|
+
first: sampling.first ?? 0,
|
|
187
|
+
thereafter: sampling.thereafter ?? 0,
|
|
188
|
+
tickMs: sampling.tick ? parseTickMs(sampling.tick) : DEFAULT_SAMPLING_TICK_MS,
|
|
189
|
+
sampleErrors: sampling.sampleErrors ?? false,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function parseTickMs(tick) {
|
|
193
|
+
const match = /^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h)\s*$/.exec(tick);
|
|
194
|
+
if (!match)
|
|
195
|
+
return DEFAULT_SAMPLING_TICK_MS;
|
|
196
|
+
const unit = { ms: 1, s: 1000, m: 60000, h: 3600000 }[match[2]];
|
|
197
|
+
return Number(match[1]) * unit;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL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,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ;QAChF,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU;KACrD,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAuD;IAC/E,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC;QAC1B,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,CAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,wBAAwB;QAC7E,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,KAAK;KAC7C,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,KAAK,GAAG,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,CAAC,KAAK;QAAE,OAAO,wBAAwB,CAAC;IAC5C,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAM,EAAE,CAAC,EAAE,OAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAA2B,CAAC,CAAC;IAC7F,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sink contract now lives in `@telorun/sdk` — §10.2 keeps the sink set open
|
|
3
|
+
* to the ecosystem, so a third-party sink module implements it as an ordinary
|
|
4
|
+
* module author rather than importing a kernel-internal type. Re-exported here
|
|
5
|
+
* so the kernel's own imports keep one spelling.
|
|
6
|
+
*/
|
|
7
|
+
export { BLOCK_UNSUPPORTED, blockUnsupportedMessage, DEFAULT_BUFFER_POLICY, } from "@telorun/sdk";
|
|
8
|
+
export type { DropCause, LoggingHost, LogSinkInstance, OnFull, SinkBufferPolicy, } from "@telorun/sdk";
|
|
9
|
+
//# sourceMappingURL=log-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-sink.d.ts","sourceRoot":"","sources":["../../src/logging/log-sink.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,MAAM,EACN,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sink contract now lives in `@telorun/sdk` — §10.2 keeps the sink set open
|
|
3
|
+
* to the ecosystem, so a third-party sink module implements it as an ordinary
|
|
4
|
+
* module author rather than importing a kernel-internal type. Re-exported here
|
|
5
|
+
* so the kernel's own imports keep one spelling.
|
|
6
|
+
*/
|
|
7
|
+
export { BLOCK_UNSUPPORTED, blockUnsupportedMessage, DEFAULT_BUFFER_POLICY, } from "@telorun/sdk";
|
|
8
|
+
//# sourceMappingURL=log-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-sink.js","sourceRoot":"","sources":["../../src/logging/log-sink.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DropCause, type LoggingHost } from "@telorun/sdk";
|
|
2
|
+
export type { LoggingHost } from "@telorun/sdk";
|
|
3
|
+
import type { LoggingPipeline } from "./logging-pipeline.js";
|
|
4
|
+
/**
|
|
5
|
+
* The narrow facade a sink controller sees — `kernel/specs/logging.md` §12.1.
|
|
6
|
+
*
|
|
7
|
+
* A sink is a resource, so its controller runs under an ordinary
|
|
8
|
+
* `ResourceContext`; this is the one extra surface it needs. It is deliberately
|
|
9
|
+
* small: attach, detach, resolve a level, count a drop. Everything else about
|
|
10
|
+
* the pipeline stays private to the kernel, so a third-party sink shipped as a
|
|
11
|
+
* module depends on this contract and nothing deeper.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createLoggingHost(pipeline: LoggingPipeline, scopeThreshold: () => number, recordDrop: (sinkId: string, cause: DropCause, count?: number) => void): LoggingHost;
|
|
14
|
+
//# sourceMappingURL=logging-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging-host.d.ts","sourceRoot":"","sources":["../../src/logging/logging-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,SAAS,EAAkB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhG,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,MAAM,MAAM,EAC5B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,GACrE,WAAW,CAcb"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseLevelName } from "@telorun/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* The narrow facade a sink controller sees — `kernel/specs/logging.md` §12.1.
|
|
4
|
+
*
|
|
5
|
+
* A sink is a resource, so its controller runs under an ordinary
|
|
6
|
+
* `ResourceContext`; this is the one extra surface it needs. It is deliberately
|
|
7
|
+
* small: attach, detach, resolve a level, count a drop. Everything else about
|
|
8
|
+
* the pipeline stays private to the kernel, so a third-party sink shipped as a
|
|
9
|
+
* module depends on this contract and nothing deeper.
|
|
10
|
+
*/
|
|
11
|
+
export function createLoggingHost(pipeline, scopeThreshold, recordDrop) {
|
|
12
|
+
return {
|
|
13
|
+
attach: (sink) => pipeline.attach(sink),
|
|
14
|
+
detach: (sink) => pipeline.detach(sink),
|
|
15
|
+
levelFor: (level) => {
|
|
16
|
+
if (!level)
|
|
17
|
+
return scopeThreshold();
|
|
18
|
+
const severity = parseLevelName(level);
|
|
19
|
+
// The schema constrains `level:` to the six named levels, so an unknown
|
|
20
|
+
// value here means the manifest bypassed validation; fall back rather than
|
|
21
|
+
// throw, because a logging misconfiguration must not break boot.
|
|
22
|
+
return severity ?? scopeThreshold();
|
|
23
|
+
},
|
|
24
|
+
recordDrop,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=logging-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging-host.js","sourceRoot":"","sources":["../../src/logging/logging-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAoD,MAAM,cAAc,CAAC;AAKhG;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAyB,EACzB,cAA4B,EAC5B,UAAsE;IAEtE,OAAO;QACL,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,CAAC,KAAK;gBAAE,OAAO,cAAc,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAkB,CAAC,CAAC;YACpD,wEAAwE;YACxE,2EAA2E;YAC3E,iEAAiE;YACjE,OAAO,QAAQ,IAAI,cAAc,EAAE,CAAC;QACtC,CAAC;QACD,UAAU;KACX,CAAC;AACJ,CAAC"}
|