logtail: add Config.Disabled to suppress the startup banner

NewLogger unconditionally writes a "logtail started" banner before
it returns, which callers that later call Logger.SetEnabled(false)
have no way to suppress: the banner is already buffered for upload
by the time the caller gets the logger back.

Add Config.Disabled so callers that know up front they want the
logger to start disabled (e.g. Android's remote-logging opt-out)
can seed the state before NewLogger's internal Write. The process-
wide Disable kill switch still takes precedence; SetEnabled can
still flip the state at runtime.

Updates #13174
Updates tailscale/tailscale-android#695

Change-Id: Icc4fa88c198447cf0faa707264dac84e359fe52c
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2026-04-20 19:15:12 +00:00
committed by Brad Fitzpatrick
parent 4a832d8d0f
commit 5b06e32f33
3 changed files with 84 additions and 0 deletions
+8
View File
@@ -64,4 +64,12 @@ type Config struct {
// being included in the logs. The sequence number is incremented for each
// log message sent, but is not persisted across process restarts.
IncludeProcSequence bool
// Disabled, if true, causes the returned [Logger] to start in the
// disabled state, dropping entries without buffering or uploading
// (equivalent to calling [Logger.SetEnabled] with false immediately).
// It applies before the internal startup banner is written, so no
// log entries are emitted until [Logger.SetEnabled] is called with
// true. The process-wide [Disable] kill switch still takes precedence.
Disabled bool
}