From e615b7d67124c548a3c7b422348821204ce32775 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 12 Jul 2018 14:34:37 -0400 Subject: Log all output of logrus to syslog as well as stdout/stderr Signed-off-by: Daniel J Walsh Closes: #1084 Approved by: baude --- cmd/podman/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cmd') diff --git a/cmd/podman/main.go b/cmd/podman/main.go index fefd8fdad..f533a8b13 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -14,7 +14,9 @@ import ( "github.com/projectatomic/libpod/pkg/rootless" "github.com/projectatomic/libpod/version" "github.com/sirupsen/logrus" + lsyslog "github.com/sirupsen/logrus/hooks/syslog" "github.com/urfave/cli" + "log/syslog" ) // This is populated by the Makefile from the VERSION file @@ -94,6 +96,12 @@ func main() { } app.Before = func(c *cli.Context) error { + if c.GlobalBool("syslog") { + hook, err := lsyslog.NewSyslogHook("", "", syslog.LOG_INFO, "") + if err == nil { + logrus.AddHook(hook) + } + } logLevel := c.GlobalString("log-level") if logLevel != "" { level, err := logrus.ParseLevel(logLevel) @@ -187,6 +195,10 @@ func main() { Name: "storage-opt", Usage: "used to pass an option to the storage driver", }, + cli.BoolFlag{ + Name: "syslog", + Usage: "output logging information to syslog as well as the console", + }, } if _, err := os.Stat("/etc/containers/registries.conf"); err != nil { if os.IsNotExist(err) { -- cgit v1.2.3-54-g00ecf