diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-09-25 10:20:42 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-09-26 14:12:43 +0300 |
commit | b0b9d35e9cb00c42d4039f89594b0d0cb3244ef3 (patch) | |
tree | 10cff05cacdea2471409e2462d0d594857adca83 | |
parent | 2bbd7cd2cbae2912b32bc7c5541cdcd81dbacf87 (diff) |
log: Drop `Warnf()` function from `Logger` interface
Remove the `Warnf()` function from the `Logger` interface. Please refer
to the preceding commit that removes `Debugf()` for the motivation
behind this change.
-rw-r--r-- | cmd/gitaly-backup/restore.go | 2 | ||||
-rw-r--r-- | internal/backup/pipeline.go | 2 | ||||
-rw-r--r-- | internal/cgroups/manager_linux.go | 4 | ||||
-rw-r--r-- | internal/gitaly/config/sentry/sentry.go | 2 | ||||
-rw-r--r-- | internal/gitaly/storage/counter/counter.go | 2 | ||||
-rw-r--r-- | internal/gitaly/storage/storagemgr/database.go | 2 | ||||
-rw-r--r-- | internal/grpc/sidechannel/proxy.go | 2 | ||||
-rw-r--r-- | internal/log/logger.go | 6 | ||||
-rw-r--r-- | internal/praefect/server.go | 4 |
9 files changed, 10 insertions, 16 deletions
diff --git a/cmd/gitaly-backup/restore.go b/cmd/gitaly-backup/restore.go index 91cd398da..d75e72399 100644 --- a/cmd/gitaly-backup/restore.go +++ b/cmd/gitaly-backup/restore.go @@ -80,7 +80,7 @@ func (cmd *restoreSubcommand) Run(ctx context.Context, logger log.Logger, stdin if err != nil { // Treat RemoveAll failures as soft failures until we can determine // how often it fails. - logger.WithError(err).Warnf("failed to remove all repositories from %s", storageName) + logger.WithError(err).WithField("storage_name", storageName).Warn("failed to remove all repositories") } } diff --git a/internal/backup/pipeline.go b/internal/backup/pipeline.go index d515ca9a2..b0026e1a6 100644 --- a/internal/backup/pipeline.go +++ b/internal/backup/pipeline.go @@ -175,7 +175,7 @@ func (p *LoggingPipeline) Handle(ctx context.Context, cmd Command) { if err := cmd.Execute(ctx); err != nil { if errors.Is(err, ErrSkipped) { - log.WithError(err).Warnf("skipped %s", cmd.Name()) + log.WithError(err).Warn(fmt.Sprintf("skipped %s", cmd.Name())) } else { log.WithError(err).Errorf("%s failed", cmd.Name()) p.addError(cmd.Repository(), err) diff --git a/internal/cgroups/manager_linux.go b/internal/cgroups/manager_linux.go index 12dc01988..2680b2862 100644 --- a/internal/cgroups/manager_linux.go +++ b/internal/cgroups/manager_linux.go @@ -49,9 +49,9 @@ func newCgroupManagerWithMode(cfg cgroupscfg.Config, logger log.Logger, pid int, handler = newV1Handler(cfg, logger, pid) case cgrps.Unified: handler = newV2Handler(cfg, logger, pid) - logger.Warnf("Gitaly now includes experimental support for CgroupV2. Please proceed with caution and use this experimental feature at your own risk") + logger.Warn("Gitaly now includes experimental support for CgroupV2. Please proceed with caution and use this experimental feature at your own risk") default: - logger.Warnf("Gitaly has encountered an issue while trying to detect the version of the system's cgroup. As a result, all subsequent commands will be executed without cgroup support. Please check the system's cgroup configuration and try again") + logger.Warn("Gitaly has encountered an issue while trying to detect the version of the system's cgroup. As a result, all subsequent commands will be executed without cgroup support. Please check the system's cgroup configuration and try again") return nil } diff --git a/internal/gitaly/config/sentry/sentry.go b/internal/gitaly/config/sentry/sentry.go index d6e148b8b..4cefdb534 100644 --- a/internal/gitaly/config/sentry/sentry.go +++ b/internal/gitaly/config/sentry/sentry.go @@ -26,7 +26,7 @@ func ConfigureSentry(logger log.Logger, version string, sentryConf Config) { Release: "v" + version, }) if err != nil { - logger.Warnf("Unable to initialize sentry client: %v", err) + logger.WithError(err).Warn("unable to initialize sentry client") return } diff --git a/internal/gitaly/storage/counter/counter.go b/internal/gitaly/storage/counter/counter.go index c1d264b9a..b9b8cd34e 100644 --- a/internal/gitaly/storage/counter/counter.go +++ b/internal/gitaly/storage/counter/counter.go @@ -99,7 +99,7 @@ func (c *RepositoryCounter) countRepositories( if err != nil { // Encountering a malformed path should not block us from continuing // to count. - logger.WithError(err).Warnf("counting repositories: walking path %q", storPath) + logger.WithError(err).WithField("storage_path", storPath).Warn("counting repositories failed due to malformed path") return nil } diff --git a/internal/gitaly/storage/storagemgr/database.go b/internal/gitaly/storage/storagemgr/database.go index b13632de2..ffb55fe74 100644 --- a/internal/gitaly/storage/storagemgr/database.go +++ b/internal/gitaly/storage/storagemgr/database.go @@ -31,7 +31,7 @@ func (l badgerLogger) Infof(msg string, args ...any) { } func (l badgerLogger) Warningf(msg string, args ...any) { - l.Warnf(msg, args...) + l.Warn(fmt.Sprintf(msg, args...)) } // databaseAdapter adapts a *badger.DB to the internal database interface used by the hooks in tests. diff --git a/internal/grpc/sidechannel/proxy.go b/internal/grpc/sidechannel/proxy.go index f8ca329ff..69df54e76 100644 --- a/internal/grpc/sidechannel/proxy.go +++ b/internal/grpc/sidechannel/proxy.go @@ -27,7 +27,7 @@ func NewUnaryProxy(registry *Registry, log log.Logger) grpc.UnaryClientIntercept // If upstream returns non-successful error and the waiter fails to close, we should // prioritize the returned error because that error is propagated back to downstream. // The waiter error (most likely unexpected close) is logged instead. - log.Warnf("sidechannel: proxy callback: %w", waiterErr) + log.WithError(waiterErr).Warn("failed proxying callback on sidechannel") } } }() diff --git a/internal/log/logger.go b/internal/log/logger.go index d079df8c8..c744718b4 100644 --- a/internal/log/logger.go +++ b/internal/log/logger.go @@ -18,7 +18,6 @@ type Logger interface { WithFields(fields Fields) Logger WithError(err error) Logger - Warnf(format string, args ...any) Errorf(format string, args ...any) Debug(msg string) @@ -64,11 +63,6 @@ func (l LogrusLogger) WithError(err error) Logger { return LogrusLogger{entry: l.entry.WithError(err)} } -// Warnf writes a formatted log message at warn level. -func (l LogrusLogger) Warnf(format string, args ...any) { - l.entry.Warnf(format, args...) -} - // Errorf writes a formatted log message at error level. func (l LogrusLogger) Errorf(format string, args ...any) { l.entry.Errorf(format, args...) diff --git a/internal/praefect/server.go b/internal/praefect/server.go index fcfc38dbf..823ed02ec 100644 --- a/internal/praefect/server.go +++ b/internal/praefect/server.go @@ -243,14 +243,14 @@ func warnDupeAddrs(logger log.Logger, conf config.Config) { for _, n := range virtualStorage.Nodes { _, ok := addrSet[n.Address] if ok { - logger.Warnf("more than one backend node is hosted at %s", n.Address) + logger.WithField("conflicting_address", n.Address).Warn("more than one backend node is hosted at same address") fishy = true continue } addrSet[n.Address] = struct{}{} } if fishy { - logger.Warnf("your Praefect configuration may not offer actual redundancy") + logger.Warn("your Praefect configuration may not offer actual redundancy") } } } |