mirror of
https://github.com/tailscale/tailscale.git
synced 2026-05-06 04:36:15 +02:00
Callers that need to turn logtail uploads on and off in response to user preference or policy changes previously had no choice: the package-level Disable is a one-way kill switch intended for the controlplane DisableLogTail debug message, and requires a process restart to undo. Add a per-Logger disabled flag, toggled via SetEnabled, that drops incoming entries without buffering while disabled. The process-wide Disable still takes precedence, so a controlplane-issued kill switch cannot be overridden by a client setting it back on. To simplify https://github.com/tailscale/tailscale-android/pull/695 Updates #13174 Change-Id: I06e75bd719c851f5f837ca5b2d1e17f7c68355f0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
47 lines
1011 B
Go
47 lines
1011 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build ts_omit_logtail
|
|
|
|
package logtail
|
|
|
|
import (
|
|
"context"
|
|
|
|
tslogger "tailscale.com/types/logger"
|
|
"tailscale.com/types/logid"
|
|
)
|
|
|
|
// Noop implementations of everything when ts_omit_logtail is set.
|
|
|
|
type Logger struct{}
|
|
|
|
type Buffer any
|
|
|
|
func Disable() {}
|
|
|
|
func (*Logger) SetEnabled(enabled bool) {}
|
|
|
|
func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
|
|
return &Logger{}
|
|
}
|
|
|
|
func (*Logger) Write(p []byte) (n int, err error) {
|
|
return len(p), nil
|
|
}
|
|
|
|
func (*Logger) Logf(format string, args ...any) {}
|
|
func (*Logger) Shutdown(ctx context.Context) error { return nil }
|
|
func (*Logger) SetVerbosityLevel(level int) {}
|
|
|
|
func (l *Logger) SetSockstatsLabel(label any) {}
|
|
|
|
func (l *Logger) PrivateID() logid.PrivateID { return logid.PrivateID{} }
|
|
func (l *Logger) StartFlush() {}
|
|
|
|
func RegisterLogTap(dst chan<- string) (unregister func()) {
|
|
return func() {}
|
|
}
|
|
|
|
func (*Logger) SetNetMon(any) {}
|