koji: promote relevant logs to Info for monitoring
Add support for promoting certain `Debug` log messages to `Info` so we can monitor them while the logging level set to `Info`, having it set to Debug is far too noisy.
This commit is contained in:
parent
e6475d0e0e
commit
ed5cd56c5a
1 changed files with 9 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package koji
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
|
@ -8,6 +10,8 @@ type LeveledLogrus struct {
|
|||
*logrus.Logger
|
||||
}
|
||||
|
||||
const monitoringKeyword = "retrying"
|
||||
|
||||
func fields(keysAndValues ...interface{}) map[string]interface{} {
|
||||
fields := make(map[string]interface{})
|
||||
|
||||
|
|
@ -26,7 +30,11 @@ 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)
|
||||
if strings.Contains(msg, monitoringKeyword) {
|
||||
l.WithFields(fields(keysAndValues...)).Info(msg)
|
||||
} else {
|
||||
l.WithFields(fields(keysAndValues...)).Debug(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LeveledLogrus) Warn(msg string, keysAndValues ...interface{}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue