bazis 0.97.10 → 0.97.11
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.
|
@@ -232,7 +232,7 @@ export class CodexAppServerClient implements CodexClient {
|
|
|
232
232
|
if (method === "account/updated") this.modelCache = undefined;
|
|
233
233
|
}, () => { this.clearLogin(); this.modelCache = undefined; });
|
|
234
234
|
const initialized = await client.request("initialize", {
|
|
235
|
-
clientInfo: { name: "bazis", title: "Bazis", version: "0.97.
|
|
235
|
+
clientInfo: { name: "bazis", title: "Bazis", version: "0.97.11" }, capabilities: { experimentalApi: true },
|
|
236
236
|
}, 15_000, signal);
|
|
237
237
|
if (resolve(text(initialized.codexHome, 4096)) !== this.paths.home) throw new CodexError("PROTOCOL_ERROR");
|
|
238
238
|
client.notify("initialized");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { redactSensitive, type SensitiveRedactionOptions } from "../../../library/redaction";
|
|
2
2
|
import type { LogFields, LogLevel, Logger } from "./Logger";
|
|
3
|
+
import { getRequestId, getTraceparent } from "../correlation/requestContext";
|
|
3
4
|
|
|
4
5
|
const LEVEL_ORDER: Record<LogLevel, number> = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
5
6
|
|
|
@@ -17,6 +18,22 @@ export interface ConsoleLoggerOptions {
|
|
|
17
18
|
readonly name?: string;
|
|
18
19
|
/** Structured fields are redacted by default; pass false only for trusted local debugging. */
|
|
19
20
|
readonly redaction?: SensitiveRedactionOptions | false;
|
|
21
|
+
/**
|
|
22
|
+
* Inside a request, add `requestId` (and `traceparent`, when the request
|
|
23
|
+
* brought one) to every line that does not pass them itself. Default: true.
|
|
24
|
+
*/
|
|
25
|
+
readonly requestContext?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The fields plus the correlation of the current request, without overriding explicit values. */
|
|
29
|
+
function withRequestContext(fields: LogFields | undefined): LogFields | undefined {
|
|
30
|
+
const requestId = getRequestId();
|
|
31
|
+
if (requestId === undefined) return fields;
|
|
32
|
+
const traceparent = getTraceparent();
|
|
33
|
+
const extra: Record<string, unknown> = {};
|
|
34
|
+
if (fields?.requestId === undefined) extra.requestId = requestId;
|
|
35
|
+
if (traceparent !== undefined && fields?.traceparent === undefined) extra.traceparent = traceparent;
|
|
36
|
+
return Object.keys(extra).length === 0 ? fields : { ...fields, ...extra };
|
|
20
37
|
}
|
|
21
38
|
|
|
22
39
|
function formatFields(fields: LogFields | undefined, redaction: SensitiveRedactionOptions | false): string {
|
|
@@ -36,11 +53,13 @@ export class ConsoleLogger implements Logger {
|
|
|
36
53
|
private readonly threshold: number;
|
|
37
54
|
private readonly prefix: string;
|
|
38
55
|
private readonly redaction: SensitiveRedactionOptions | false;
|
|
56
|
+
private readonly requestContext: boolean;
|
|
39
57
|
|
|
40
58
|
public constructor(options: ConsoleLoggerOptions = {}) {
|
|
41
59
|
this.threshold = LEVEL_ORDER[options.minLevel ?? "info"];
|
|
42
60
|
this.prefix = options.name ? `[${options.name}] ` : "";
|
|
43
61
|
this.redaction = options.redaction ?? {};
|
|
62
|
+
this.requestContext = options.requestContext ?? true;
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
public debug(message: string, fields?: LogFields): void {
|
|
@@ -63,6 +82,7 @@ export class ConsoleLogger implements Logger {
|
|
|
63
82
|
if (LEVEL_ORDER[level] < this.threshold) {
|
|
64
83
|
return;
|
|
65
84
|
}
|
|
66
|
-
|
|
85
|
+
const line = this.requestContext ? withRequestContext(fields) : fields;
|
|
86
|
+
LEVEL_SINK[level](`${this.prefix}${level}: ${message}${formatFields(line, this.redaction)}`);
|
|
67
87
|
}
|
|
68
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bazis",
|
|
3
|
-
"version": "0.97.
|
|
3
|
+
"version": "0.97.11",
|
|
4
4
|
"description": "Modular backend framework for Bun in TypeScript: DI wired by codegen, HTTP, a PostgreSQL ORM, JWT, WebSocket, agents and a CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alexander Alenin",
|