add structured logging with timestamps for docker/unraid log viewer
All checks were successful
Build and Push Docker Image / build (push) Successful in 15s
All checks were successful
Build and Push Docker Image / build (push) Successful in 15s
all server output now prefixed with ISO timestamp and level [INFO/WARN/ERROR]. logs requests, scan start/complete, job lifecycle, errors. skips noisy SSE endpoints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { Hono } from 'hono';
|
||||
import { serveStatic } from 'hono/bun';
|
||||
import { cors } from 'hono/cors';
|
||||
import { getDb, getConfig } from './db/index';
|
||||
import { log } from './lib/log';
|
||||
|
||||
import setupRoutes from './api/setup';
|
||||
import scanRoutes from './api/scan';
|
||||
@@ -17,6 +18,17 @@ const app = new Hono();
|
||||
|
||||
app.use('/api/*', cors({ origin: ['http://localhost:5173', 'http://localhost:3000'] }));
|
||||
|
||||
// ─── Request logging ──────────────────────────────────────────────────────────
|
||||
|
||||
app.use('/api/*', async (c, next) => {
|
||||
const start = Date.now();
|
||||
await next();
|
||||
const ms = Date.now() - start;
|
||||
// Skip noisy SSE/polling endpoints
|
||||
if (c.req.path.endsWith('/events')) return;
|
||||
log(`${c.req.method} ${c.req.path} → ${c.res.status} (${ms}ms)`);
|
||||
});
|
||||
|
||||
// ─── API routes ───────────────────────────────────────────────────────────────
|
||||
|
||||
import pkg from '../package.json';
|
||||
@@ -54,7 +66,7 @@ app.get('*', (c) => {
|
||||
|
||||
const port = Number(process.env.PORT ?? '3000');
|
||||
|
||||
console.log(`netfelix-audio-fix API on http://localhost:${port}`);
|
||||
log(`netfelix-audio-fix v${pkg.version} starting on http://localhost:${port}`);
|
||||
|
||||
getDb();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user