refactor: move scrubbingLogger to the scrubber pkg (#394)

* refactor: move scrubbingLogger to the scrubber pkg

We need it exported so we can use it in the new implementation.

Part of https://github.com/ooni/probe/issues/1687

* fix test
This commit is contained in:
Simone Basso 2021-06-22 14:43:58 +02:00 committed by GitHub
commit 1eb6e758c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 181 additions and 145 deletions

View file

@ -323,44 +323,11 @@ func (rc *resultsCollector) measureSingleTarget(
))
}
// scrubbingLogger is a logger that scrubs endpoints from its output. We are using
// it only here, currently, since we pay some performance penalty in that we evaluate
// the string to be logged regardless of the logging level.
//
// TODO(bassosimone): find a more efficient way of scrubbing logs.
type scrubbingLogger struct {
model.Logger
}
func (sl scrubbingLogger) Debug(message string) {
sl.Logger.Debug(scrubber.Scrub(message))
}
func (sl scrubbingLogger) Debugf(format string, v ...interface{}) {
sl.Debug(fmt.Sprintf(format, v...))
}
func (sl scrubbingLogger) Info(message string) {
sl.Logger.Info(scrubber.Scrub(message))
}
func (sl scrubbingLogger) Infof(format string, v ...interface{}) {
sl.Info(fmt.Sprintf(format, v...))
}
func (sl scrubbingLogger) Warn(message string) {
sl.Logger.Warn(scrubber.Scrub(message))
}
func (sl scrubbingLogger) Warnf(format string, v ...interface{}) {
sl.Warn(fmt.Sprintf(format, v...))
}
func maybeScrubbingLogger(input model.Logger, kt keytarget) model.Logger {
if !kt.private() {
return input
}
return scrubbingLogger{Logger: input}
return &scrubber.Logger{UnderlyingLogger: input}
}
func (rc *resultsCollector) defaultFlexibleConnect(