aboutsummaryrefslogtreecommitdiff
path: root/libpod/events.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/events.go')
-rw-r--r--libpod/events.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/libpod/events.go b/libpod/events.go
index 60142cb60..2f9799114 100644
--- a/libpod/events.go
+++ b/libpod/events.go
@@ -3,6 +3,7 @@ package libpod
import (
"context"
"fmt"
+ "path/filepath"
"sync"
"github.com/containers/podman/v4/libpod/events"
@@ -11,6 +12,10 @@ import (
// newEventer returns an eventer that can be used to read/write events
func (r *Runtime) newEventer() (events.Eventer, error) {
+ if r.config.Engine.EventsLogFilePath == "" {
+ // default, use path under tmpdir when none was explicitly set by the user
+ r.config.Engine.EventsLogFilePath = filepath.Join(r.config.Engine.TmpDir, "events", "events.log")
+ }
options := events.EventerOptions{
EventerType: r.config.Engine.EventsLogger,
LogFilePath: r.config.Engine.EventsLogFilePath,
@@ -133,11 +138,7 @@ func (v *Volume) newVolumeEvent(status events.Status) {
// Events is a wrapper function for everyone to begin tailing the events log
// with options
func (r *Runtime) Events(ctx context.Context, options events.ReadOptions) error {
- eventer, err := r.newEventer()
- if err != nil {
- return err
- }
- return eventer.Read(ctx, options)
+ return r.eventer.Read(ctx, options)
}
// GetEvents reads the event log and returns events based on input filters
@@ -149,10 +150,6 @@ func (r *Runtime) GetEvents(ctx context.Context, filters []string) ([]*events.Ev
FromStart: true,
Stream: false,
}
- eventer, err := r.newEventer()
- if err != nil {
- return nil, err
- }
logEvents := make([]*events.Event, 0, len(eventChannel))
readLock := sync.Mutex{}
@@ -164,7 +161,7 @@ func (r *Runtime) GetEvents(ctx context.Context, filters []string) ([]*events.Ev
readLock.Unlock()
}()
- readErr := eventer.Read(ctx, options)
+ readErr := r.eventer.Read(ctx, options)
readLock.Lock() // Wait for the events to be consumed.
return logEvents, readErr
}