feat: add structured backend logging
CI / Static checks (push) Successful in 37s
CI / Build and push image (push) Skipped

Collector failures, service-API errors, WS connection lifecycle, and
config reload/discovery events were previously invisible outside the
browser (or, for a few config/discovery cases, logged with an
inconsistent ad-hoc console.error). Add a small scoped logger
(lib/logger.ts, level via LOG_LEVEL) and wire it through server.ts,
the scheduler, service collector, config loader/effective store, and
the WS server so operators can see failures via `docker logs`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 09:39:30 +02:00
co-authored by Claude Sonnet 5
parent 94ffa9e930
commit 7727ca8e97
7 changed files with 159 additions and 18 deletions
+8 -1
View File
@@ -1,6 +1,9 @@
import { configStore } from "./loader";
import { discoverDockerWidgets } from "@/lib/discovery/traefik-labels";
import type { Config, Widget } from "./schema";
import { createLogger } from "@/lib/logger";
const log = createLogger("discovery");
const DISCOVERY_INTERVAL_MS = 60_000;
@@ -53,11 +56,15 @@ class EffectiveConfigStore {
try {
const next = await discoverDockerWidgets(configStore.get());
if (!sameDiscoveredSet(this.discovered, next)) {
log.info("discovered widget set changed", {
previous: this.discovered.length,
current: next.length,
});
this.discovered = next;
this.emit();
}
} catch (err) {
console.error(`[discovery] ${(err as Error).message}`);
log.error("discovery scan failed", { error: (err as Error).message });
}
}