Skip to content

Commit

Permalink
Update big log size to 4KB from 1KB.
Browse files Browse the repository at this point in the history
  • Loading branch information
edoger committed Mar 12, 2023
1 parent da6e997 commit 21a1bde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions log.go
Expand Up @@ -236,9 +236,9 @@ func (c *core) getEntity(l *log, level Level, message, caller string) *logEntity

// Clean up and recycle the given log entity.
func (c *core) putEntity(o *logEntity) {
// If the log size exceeds 1KB, we need to discard this buffer to
// If the log size exceeds 4KB, we need to discard this buffer to
// free memory faster.
if o.buffer.Cap() > 1024 {
if o.buffer.Cap() > 4096 {
o.buffer = bytes.Buffer{}
} else {
o.buffer.Reset()
Expand Down
8 changes: 4 additions & 4 deletions logger_test.go
Expand Up @@ -656,16 +656,16 @@ func TestLogger_BigLog(t *testing.T) {
o.SetLevel(TraceLevel)

var builder strings.Builder
for i := 0; i < 1500; i++ {
for i := 0; i < 5000; i++ {
builder.WriteByte('x')
}
o.Print(builder.String()) // Big log
if w.Len() < 1024 {
if w.Len() < 5000 {
t.Fatalf("Big log: %d", w.Len())
}
// For logs exceeding 1KB, the buffer will not be reused.
// For logs exceeding 4KB, the buffer will not be reused.
n := o.(*logger).core.pool.Get().(*logEntity).buffer.Cap()
if n > 1024 {
if n > 4096 {
t.Fatalf("Big log: %d", n)
}
}
Expand Down

0 comments on commit 21a1bde

Please sign in to comment.