From 0d6364c68d5e523f3c69b93d48cadfb7c150b652 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 12 May 2021 08:35:59 +0200 Subject: [PATCH] safcm: simplify Sync.logf to take the log message as string logf() is not directly called by regular code which makes the format string less useful. Also rename it to log(). --- cmd/safcm/sync.go | 12 +++++------- cmd/safcm/sync_sync.go | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/safcm/sync.go b/cmd/safcm/sync.go index 70aaf47..4a82ca3 100644 --- a/cmd/safcm/sync.go +++ b/cmd/safcm/sync.go @@ -400,9 +400,7 @@ func (s *Sync) Host(wg *sync.WaitGroup) error { return nil } -func (s *Sync) logf(level safcm.LogLevel, escaped bool, - format string, a ...interface{}) { - +func (s *Sync) log(level safcm.LogLevel, escaped bool, msg string) { if s.config.LogLevel < level { return } @@ -410,16 +408,16 @@ func (s *Sync) logf(level safcm.LogLevel, escaped bool, Host: s.host, Log: Log{ Level: level, - Text: fmt.Sprintf(format, a...), + Text: msg, }, Escaped: escaped, } } func (s *Sync) logDebugf(format string, a ...interface{}) { - s.logf(safcm.LogDebug, false, format, a...) + s.log(safcm.LogDebug, false, fmt.Sprintf(format, a...)) } func (s *Sync) logVerbosef(format string, a ...interface{}) { - s.logf(safcm.LogVerbose, false, format, a...) + s.log(safcm.LogVerbose, false, fmt.Sprintf(format, a...)) } // sendRecv sends a message over conn and waits for the response. Any MsgLog @@ -437,7 +435,7 @@ func (s *Sync) sendRecv(conn *rpc.Conn, msg safcm.Msg) (safcm.Msg, error) { } log, ok := x.(safcm.MsgLog) if ok { - s.logf(log.Level, false, "%s", log.Text) + s.log(log.Level, false, log.Text) continue } return x, nil diff --git a/cmd/safcm/sync_sync.go b/cmd/safcm/sync_sync.go index 385cfd9..0d5a722 100644 --- a/cmd/safcm/sync_sync.go +++ b/cmd/safcm/sync_sync.go @@ -47,7 +47,7 @@ func (s *Sync) hostSync(conn *rpc.Conn, detectedGroups []string) error { // Display changes changes := s.formatChanges(resp) if changes != "" { - s.logf(safcm.LogInfo, true, "%s", changes) + s.log(safcm.LogInfo, true, changes) } if resp.Error != "" { -- 2.43.2