tsnet: split user facing and backend logging
This adds a new `UserLogf` field to the `Server` struct. When set this any logs generated by Server are logged using `UserLogf` and all spammy backend logs are logged to `Logf`. If it `UserLogf` is unset, we default to `log.Printf` and if `Logf` is unset we discard all the spammy logs. Fixes #12094 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@ -89,15 +89,6 @@ func ExampleServer_multipleInstances() {
|
||||
}()
|
||||
}
|
||||
|
||||
// ExampleServer_ignoreLogs shows you how to ignore all of the log messages written
|
||||
// by a tsnet instance.
|
||||
func ExampleServer_ignoreLogs() {
|
||||
srv := &tsnet.Server{
|
||||
Logf: func(string, ...any) {},
|
||||
}
|
||||
_ = srv
|
||||
}
|
||||
|
||||
// ExampleServer_ignoreLogsSometimes shows you how to ignore all of the log messages
|
||||
// written by a tsnet instance, but allows you to opt-into them if a command-line
|
||||
// flag is set.
|
||||
@ -107,7 +98,6 @@ func ExampleServer_ignoreLogsSometimes() {
|
||||
|
||||
srv := &tsnet.Server{
|
||||
Hostname: *hostname,
|
||||
Logf: func(string, ...any) {},
|
||||
}
|
||||
|
||||
if *tsnetVerbose {
|
||||
|
Reference in New Issue
Block a user