From 152882bf19e1c94110187264ed37d25976bf1e73 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 21 Nov 2017 13:51:51 -0500 Subject: Add ability to retrieve container's log path to API Signed-off-by: Matthew Heon Closes: #56 Approved by: rhatdan --- libpod/container.go | 13 +++++++++++++ libpod/oci.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/container.go b/libpod/container.go index 710ae866b..f167adc35 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -150,6 +150,14 @@ func (c *Container) Labels() map[string]string { return labels } +// LogPath returns the path to the container's log file +// This file will only be present after Init() is called to create the container +// in runc +func (c *Container) LogPath() string { + // TODO store this in state and allow overriding + return c.logPath() +} + // State returns the current state of the container func (c *Container) State() (ContainerState, error) { c.lock.Lock() @@ -181,6 +189,11 @@ func (c *Container) bundlePath() string { return c.state.RunDir } +// The path to the container's logs file +func (c *Container) logPath() string { + return filepath.Join(c.config.StaticDir, "ctr.log") +} + // Retrieves the path of the container's attach socket func (c *Container) attachSocketPath() string { return filepath.Join(c.runtime.ociRuntime.socketsDir, c.ID(), "attach") diff --git a/libpod/oci.go b/libpod/oci.go index 3ad3fdd8e..ddbd2f606 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -139,7 +139,7 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) error args = append(args, "-p", filepath.Join(ctr.state.RunDir, "pidfile")) // TODO container log location should be configurable // The default also likely shouldn't be this - args = append(args, "-l", filepath.Join(ctr.config.StaticDir, "ctr.log")) + args = append(args, "-l", ctr.logPath()) args = append(args, "--exit-dir", r.exitsDir) args = append(args, "--socket-dir-path", r.socketsDir) if ctr.config.Spec.Process.Terminal { -- cgit v1.2.3-54-g00ecf