debian-forge-composer/internal/upload/koji/rh-logrus-adapter.go
Diaa Sami 3ab2725042 koji: Reduce excessive logging by retryablehttp
Use LeveledLogger
Fixes COMPOSER-1394
2022-03-09 23:18:25 +00:00

34 lines
871 B
Go

package koji
import (
"github.com/sirupsen/logrus"
)
type LeveledLogrus struct {
*logrus.Logger
}
func (l *LeveledLogrus) fields(keysAndValues ...interface{}) map[string]interface{} {
fields := make(map[string]interface{})
for i := 0; i < len(keysAndValues)-1; i += 2 {
fields[keysAndValues[i].(string)] = keysAndValues[i+1]
}
return fields
}
func (l *LeveledLogrus) Error(msg string, keysAndValues ...interface{}) {
l.WithFields(l.fields(keysAndValues...)).Error(msg)
}
func (l *LeveledLogrus) Info(msg string, keysAndValues ...interface{}) {
l.WithFields(l.fields(keysAndValues...)).Info(msg)
}
func (l *LeveledLogrus) Debug(msg string, keysAndValues ...interface{}) {
l.WithFields(l.fields(keysAndValues...)).Debug(msg)
}
func (l *LeveledLogrus) Warn(msg string, keysAndValues ...interface{}) {
l.WithFields(l.fields(keysAndValues...)).Warn(msg)
}