summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Fang <cfang@redhat.com>2024-08-30 19:20:57 -0400
committerGitHub <noreply@github.com>2024-08-30 19:20:57 -0400
commit40f260aa66622fb0a4318bafbb873f0f0122b31f (patch)
treecee9cfdb603c922b4d47c55b36ad4b70b8fd0eb6
parentb2d83759a115c10f956e15faddc1383f96cc3c9e (diff)
fix: warnings from golangci-lint: S1009 should omit nil check; non-constant format string in call to fmt.Errorf (#849)
Signed-off-by: Cheng Fang <cfang@redhat.com>
-rw-r--r--ext/git/writer.go2
-rw-r--r--pkg/log/log.go16
2 files changed, 9 insertions, 9 deletions
diff --git a/ext/git/writer.go b/ext/git/writer.go
index d2d2f75..f286f51 100644
--- a/ext/git/writer.go
+++ b/ext/git/writer.go
@@ -61,7 +61,7 @@ func (m *nativeGitClient) Commit(pathSpec string, opts *CommitOptions) error {
out, err := m.runCmd(args...)
if err != nil {
- log.Errorf(out)
+ log.Errorf("%s %v", out, err)
return err
}
diff --git a/pkg/log/log.go b/pkg/log/log.go
index 1f74634..85be5d4 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -70,7 +70,7 @@ func (logctx *LogContext) AddField(key string, value interface{}) *LogContext {
return logctx
}
-// Logger retrieves the native logger interface. Use with care.
+// Log retrieves the native logger interface. Use with care.
func Log() *logrus.Logger {
return logger
}
@@ -78,7 +78,7 @@ func Log() *logrus.Logger {
// Tracef logs a debug message for logctx to stdout
func (logctx *LogContext) Tracef(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
- if logctx.fields != nil && len(logctx.fields) > 0 {
+ if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Tracef(format, args...)
} else {
logger.Tracef(format, args...)
@@ -88,7 +88,7 @@ func (logctx *LogContext) Tracef(format string, args ...interface{}) {
// Debugf logs a debug message for logctx to stdout
func (logctx *LogContext) Debugf(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
- if logctx.fields != nil && len(logctx.fields) > 0 {
+ if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Debugf(format, args...)
} else {
logger.Debugf(format, args...)
@@ -98,7 +98,7 @@ func (logctx *LogContext) Debugf(format string, args ...interface{}) {
// Infof logs an informational message for logctx to stdout
func (logctx *LogContext) Infof(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
- if logctx.fields != nil && len(logctx.fields) > 0 {
+ if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Infof(format, args...)
} else {
logger.Infof(format, args...)
@@ -108,7 +108,7 @@ func (logctx *LogContext) Infof(format string, args ...interface{}) {
// Warnf logs a warning message for logctx to stdout
func (logctx *LogContext) Warnf(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
- if logctx.fields != nil && len(logctx.fields) > 0 {
+ if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Warnf(format, args...)
} else {
logger.Warnf(format, args...)
@@ -118,7 +118,7 @@ func (logctx *LogContext) Warnf(format string, args ...interface{}) {
// Errorf logs a non-fatal error message for logctx to stdout
func (logctx *LogContext) Errorf(format string, args ...interface{}) {
logger.SetOutput(logctx.errorOut)
- if logctx.fields != nil && len(logctx.fields) > 0 {
+ if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Errorf(format, args...)
} else {
logger.Errorf(format, args...)
@@ -128,14 +128,14 @@ func (logctx *LogContext) Errorf(format string, args ...interface{}) {
// Fatalf logs a fatal error message for logctx to stdout
func (logctx *LogContext) Fatalf(format string, args ...interface{}) {
logger.SetOutput(logctx.errorOut)
- if logctx.fields != nil && len(logctx.fields) > 0 {
+ if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Fatalf(format, args...)
} else {
logger.Fatalf(format, args...)
}
}
-// Debugf logs a warning message without context to stdout
+// Tracef logs a warning message without context to stdout
func Tracef(format string, args ...interface{}) {
logCtx := NewContext()
logCtx.Tracef(format, args...)