-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Sometimes we need to specify different buffer pools for different loggers. The current version makes it impossible for us to do so!
like:
Logger.SetBufferPool(pool BufferPool)
The advantage of this is that loggers for different purposes can use different buffers.
type LimitBufferPool struct {
pool *sync.Pool
cap int
}
func (p *LimitBufferPool) Put(buf *bytes.Buffer) {
if buf.Cap() > p.cap {
return
}
p.pool.Put(buf)
}
func (p *LimitBufferPool) Get() *bytes.Buffer {
return p.pool.Get().(*bytes.Buffer)
}