summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2022-06-09 14:52:43 -0700
committerJoe Tsai <joetsai@digital-static.net>2022-06-09 14:57:33 -0700
commit840785fcd961dd0069371c3136b8d99b864c4a08 (patch)
tree0e0b200ab49cd245109321e16447ee762a73def7
parent96f73b38946f5acc09ee8718171054155ebda32d (diff)
downloadtailscale-dsnet/tsnet-logging.tar.xz
tailscale-dsnet/tsnet-logging.zip
tsnet: do not log using log.Printf by defaultdsnet/tsnet-logging
Printing to log.Printf by default made sense when there was no automatic uploading to log.tailscale.io. However, now that we support that by default, logging to log.Printf if Server.Logf is nil seems superfluous. The tsnet package is also intended to be instantiated as a library. Thus, a single process can multiple tsnet instances running simultaneously. The default behavior of each logging to log.Printf makes the os.Stderr of the main process unreadable. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
-rw-r--r--tsnet/tsnet.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/tsnet/tsnet.go b/tsnet/tsnet.go
index 41e733564..e9d72dad1 100644
--- a/tsnet/tsnet.go
+++ b/tsnet/tsnet.go
@@ -11,7 +11,6 @@ import (
"context"
"fmt"
"io/ioutil"
- "log"
"net"
"net/http"
"os"
@@ -62,8 +61,8 @@ type Server struct {
// If empty, the binary name is used.
Hostname string
- // Logf, if non-nil, specifies the logger to use. By default,
- // log.Printf is used.
+ // Logf, if non-nil, specifies an additional logger to use such that
+ // logs are both written here and uploaded to log.tailscale.io.
Logf logger.Logf
// Ephemeral, if true, specifies that the instance should register
@@ -331,9 +330,7 @@ func (s *Server) logf(format string, a ...interface{}) {
}
if s.Logf != nil {
s.Logf(format, a...)
- return
}
- log.Printf(format, a...)
}
// printAuthURLLoop loops once every few seconds while the server is still running and