From: Simon Ruderich Date: Wed, 12 May 2021 06:35:59 +0000 (+0200) Subject: safcm: simplify Sync.logf to take the log message as string X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=0d6364c68d5e523f3c69b93d48cadfb7c150b652;p=safcm%2Fsafcm.git 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(). --- 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 != "" {