diff --git a/log/logsdk/logjson/option.go b/log/logsdk/logjson/option.go index 8a22402..2929c8d 100644 --- a/log/logsdk/logjson/option.go +++ b/log/logsdk/logjson/option.go @@ -60,10 +60,10 @@ func newConfig(opts ...Option) *config { opt.apply(cfg) } if !cfg.hasPool { - cfg.bytesBufferPool = newBytesBufferPool(512, 4096) + cfg.bytesBufferPool = NewBytesBufferPool(512, 4096) } if cfg.output == nil { - cfg.output = newSyncWriter(os.Stderr) + cfg.output = NewSyncWriter(os.Stderr) } if cfg.timestampFormat == "" { cfg.timestampFormat = time.RFC3339Nano diff --git a/log/logsdk/logjson/pool.go b/log/logsdk/logjson/pool.go index cd99492..7b3bc5b 100644 --- a/log/logsdk/logjson/pool.go +++ b/log/logsdk/logjson/pool.go @@ -10,7 +10,8 @@ type BytesBufferPool interface { Put(buffer *bytes.Buffer) } -func newBytesBufferPool(initialSize, maximumSize int) *bytesBufferPool { +// NewBytesBufferPool 创建并返回 BytesBufferPool +func NewBytesBufferPool(initialSize, maximumSize int) BytesBufferPool { return &bytesBufferPool{ pool: sync.Pool{ New: func() any { diff --git a/log/logsdk/logjson/writer.go b/log/logsdk/logjson/writer.go index fd52d1f..bda4a62 100644 --- a/log/logsdk/logjson/writer.go +++ b/log/logsdk/logjson/writer.go @@ -5,7 +5,8 @@ import ( "sync" ) -func newSyncWriter(writer io.Writer) io.Writer { +// NewSyncWriter 返回写互斥的 io.Writer +func NewSyncWriter(writer io.Writer) io.Writer { return &syncWriter{ writer: writer, lock: sync.Mutex{},