summaryrefslogtreecommitdiff
path: root/vendor/github.com/sirupsen/logrus/entry.go
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@redhat.com>2022-07-21 09:58:18 +0200
committerMatthew Heon <matthew.heon@pm.me>2022-07-26 13:51:56 -0400
commitdc1dc46006f890f02d9e61ae5ce9caf1a7a2cd60 (patch)
treed12a66321949306ae43c9e609fecdd775f706f2f /vendor/github.com/sirupsen/logrus/entry.go
parent2350ef9dd4c0ffc7c92583b33f63da0bc9502bba (diff)
downloadpodman-dc1dc46006f890f02d9e61ae5ce9caf1a7a2cd60.tar.gz
podman-dc1dc46006f890f02d9e61ae5ce9caf1a7a2cd60.tar.bz2
podman-dc1dc46006f890f02d9e61ae5ce9caf1a7a2cd60.zip
podman-remote pull: fix duplicate progress outputs
By vendoring the fixes from containers/image. Also add a test (thanks @edsantiago) to make sure we won't regress in the future again. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/sirupsen/logrus/entry.go')
-rw-r--r--vendor/github.com/sirupsen/logrus/entry.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go
index 07a1e5fa7..71cdbbc35 100644
--- a/vendor/github.com/sirupsen/logrus/entry.go
+++ b/vendor/github.com/sirupsen/logrus/entry.go
@@ -232,6 +232,7 @@ func (entry *Entry) log(level Level, msg string) {
newEntry.Logger.mu.Lock()
reportCaller := newEntry.Logger.ReportCaller
+ bufPool := newEntry.getBufferPool()
newEntry.Logger.mu.Unlock()
if reportCaller {
@@ -239,11 +240,11 @@ func (entry *Entry) log(level Level, msg string) {
}
newEntry.fireHooks()
-
- buffer = getBuffer()
+ buffer = bufPool.Get()
defer func() {
newEntry.Buffer = nil
- putBuffer(buffer)
+ buffer.Reset()
+ bufPool.Put(buffer)
}()
buffer.Reset()
newEntry.Buffer = buffer
@@ -260,6 +261,13 @@ func (entry *Entry) log(level Level, msg string) {
}
}
+func (entry *Entry) getBufferPool() (pool BufferPool) {
+ if entry.Logger.BufferPool != nil {
+ return entry.Logger.BufferPool
+ }
+ return bufferPool
+}
+
func (entry *Entry) fireHooks() {
var tmpHooks LevelHooks
entry.Logger.mu.Lock()
@@ -276,18 +284,21 @@ func (entry *Entry) fireHooks() {
}
func (entry *Entry) write() {
+ entry.Logger.mu.Lock()
+ defer entry.Logger.mu.Unlock()
serialized, err := entry.Logger.Formatter.Format(entry)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
return
}
- entry.Logger.mu.Lock()
- defer entry.Logger.mu.Unlock()
if _, err := entry.Logger.Out.Write(serialized); err != nil {
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
}
}
+// Log will log a message at the level given as parameter.
+// Warning: using Log at Panic or Fatal level will not respectively Panic nor Exit.
+// For this behaviour Entry.Panic or Entry.Fatal should be used instead.
func (entry *Entry) Log(level Level, args ...interface{}) {
if entry.Logger.IsLevelEnabled(level) {
entry.log(level, fmt.Sprint(args...))