all: pass log IDs as the proper type rather than strings

This change focuses on the backend log ID, which is the mostly commonly
used in the client.  Tests which don't seem to make use of the log ID
just use the zero value.

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-03-23 10:49:56 -07:00
committed by Will Norris
parent 13377e6458
commit 57a008a1e1
18 changed files with 53 additions and 39 deletions

View File

@ -48,6 +48,7 @@ import (
"tailscale.com/net/tsdial"
"tailscale.com/smallzstd"
"tailscale.com/types/logger"
"tailscale.com/types/logid"
"tailscale.com/types/nettype"
"tailscale.com/util/mak"
"tailscale.com/wgengine"
@ -118,7 +119,7 @@ type Server struct {
localClient *tailscale.LocalClient // in-memory
logbuffer *filch.Filch
logtail *logtail.Logger
logid string
logid logid.PublicID
mu sync.Mutex
listeners map[listenKey]*listener
@ -573,7 +574,6 @@ func (s *Server) start() (reterr error) {
func (s *Server) startLogger(closePool *closeOnErrorPool) error {
if inTest() {
s.logid = "test"
return nil
}
cfgPath := filepath.Join(s.rootPath, "tailscaled.log.conf")
@ -590,7 +590,7 @@ func (s *Server) startLogger(closePool *closeOnErrorPool) error {
if err := lpc.Validate(logtail.CollectionNode); err != nil {
return fmt.Errorf("logpolicy.Config.Validate for %v: %w", cfgPath, err)
}
s.logid = lpc.PublicID.String()
s.logid = lpc.PublicID
s.logbuffer, err = filch.New(filepath.Join(s.rootPath, "tailscaled"), filch.Options{ReplaceStderr: false})
if err != nil {