Files
xevion.dev/web/console-logger.js
Xevion 32f1f88a90 feat: embed SvelteKit client assets in Rust binary
- Add include_dir for serving /_app static bundles from binary
- Add console-logger.js for structured JSON logs from Bun
- Fix API routing edge cases and add method restrictions
2026-01-04 19:16:08 -06:00

32 lines
883 B
JavaScript

// Patch console methods to output structured JSON logs
// This runs before the Bun server starts to ensure all console output is formatted
const originalConsole = {
log: console.log,
error: console.error,
warn: console.warn,
info: console.info,
debug: console.debug,
};
function formatLog(level, args) {
const message = args.map(arg =>
typeof arg === 'object' ? JSON.stringify(arg) : String(arg)
).join(' ');
const logEntry = {
timestamp: new Date().toISOString(),
level: level,
message: message,
target: 'bun',
};
originalConsole.log(JSON.stringify(logEntry));
}
console.log = (...args) => formatLog('info', args);
console.info = (...args) => formatLog('info', args);
console.warn = (...args) => formatLog('warn', args);
console.error = (...args) => formatLog('error', args);
console.debug = (...args) => formatLog('debug', args);