diff options
Diffstat (limited to 'logtail/logtail.go')
| -rw-r--r-- | logtail/logtail.go | 5 |
1 files changed, 5 insertions, 0 deletions
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)) |
