|
|
@ -36,6 +36,8 @@ type Logger struct {
|
|
|
|
logf logger.Logf
|
|
|
|
logf logger.Logf
|
|
|
|
|
|
|
|
|
|
|
|
logger *logtail.Logger
|
|
|
|
logger *logtail.Logger
|
|
|
|
|
|
|
|
filch *filch.Filch
|
|
|
|
|
|
|
|
tr *http.Transport
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deltaStat represents the bytes transferred during a time period.
|
|
|
|
// deltaStat represents the bytes transferred during a time period.
|
|
|
@ -88,6 +90,8 @@ func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID) (*Logger,
|
|
|
|
cancelFn: cancel,
|
|
|
|
cancelFn: cancel,
|
|
|
|
ticker: time.NewTicker(pollPeriod),
|
|
|
|
ticker: time.NewTicker(pollPeriod),
|
|
|
|
logf: logf,
|
|
|
|
logf: logf,
|
|
|
|
|
|
|
|
filch: filch,
|
|
|
|
|
|
|
|
tr: logpolicy.NewLogtailTransport(logtail.DefaultHost),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logger.logger = logtail.NewLogger(logtail.Config{
|
|
|
|
logger.logger = logtail.NewLogger(logtail.Config{
|
|
|
|
BaseURL: logpolicy.LogURL(),
|
|
|
|
BaseURL: logpolicy.LogURL(),
|
|
|
@ -107,7 +111,7 @@ func NewLogger(logdir string, logf logger.Logf, logID logid.PublicID) (*Logger,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Stderr: io.Discard, // don't log to stderr
|
|
|
|
Stderr: io.Discard, // don't log to stderr
|
|
|
|
|
|
|
|
|
|
|
|
HTTPC: &http.Client{Transport: logpolicy.NewLogtailTransport(logtail.DefaultHost)},
|
|
|
|
HTTPC: &http.Client{Transport: logger.tr},
|
|
|
|
}, logf)
|
|
|
|
}, logf)
|
|
|
|
|
|
|
|
|
|
|
|
go logger.poll()
|
|
|
|
go logger.poll()
|
|
|
@ -166,8 +170,10 @@ func (l *Logger) Flush() {
|
|
|
|
|
|
|
|
|
|
|
|
func (l *Logger) Shutdown() {
|
|
|
|
func (l *Logger) Shutdown() {
|
|
|
|
l.ticker.Stop()
|
|
|
|
l.ticker.Stop()
|
|
|
|
l.logger.Shutdown(context.Background())
|
|
|
|
l.logger.Shutdown(l.ctx)
|
|
|
|
l.cancelFn()
|
|
|
|
l.cancelFn()
|
|
|
|
|
|
|
|
l.filch.Close()
|
|
|
|
|
|
|
|
l.tr.CloseIdleConnections()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// delta calculates the delta stats between two SockStats snapshots.
|
|
|
|
// delta calculates the delta stats between two SockStats snapshots.
|
|
|
|