mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-04 12:39:06 +02:00
Tighten verbose comments in Wails UI Go code
Shorten over-long godoc/inline comments across the client/ui tray and services code: drop narrative restatement, legacy-Fyne tangents, and text already evident from signatures and names. Keep only the non-obvious why (concurrency/lock ordering, platform quirks, ordering constraints, the profile-switch state table). No code changes.
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
//go:build !android && !ios && !freebsd && !js
|
||||
|
||||
// Package guilog manages the desktop UI's own file log (gui-client.log), which
|
||||
// follows the daemon's log level: when the daemon is in debug/trace the GUI
|
||||
// attaches a rotated file alongside the console so its (and the React frontend's
|
||||
// forwarded) output is captured for the debug bundle. It is intentionally not a
|
||||
// Wails service — it has no frontend-facing methods and generates no TS
|
||||
// bindings — so it lives outside client/ui/services.
|
||||
// Package guilog manages gui-client.log, which follows the daemon's log level:
|
||||
// in debug/trace the GUI attaches a rotated file alongside the console so its
|
||||
// (and the React frontend's forwarded) output is captured for the debug bundle.
|
||||
package guilog
|
||||
|
||||
import (
|
||||
@@ -16,17 +13,9 @@ import (
|
||||
"github.com/netbirdio/netbird/util"
|
||||
)
|
||||
|
||||
// DebugLog is the daemon-debug-driven GUI file log. The daemon publishes a
|
||||
// marked "log-level-changed" SystemEvent over SubscribeEvents (both on change
|
||||
// and once per new subscription, so a daemon already in debug is picked up at
|
||||
// startup); services.DaemonFeed routes it here via Apply.
|
||||
//
|
||||
// When the daemon is in debug/trace and the GUI owns its log (no manual
|
||||
// --log-file), it attaches a rotated gui-client.log alongside the console and
|
||||
// raises the logrus level; back to a higher level it detaches the file and
|
||||
// restores info. The file is left on disk (rotated by timberjack) for the debug
|
||||
// bundle to collect. When the user set --log-file explicitly, it is disabled and
|
||||
// never touches logging.
|
||||
// DebugLog attaches/detaches gui-client.log based on the daemon's log level,
|
||||
// fed via Apply. The file is left on disk for the debug bundle to collect.
|
||||
// Disabled (and never touches logging) when the user set --log-file explicitly.
|
||||
type DebugLog struct {
|
||||
uiPath string
|
||||
enabled bool
|
||||
@@ -35,16 +24,14 @@ type DebugLog struct {
|
||||
fileOn bool
|
||||
}
|
||||
|
||||
// NewDebugLog builds the GUI debug log. uiPath is the absolute gui-client.log
|
||||
// path; enabled is false when the user passed --log-file (manual override), in
|
||||
// which case it leaves logging untouched.
|
||||
// NewDebugLog builds the GUI debug log. enabled is false when the user passed
|
||||
// --log-file (manual override).
|
||||
func NewDebugLog(uiPath string, enabled bool) *DebugLog {
|
||||
return &DebugLog{uiPath: uiPath, enabled: enabled}
|
||||
}
|
||||
|
||||
// Path returns the GUI log path to register with the daemon, or "" when the GUI
|
||||
// doesn't own its log (manual --log-file) — in that case the daemon shouldn't
|
||||
// try to collect a gui-client.log the GUI never writes.
|
||||
// Path returns the GUI log path to register with the daemon, or "" when disabled
|
||||
// so the daemon won't collect a file the GUI never writes.
|
||||
func (d *DebugLog) Path() string {
|
||||
if !d.enabled {
|
||||
return ""
|
||||
@@ -52,17 +39,15 @@ func (d *DebugLog) Path() string {
|
||||
return d.uiPath
|
||||
}
|
||||
|
||||
// Apply reacts to a daemon log level (the lowercase logrus name, e.g. "debug").
|
||||
// Idempotent: repeated identical levels are no-ops, so the startup replay plus a
|
||||
// racing change-event do no harm.
|
||||
// Apply reacts to a daemon log level (the logrus name, e.g. "debug").
|
||||
// Idempotent via the fileOn guard, so the startup replay plus a racing
|
||||
// change-event are harmless.
|
||||
func (d *DebugLog) Apply(level string) {
|
||||
if !d.enabled {
|
||||
return
|
||||
}
|
||||
|
||||
// "debug or more verbose" (debug/trace) turns the file log on; anything less
|
||||
// verbose turns it off. Compare numerically against logrus' own levels so
|
||||
// there are no hard-coded level-name literals.
|
||||
// Compared numerically so there are no hard-coded level-name literals.
|
||||
lvl, err := log.ParseLevel(level)
|
||||
if err != nil {
|
||||
lvl = log.InfoLevel
|
||||
|
||||
Reference in New Issue
Block a user