aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-03-27 13:50:54 -0500
committerbaude <bbaude@redhat.com>2019-04-24 16:00:04 -0500
commit7bf7c177ab3f67d5de1689842204c258fca083e4 (patch)
tree960fd1365913209fec61e3226b96a6f8bb1fd051 /libpod/runtime.go
parentd75543fcd2ce87a9b87b8883400f355979004e91 (diff)
downloadpodman-7bf7c177ab3f67d5de1689842204c258fca083e4.tar.gz
podman-7bf7c177ab3f67d5de1689842204c258fca083e4.tar.bz2
podman-7bf7c177ab3f67d5de1689842204c258fca083e4.zip
journald event logging
add the ability for podman to read and write events to journald instead of just a logfile. This can be controlled in libpod.conf with the `events_logger` attribute of `journald` or `file`. The default will be set to `journald`. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 3b1c2be98..38e0e0ff6 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -2,6 +2,7 @@ package libpod
import (
"fmt"
+ "github.com/containers/libpod/libpod/events"
"io/ioutil"
"os"
"path/filepath"
@@ -105,6 +106,9 @@ type Runtime struct {
// storage unusable). When valid is false, the runtime cannot be used.
valid bool
lock sync.RWMutex
+
+ // mechanism to read and write even logs
+ eventer events.Eventer
}
// OCIRuntimePath contains information about an OCI runtime.
@@ -222,6 +226,8 @@ type RuntimeConfig struct {
// pods.
NumLocks uint32 `toml:"num_locks,omitempty"`
+ // EventsLogger determines where events should be logged
+ EventsLogger string `toml:"events_logger"`
// EventsLogFilePath is where the events log is stored.
EventsLogFilePath string `toml:-"events_logfile_path"`
}
@@ -252,7 +258,6 @@ func defaultRuntimeConfig() (RuntimeConfig, error) {
if err != nil {
return RuntimeConfig{}, err
}
-
return RuntimeConfig{
// Leave this empty so containers/storage will use its defaults
StorageConfig: storage.StoreOptions{},
@@ -296,6 +301,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) {
EnablePortReservation: true,
EnableLabeling: true,
NumLocks: 2048,
+ EventsLogger: "journald",
}, nil
}
@@ -755,16 +761,24 @@ func makeRuntime(runtime *Runtime) (err error) {
// Set up image runtime and store in runtime
ir := image.NewImageRuntimeFromStore(runtime.store)
- if err != nil {
- return err
- }
runtime.imageRuntime = ir
// Setting signaturepolicypath
ir.SignaturePolicyPath = runtime.config.SignaturePolicyPath
+
// Set logfile path for events
ir.EventsLogFilePath = runtime.config.EventsLogFilePath
+ // Set logger type
+ ir.EventsLogger = runtime.config.EventsLogger
+
+ // Setup the eventer
+ eventer, err := runtime.newEventer()
+ if err != nil {
+ return err
+ }
+ runtime.eventer = eventer
+ ir.Eventer = eventer
defer func() {
if err != nil && store != nil {