save source buffer index start for log files

This commit is contained in:
chrislu
2025-09-01 23:33:35 -07:00
parent f5ed25f755
commit 7ca3b59c44
6 changed files with 325 additions and 13 deletions
+15
View File
@@ -63,6 +63,7 @@ func NewLogBuffer(name string, flushInterval time.Duration, flushFn LogFlushFunc
notifyFn: notifyFn,
flushChan: make(chan *dataToFlush, 256),
isStopping: new(atomic.Bool),
batchIndex: time.Now().UnixNano(), // Initialize with process start time for uniqueness
}
go lb.loopFlush()
go lb.loopInterval()
@@ -343,6 +344,20 @@ func (logBuffer *LogBuffer) ReleaseMemory(b *bytes.Buffer) {
bufferPool.Put(b)
}
// GetName returns the log buffer name for metadata tracking
func (logBuffer *LogBuffer) GetName() string {
logBuffer.RLock()
defer logBuffer.RUnlock()
return logBuffer.name
}
// GetBatchIndex returns the current batch index for metadata tracking
func (logBuffer *LogBuffer) GetBatchIndex() int64 {
logBuffer.RLock()
defer logBuffer.RUnlock()
return logBuffer.batchIndex
}
var bufferPool = sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)