feat(ui): GUI debug logging follows daemon log level + debug bundle

When the daemon is set to debug/trace, the GUI now automatically writes a
rotated gui-client.log in the user's config dir and the daemon's debug bundle
collects it. The UI learns the level both at startup (daemon already in debug)
and live, by piggybacking the existing SubscribeEvents stream: the daemon
publishes a marked log-level-changed SystemEvent (and a per-subscription
snapshot), which DaemonFeed routes to guilog.DebugLog instead of an OS toast.
The UI registers its log path via a new RegisterUILog RPC so the root daemon,
which can't resolve the user's config dir, knows where to find the file.

Manual --log-file (any value) disables the daemon-driven file logging.

Fix: client/ui SetLogLevel looked up proto.LogLevel_value with the lowercase
logrus name, which never matched the uppercase enum keys and silently fell back
to INFO — so trace/debug requests from the bundle flow had no effect.
This commit is contained in:
Zoltán Papp
2026-06-11 18:33:21 +02:00
parent 96f0c7a165
commit ff6aef5e2a
17 changed files with 971 additions and 419 deletions

View File

@@ -8,6 +8,11 @@ import { useProfile } from "@/contexts/ProfileContext.tsx";
const NETBIRD_UPLOAD_URL = "https://upload.debug.netbird.io/upload-url";
const TRACE_LOG_FILE_COUNT = 5;
const PLAIN_LOG_FILE_COUNT = 1;
// Lowercase logrus level name sent to Debug.SetLogLevel (the Go binding
// upper-cases before the proto enum lookup). Raising to trace is what drives
// the daemon's verbose logging and the GUI's gui-client.log during a bundle.
const TRACE_LOG_LEVEL = "trace";
const DEFAULT_LOG_LEVEL = "info";
export type DebugStage =
| { kind: "idle" }
@@ -68,7 +73,7 @@ const runTracePhase = async (
// empty
}
throwIfAborted(signal);
await DebugSvc.SetLogLevel({ level: "trace" });
await DebugSvc.SetLogLevel({ level: TRACE_LOG_LEVEL });
level.raised = true;
throwIfAborted(signal);
@@ -123,7 +128,7 @@ const useDebugBundle = () => {
const signal = ctrl.signal;
const uploadUrl = upload ? NETBIRD_UPLOAD_URL : "";
const level: LevelState = { original: "info", raised: false };
const level: LevelState = { original: DEFAULT_LOG_LEVEL, raised: false };
try {
if (trace) {