chore: fix data race (#1593)

This commit is contained in:
Kevin Wan
2022-02-28 23:17:51 +08:00
committed by GitHub
parent cf7c7cb392
commit 259a5a13e7
8 changed files with 40 additions and 37 deletions

View File

@@ -3,6 +3,7 @@ package logx
import (
"fmt"
"io"
"sync/atomic"
"time"
"github.com/zeromicro/go-zero/core/timex"
@@ -79,7 +80,7 @@ func (l *durationLogger) WithDuration(duration time.Duration) Logger {
}
func (l *durationLogger) write(writer io.Writer, level string, val interface{}) {
switch encoding {
switch atomic.LoadUint32(&encoding) {
case plainEncodingType:
writePlainAny(writer, level, val, l.Duration)
default: