diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-09-29 13:20:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 13:20:30 +0000 |
commit | 84dede4452d4f85ad6dacf2c66e00500685c24af (patch) | |
tree | 670e0208837a7acf0a8b53eda463b57e55d353d8 /vendor/github.com/sirupsen/logrus/buffer_pool.go | |
parent | 5cf865926ed62c8baa691f96e8fe5f585e077083 (diff) | |
parent | e6789cb3e8aaaa54cd80e953f730f358b861f167 (diff) | |
download | podman-84dede4452d4f85ad6dacf2c66e00500685c24af.tar.gz podman-84dede4452d4f85ad6dacf2c66e00500685c24af.tar.bz2 podman-84dede4452d4f85ad6dacf2c66e00500685c24af.zip |
Merge pull request #7819 from containers/dependabot/go_modules/github.com/sirupsen/logrus-1.7.0
Bump github.com/sirupsen/logrus from 1.6.0 to 1.7.0
Diffstat (limited to 'vendor/github.com/sirupsen/logrus/buffer_pool.go')
-rw-r--r-- | vendor/github.com/sirupsen/logrus/buffer_pool.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/github.com/sirupsen/logrus/buffer_pool.go b/vendor/github.com/sirupsen/logrus/buffer_pool.go new file mode 100644 index 000000000..4545dec07 --- /dev/null +++ b/vendor/github.com/sirupsen/logrus/buffer_pool.go @@ -0,0 +1,52 @@ +package logrus + +import ( + "bytes" + "sync" +) + +var ( + bufferPool BufferPool +) + +type BufferPool interface { + Put(*bytes.Buffer) + Get() *bytes.Buffer +} + +type defaultPool struct { + pool *sync.Pool +} + +func (p *defaultPool) Put(buf *bytes.Buffer) { + p.pool.Put(buf) +} + +func (p *defaultPool) Get() *bytes.Buffer { + return p.pool.Get().(*bytes.Buffer) +} + +func getBuffer() *bytes.Buffer { + return bufferPool.Get() +} + +func putBuffer(buf *bytes.Buffer) { + buf.Reset() + bufferPool.Put(buf) +} + +// SetBufferPool allows to replace the default logrus buffer pool +// to better meets the specific needs of an application. +func SetBufferPool(bp BufferPool) { + bufferPool = bp +} + +func init() { + SetBufferPool(&defaultPool{ + pool: &sync.Pool{ + New: func() interface{} { + return new(bytes.Buffer) + }, + }, + }) +} |