v0.1.13 follow a replaced, removed, moved log file properly
Test / test (push) Canceled after 0s
Test / fuzz (./compat, FuzzParseFormat) (push) Canceled after 0s
Test / fuzz (./formatter, FuzzFormatJSON) (push) Canceled after 0s
Test / fuzz (./formatter, FuzzFormatTextPolicy) (push) Canceled after 0s
Test / fuzz (./sanitizer, FuzzSanitize) (push) Canceled after 0s
Test / fuzz (./sanitizer, FuzzSerializerJSON) (push) Canceled after 0s

This commit is contained in:
Claude authored and Lixen Wraith committed 2026-10-15 16:54:39 -04:00
1 parent fe711ed2a5
commit f9b8770303
14 files changed
+425 -51

No files matched your search

+38 -3
View File
@@ -2,11 +2,12 @@ package log
import (
"testing"
"time"
)
// These benchmarks measure the producer path: format selection, channel send,
// and drop accounting. File writes complete asynchronously in the processor and
// are not attributed to the measured iterations.
// The benchmarks up to BenchmarkProcessLogRecord measure the producer path:
// format selection, channel send, and drop accounting. File writes complete
// asynchronously in the processor and are not attributed to their iterations.
// BenchmarkLoggerInfo measures the default raw-format path.
func BenchmarkLoggerInfo(b *testing.B) {
@@ -95,3 +96,37 @@ func BenchmarkConcurrentLogging(b *testing.B) {
}
})
}
// BenchmarkProcessLogRecord measures the processor's write path, which the
// producer benchmarks above do not see. Record stamps advance by step to stand
// for a logging rate: at 100/s every record is due a log path check.
func BenchmarkProcessLogRecord(b *testing.B) {
for _, bc := range []struct {
name string
step time.Duration // 0: time.Now per record, as emit stamps it
}{{"ts=now", 0}, {"rate=1k/s", time.Millisecond}, {"rate=100/s", 10 * time.Millisecond}} {
b.Run(bc.name, func(b *testing.B) {
l := NewLogger()
c := DefaultConfig()
c.EnableConsole = false
c.EnableFile = true
c.Directory = b.TempDir()
c.Format = "txt"
c.MaxSizeKB = 0
mustNoErr(b, l.ApplyConfig(c), "ApplyConfig") // not started: the benchmark is the processor
b.Cleanup(func() { _ = l.Shutdown() })
rec := logRecord{Flags: l.getFlags(), Level: LevelInfo, Args: []any{"benchmark message", 42}}
ts := time.Now()
b.ReportAllocs()
for b.Loop() {
if ts = ts.Add(bc.step); bc.step == 0 {
ts = time.Now()
}
rec.TimeStamp = ts
if l.processLogRecord(rec) == 0 {
b.Fatal("record not written")
}
}
})
}
}