Files
netbird/client/ui/services/uilog.go
T
Zoltán Papp 439b85c584 [client] Forward frontend console logs through the standard logger
Use the shared logrus logger alias and carry the JS origin in a dedicated
"ui" log field instead of inlining a [ui ...] tag in the message, keeping
frontend logs distinct from the Go-caller source.
2026-06-10 16:06:26 +02:00

39 lines
890 B
Go

//go:build !android && !ios && !freebsd && !js
package services
import (
"context"
log "github.com/sirupsen/logrus"
)
// UILog lets the frontend forward console output into the Go logrus
// pipeline. The JS origin is carried as the "ui" log field so it stays
// distinct from logrus's own Go-caller source.
type UILog struct{}
func NewUILog() *UILog { return &UILog{} }
// Log forwards one frontend console entry. level is trace/debug/info/warn/
// error (anything else → info); source is the JS origin (may be empty).
func (s *UILog) Log(_ context.Context, level, source, msg string) {
origin := "unknown"
if source != "" {
origin = source
}
entry := log.WithField("ui", origin)
switch level {
case "trace":
entry.Trace(msg)
case "debug":
entry.Debug(msg)
case "warn", "warning":
entry.Warn(msg)
case "error":
entry.Error(msg)
default:
entry.Info(msg)
}
}