273b70bacc
## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/1885 - [x] related ooni/spec pull request: N/A Location of the issue tracker: https://github.com/ooni/probe ## Description This PR contains a set of changes to move important interfaces and data types into the `./internal/model` package. The criteria for including an interface or data type in here is roughly that the type should be important and used by several packages. We are especially interested to move more interfaces here to increase modularity. An additional side effect is that, by reading this package, one should be able to understand more quickly how different parts of the codebase interact with each other. This is what I want to move in `internal/model`: - [x] most important interfaces from `internal/netxlite` - [x] everything that was previously part of `internal/engine/model` - [x] mocks from `internal/netxlite/mocks` should also be moved in here as a subpackage
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package scrubber
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
)
|
|
|
|
// 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 {
|
|
model.Logger
|
|
}
|
|
|
|
// Debug scrubs and emits a debug message.
|
|
func (sl *Logger) Debug(message string) {
|
|
sl.Logger.Debug(Scrub(message))
|
|
}
|
|
|
|
// 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) {
|
|
sl.Logger.Info(Scrub(message))
|
|
}
|
|
|
|
// 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) {
|
|
sl.Logger.Warn(Scrub(message))
|
|
}
|
|
|
|
// Warnf scrubs, formats, and emits a warning message.
|
|
func (sl *Logger) Warnf(format string, v ...interface{}) {
|
|
sl.Warn(fmt.Sprintf(format, v...))
|
|
}
|