From 715eb86cec9e11994f36e5f146954c03fffd0d5a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 22 Feb 2017 01:40:24 +0000 Subject: [PATCH] Add ability to disable logging output --- cli/setup.go | 1 + cli/start.go | 4 +++- log/log.go | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/setup.go b/cli/setup.go index 8993a14e..10dd4714 100644 --- a/cli/setup.go +++ b/cli/setup.go @@ -258,6 +258,7 @@ func setup() { if opts.Logging.Output != "" { chk := map[string]bool{ + "none": true, "stdout": true, "stderr": true, } diff --git a/cli/start.go b/cli/start.go index 513f55b3..f877546a 100644 --- a/cli/start.go +++ b/cli/start.go @@ -31,7 +31,9 @@ var startCmd = &cobra.Command{ Short: "Start the database and http server", PreRun: func(cmd *cobra.Command, args []string) { - fmt.Print(logo) + if opts.Logging.Output != "none" { + fmt.Print(logo) + } }, RunE: func(cmd *cobra.Command, args []string) (err error) { diff --git a/log/log.go b/log/log.go index d94f489d..63242a33 100644 --- a/log/log.go +++ b/log/log.go @@ -18,6 +18,8 @@ import ( "os" "time" + "io/ioutil" + "github.com/sirupsen/logrus" ) @@ -230,6 +232,8 @@ func (l *Logger) SetFormat(v string) { // SetOutput sets the logging output of the logger instance. func (l *Logger) SetOutput(v string) { switch v { + case "none": + l.Out = ioutil.Discard case "stdout": l.Out = os.Stdout case "stderr":