mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-07 16:17:41 +00:00
logtail: support a copy ID (#5851)
The copy ID operates similar to a CC in email where a message is sent to both the primary ID and also the copy ID. A given log message is uploaded once, but the log server records it twice for each ID. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
parent
24ebf161e8
commit
c321363d2c
@ -44,7 +44,8 @@ type Encoder interface {
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Collection string // collection name, a domain name
|
Collection string // collection name, a domain name
|
||||||
PrivateID PrivateID // machine-specific private identifier
|
PrivateID PrivateID // private ID for the primary log stream
|
||||||
|
CopyPrivateID PrivateID // private ID for a log stream that is a superset of this log stream
|
||||||
BaseURL string // if empty defaults to "https://log.tailscale.io"
|
BaseURL string // if empty defaults to "https://log.tailscale.io"
|
||||||
HTTPC *http.Client // if empty defaults to http.DefaultClient
|
HTTPC *http.Client // if empty defaults to http.DefaultClient
|
||||||
SkipClientTime bool // if true, client_time is not written to logs
|
SkipClientTime bool // if true, client_time is not written to logs
|
||||||
@ -112,12 +113,16 @@ func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
|
|||||||
stdLogf := func(f string, a ...any) {
|
stdLogf := func(f string, a ...any) {
|
||||||
fmt.Fprintf(cfg.Stderr, strings.TrimSuffix(f, "\n")+"\n", a...)
|
fmt.Fprintf(cfg.Stderr, strings.TrimSuffix(f, "\n")+"\n", a...)
|
||||||
}
|
}
|
||||||
|
var urlSuffix string
|
||||||
|
if !cfg.CopyPrivateID.IsZero() {
|
||||||
|
urlSuffix = "?copyId=" + cfg.CopyPrivateID.String()
|
||||||
|
}
|
||||||
l := &Logger{
|
l := &Logger{
|
||||||
privateID: cfg.PrivateID,
|
privateID: cfg.PrivateID,
|
||||||
stderr: cfg.Stderr,
|
stderr: cfg.Stderr,
|
||||||
stderrLevel: int64(cfg.StderrLevel),
|
stderrLevel: int64(cfg.StderrLevel),
|
||||||
httpc: cfg.HTTPC,
|
httpc: cfg.HTTPC,
|
||||||
url: cfg.BaseURL + "/c/" + cfg.Collection + "/" + cfg.PrivateID.String(),
|
url: cfg.BaseURL + "/c/" + cfg.Collection + "/" + cfg.PrivateID.String() + urlSuffix,
|
||||||
lowMem: cfg.LowMemory,
|
lowMem: cfg.LowMemory,
|
||||||
buffer: cfg.Buffer,
|
buffer: cfg.Buffer,
|
||||||
skipClientTime: cfg.SkipClientTime,
|
skipClientTime: cfg.SkipClientTime,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user