forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logging): Add 'trace' log-level (influxdata#15695)
- Loading branch information
Showing
25 changed files
with
205 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
package kafka | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/IBM/sarama" | ||
|
||
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/logger" | ||
) | ||
|
||
type Logger struct { | ||
} | ||
var ( | ||
log = logger.New("sarama", "", "") | ||
once sync.Once | ||
) | ||
|
||
// DebugLogger logs messages from sarama at the debug level. | ||
type DebugLogger struct { | ||
Log telegraf.Logger | ||
} | ||
type debugLogger struct{} | ||
|
||
func (l *DebugLogger) Print(v ...interface{}) { | ||
l.Log.Debug(v...) | ||
func (l *debugLogger) Print(v ...interface{}) { | ||
log.Trace(v...) | ||
} | ||
|
||
func (l *DebugLogger) Printf(format string, v ...interface{}) { | ||
l.Log.Debugf(format, v...) | ||
func (l *debugLogger) Printf(format string, v ...interface{}) { | ||
log.Tracef(format, v...) | ||
} | ||
|
||
func (l *DebugLogger) Println(v ...interface{}) { | ||
func (l *debugLogger) Println(v ...interface{}) { | ||
l.Print(v...) | ||
} | ||
|
||
// SetLogger configures a debug logger for kafka (sarama) | ||
func (k *Logger) SetLogger() { | ||
sarama.Logger = &DebugLogger{Log: logger.New("sarama", "", "")} | ||
func SetLogger(level telegraf.LogLevel) { | ||
// Set-up the sarama logger only once | ||
once.Do(func() { | ||
sarama.Logger = &debugLogger{} | ||
}) | ||
// Increase the log-level if needed. | ||
if !log.Level().Includes(level) { | ||
log.SetLevel(level) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.