summaryrefslogtreecommitdiffhomepage
path: root/logtail
diff options
context:
space:
mode:
Diffstat (limited to 'logtail')
-rw-r--r--logtail/config.go1
-rw-r--r--logtail/logtail.go5
2 files changed, 6 insertions, 0 deletions
diff --git a/logtail/config.go b/logtail/config.go
index bf47dd8aa..44e0ff922 100644
--- a/logtail/config.go
+++ b/logtail/config.go
@@ -30,6 +30,7 @@ type Config struct {
PrivateID logid.PrivateID // private ID for the primary log stream
CopyPrivateID logid.PrivateID // private ID for a log stream that is a superset of this log stream
BaseURL string // if empty defaults to "https://log.tailscale.com"
+ HTTPAuth string // if set, specifies the Authorization HTTP header to send
HTTPC *http.Client // if empty defaults to http.DefaultClient
SkipClientTime bool // if true, client_time is not written to logs
LowMemory bool // if true, logtail minimizes memory use
diff --git a/logtail/logtail.go b/logtail/logtail.go
index ce50c1c0a..50ccaf373 100644
--- a/logtail/logtail.go
+++ b/logtail/logtail.go
@@ -106,6 +106,7 @@ func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
privateID: cfg.PrivateID,
stderr: cfg.Stderr,
stderrLevel: int64(cfg.StderrLevel),
+ httpAuth: cfg.HTTPAuth,
httpc: cfg.HTTPC,
url: cfg.BaseURL + "/c/" + cfg.Collection + "/" + cfg.PrivateID.String() + urlSuffix,
lowMem: cfg.LowMemory,
@@ -146,6 +147,7 @@ func NewLogger(cfg Config, logf tslogger.Logf) *Logger {
type Logger struct {
stderr io.Writer
stderrLevel int64 // accessed atomically
+ httpAuth string
httpc *http.Client
url string
lowMem bool
@@ -500,6 +502,9 @@ func (lg *Logger) upload(ctx context.Context, body []byte, origlen int) (retryAf
// TODO record logs to disk
panic("logtail: cannot build http request: " + err.Error())
}
+ if lg.httpAuth != "" {
+ req.Header.Add("Authorization", lg.httpAuth)
+ }
if origlen != -1 {
req.Header.Add("Content-Encoding", "zstd")
req.Header.Add("Orig-Content-Length", strconv.Itoa(origlen))