// at most once per "crunchLogSecondsBetweenEvents" seconds.
func NewThrottledLogger(writer io.WriteCloser) *ThrottledLogger {
tl := &ThrottledLogger{}
- tl.flush = make(chan struct{})
+ tl.flush = make(chan struct{}, 1)
tl.stopped = make(chan struct{})
tl.stopping = make(chan struct{})
tl.writer = writer
}
}
- if (int64(arvlog.bufToFlush.Len()) > crunchLogBytesPerEvent ||
+ if (int64(arvlog.bufToFlush.Len()) >= crunchLogBytesPerEvent ||
(now.Sub(arvlog.bufFlushedAt) >= crunchLogSecondsBetweenEvents) ||
arvlog.closing) && (arvlog.bufToFlush.Len() > 0) {
// write to API