NewLogBuffer creates log buffer with max line number limit. Because we only match logs in the log buffer, the max buffer line number is also the max pattern line number we support. Smaller buffer line number means less memory and cpu usage, but also means less lines of patterns we support.
(maxLines int)
| 46 | // support. Smaller buffer line number means less memory and cpu usage, but also means less |
| 47 | // lines of patterns we support. |
| 48 | func NewLogBuffer(maxLines int) *logBuffer { |
| 49 | return &logBuffer{ |
| 50 | buffer: make([]*types.Log, maxLines), |
| 51 | msg: make([]string, maxLines), |
| 52 | max: maxLines, |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func (b *logBuffer) Push(log *types.Log) { |
| 57 | b.buffer[b.current%b.max] = log |
no outgoing calls