From 439b85c584baaefe4b8e4a89358321528dcff8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Wed, 10 Jun 2026 16:06:26 +0200 Subject: [PATCH] [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. --- client/ui/services/uilog.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/ui/services/uilog.go b/client/ui/services/uilog.go index 0ce3c35c1..1c7669438 100644 --- a/client/ui/services/uilog.go +++ b/client/ui/services/uilog.go @@ -5,12 +5,12 @@ package services import ( "context" - "github.com/sirupsen/logrus" + log "github.com/sirupsen/logrus" ) // UILog lets the frontend forward console output into the Go logrus -// pipeline. The JS origin rides in the message ("[ui ] ...") -// because logrus's ReportCaller always pins the source to this file. +// 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{} } @@ -18,21 +18,21 @@ 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 != "" { - msg = "[ui " + source + "] " + msg - } else { - msg = "[ui] " + msg + origin = source } + entry := log.WithField("ui", origin) switch level { case "trace": - logrus.Trace(msg) + entry.Trace(msg) case "debug": - logrus.Debug(msg) + entry.Debug(msg) case "warn", "warning": - logrus.Warn(msg) + entry.Warn(msg) case "error": - logrus.Error(msg) + entry.Error(msg) default: - logrus.Info(msg) + entry.Info(msg) } }