cleanup(netx): another batch of small/simple cleanups (#789)

See https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso 2022-06-02 13:50:34 +02:00 committed by GitHub
commit ae24ba644c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 149 deletions

View file

@ -69,3 +69,12 @@ func ErrorToStringOrOK(err error) string {
}
return "ok"
}
// ValidLoggerOrDefault is a factory that either returns the logger
// provided as argument, if not nil, or DiscardLogger.
func ValidLoggerOrDefault(logger Logger) Logger {
if logger != nil {
return logger
}
return DiscardLogger
}