debian-forge-composer/internal/upload/koji/rh-logrus-adapter.go
Diaa Sami e6475d0e0e koji: make function non-member
follow-up to PR-2397
2022-04-05 23:48:30 +02:00

34 lines
850 B
Go

package koji
import (
"github.com/sirupsen/logrus"
)
type LeveledLogrus struct {
*logrus.Logger
}
func 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(fields(keysAndValues...)).Error(msg)
}
func (l *LeveledLogrus) Info(msg string, keysAndValues ...interface{}) {
l.WithFields(fields(keysAndValues...)).Info(msg)
}
func (l *LeveledLogrus) Debug(msg string, keysAndValues ...interface{}) {
l.WithFields(fields(keysAndValues...)).Debug(msg)
}
func (l *LeveledLogrus) Warn(msg string, keysAndValues ...interface{}) {
l.WithFields(fields(keysAndValues...)).Warn(msg)
}