mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 12:26:39 -06:00
feat: add request ID propagation from Rust to Bun with structured logging
- Forward x-request-id header through proxy and API calls - Store RequestId in request extensions for downstream access - Add AsyncLocalStorage context to correlate logs across async boundaries - Improve migration logging to show pending changes before applying - Reduce noise in logs (common OG images, health checks)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { dev } from "$app/environment";
|
||||
import { configure, getConsoleSink, type LogRecord } from "@logtape/logtape";
|
||||
import { requestContext } from "$lib/server/context";
|
||||
|
||||
interface RailwayLogEntry {
|
||||
timestamp: string;
|
||||
@@ -10,12 +11,14 @@ interface RailwayLogEntry {
|
||||
}
|
||||
|
||||
function railwayFormatter(record: LogRecord): string {
|
||||
const ctx = requestContext.getStore();
|
||||
const categoryTarget = record.category.join(":");
|
||||
const entry: RailwayLogEntry = {
|
||||
timestamp: new Date().toISOString(),
|
||||
level: record.level.toLowerCase(),
|
||||
message: record.message.join(" "),
|
||||
target: categoryTarget ? `bun:${categoryTarget}` : "bun",
|
||||
...(ctx?.requestId && { req_id: ctx.requestId }),
|
||||
};
|
||||
|
||||
if (record.properties && Object.keys(record.properties).length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user