cmd/tailscale,ipn/ipnlocal: print debug component names

Make the 'tailscale debug component-logs' command print the component names for
which extra logging can be turned on, for easier discoverability of debug
functions.

Updates #cleanup

Co-authored-by: Paul Scott <paul@tailscale.com>
Signed-off-by: Val <valerie@tailscale.com>
This commit is contained in:
Val
2023-10-03 12:31:56 +02:00
committed by valscale
parent 5efd5e093e
commit 73e53dcd1c
3 changed files with 14 additions and 11 deletions

View File

@@ -386,7 +386,7 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo
b.logf("[unexpected] failed to wire up PeerAPI port for engine %T", e)
}
for _, component := range debuggableComponents {
for _, component := range ipn.DebuggableComponents {
key := componentStateKey(component)
if ut, err := ipn.ReadStoreInt(pm.Store(), key); err == nil {
if until := time.Unix(ut, 0); until.After(b.clock.Now()) {
@@ -404,11 +404,6 @@ type componentLogState struct {
timer tstime.TimerController // if non-nil, the AfterFunc to disable it
}
var debuggableComponents = []string{
"magicsock",
"sockstats",
}
func componentStateKey(component string) ipn.StateKey {
return ipn.StateKey("_debug_" + component + "_until")
}
@@ -440,7 +435,7 @@ func (b *LocalBackend) SetComponentDebugLogging(component string, until time.Tim
}
}
}
if setEnabled == nil || !slices.Contains(debuggableComponents, component) {
if setEnabled == nil || !slices.Contains(ipn.DebuggableComponents, component) {
return fmt.Errorf("unknown component %q", component)
}
timeUnixOrZero := func(t time.Time) int64 {