feat: add structured backend logging
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:
@@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user