mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 04:26:43 -06:00
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
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// 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);
|
||||
Reference in New Issue
Block a user