1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

75
testutil/log.go Normal file
View file

@ -0,0 +1,75 @@
package testutil
import (
"log"
"github.com/influxdata/telegraf"
)
var _ telegraf.Logger = &Logger{}
type Logger struct {
Name string // Name is the plugin name, will be printed in the `[]`.
Quiet bool
}
// We always want to output at debug level during testing to find issues easier
func (Logger) Level() telegraf.LogLevel {
return telegraf.Debug
}
// Adding attributes is not supported by the test-logger
func (Logger) AddAttribute(string, interface{}) {}
func (l Logger) Errorf(format string, args ...interface{}) {
log.Printf("E! ["+l.Name+"] "+format, args...)
}
func (l Logger) Error(args ...interface{}) {
log.Print(append([]interface{}{"E! [" + l.Name + "] "}, args...)...)
}
func (l Logger) Warnf(format string, args ...interface{}) {
log.Printf("W! ["+l.Name+"] "+format, args...)
}
func (l Logger) Warn(args ...interface{}) {
log.Print(append([]interface{}{"W! [" + l.Name + "] "}, args...)...)
}
func (l Logger) Infof(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("I! ["+l.Name+"] "+format, args...)
}
}
func (l Logger) Info(args ...interface{}) {
if !l.Quiet {
log.Print(append([]interface{}{"I! [" + l.Name + "] "}, args...)...)
}
}
func (l Logger) Debugf(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("D! ["+l.Name+"] "+format, args...)
}
}
func (l Logger) Debug(args ...interface{}) {
if !l.Quiet {
log.Print(append([]interface{}{"D! [" + l.Name + "] "}, args...)...)
}
}
func (l Logger) Tracef(format string, args ...interface{}) {
if !l.Quiet {
log.Printf("T! ["+l.Name+"] "+format, args...)
}
}
// Trace logs a trace message, patterned after log.Print.
func (l Logger) Trace(args ...interface{}) {
if !l.Quiet {
log.Print(append([]interface{}{"T! [" + l.Name + "] "}, args...)...)
}
}