2021-06-22 14:43:58 +02:00
|
|
|
package scrubber
|
|
|
|
|
2022-01-03 13:53:23 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
2021-06-22 14:43:58 +02:00
|
|
|
|
2022-01-03 13:53:23 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
|
|
)
|
2021-06-22 14:43:58 +02:00
|
|
|
|
|
|
|
// Logger is a Logger with scrubbing. All messages are scrubbed
|
|
|
|
// including the ones that won't be emitted. As such, this logger
|
|
|
|
// is less efficient than a logger without scrubbing.
|
|
|
|
type Logger struct {
|
2022-01-03 13:53:23 +01:00
|
|
|
model.Logger
|
2021-06-22 14:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debug scrubs and emits a debug message.
|
|
|
|
func (sl *Logger) Debug(message string) {
|
2022-01-03 13:53:23 +01:00
|
|
|
sl.Logger.Debug(Scrub(message))
|
2021-06-22 14:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugf scrubs, formats, and emits a debug message.
|
|
|
|
func (sl *Logger) Debugf(format string, v ...interface{}) {
|
|
|
|
sl.Debug(fmt.Sprintf(format, v...))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Info scrubs and emits an informational message.
|
|
|
|
func (sl *Logger) Info(message string) {
|
2022-01-03 13:53:23 +01:00
|
|
|
sl.Logger.Info(Scrub(message))
|
2021-06-22 14:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Infof scrubs, formats, and emits an informational message.
|
|
|
|
func (sl *Logger) Infof(format string, v ...interface{}) {
|
|
|
|
sl.Info(fmt.Sprintf(format, v...))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Warn scrubs and emits a warning message.
|
|
|
|
func (sl *Logger) Warn(message string) {
|
2022-01-03 13:53:23 +01:00
|
|
|
sl.Logger.Warn(Scrub(message))
|
2021-06-22 14:43:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Warnf scrubs, formats, and emits a warning message.
|
|
|
|
func (sl *Logger) Warnf(format string, v ...interface{}) {
|
|
|
|
sl.Warn(fmt.Sprintf(format, v...))
|
|
|
|
}
|