From b58cbda5041409df2b4655cb4bc6c498a4e0b05d Mon Sep 17 00:00:00 2001 From: Emily Casey Date: Thu, 28 Mar 2019 15:08:16 -0400 Subject: [PATCH] surpresses ggcr output * NOTE: we are silencing the standard logger * all lifecycle phases must create and use their own logger [buildpack/roadmap#45] Signed-off-by: Emily Casey Signed-off-by: Danny Joyce --- cmd/analyzer/main.go | 4 ++++ cmd/builder/main.go | 5 +++++ cmd/cacher/main.go | 3 +++ cmd/cmd.go | 3 ++- cmd/detector/main.go | 3 +++ cmd/exporter/main.go | 3 +++ cmd/restorer/main.go | 4 ++++ 7 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd/analyzer/main.go b/cmd/analyzer/main.go index b059e41e6..3d36ae0b7 100644 --- a/cmd/analyzer/main.go +++ b/cmd/analyzer/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "io/ioutil" "log" "os" @@ -34,6 +35,9 @@ func init() { } func main() { + // suppress output from libraries, lifecycle will not use standard logger + log.SetOutput(ioutil.Discard) + flag.Parse() repoName = flag.Arg(0) if flag.NArg() > 1 || repoName == "" { diff --git a/cmd/builder/main.go b/cmd/builder/main.go index 093849ee3..064d3627a 100644 --- a/cmd/builder/main.go +++ b/cmd/builder/main.go @@ -2,6 +2,8 @@ package main import ( "flag" + "io/ioutil" + "log" "os" "path/filepath" @@ -30,6 +32,9 @@ func init() { } func main() { + // suppress output from libraries, lifecycle will not use standard logger + log.SetOutput(ioutil.Discard) + flag.Parse() if flag.NArg() != 0 { cmd.Exit(cmd.FailCode(cmd.CodeInvalidArgs, "parse arguments")) diff --git a/cmd/cacher/main.go b/cmd/cacher/main.go index 3e0443474..b8c9a74a5 100644 --- a/cmd/cacher/main.go +++ b/cmd/cacher/main.go @@ -31,6 +31,9 @@ func init() { } func main() { + // suppress output from libraries, lifecycle will not use standard logger + log.SetOutput(ioutil.Discard) + flag.Parse() if flag.NArg() > 0 { args := map[string]interface{}{"narg": flag.NArg(), "layersDir": layersDir} diff --git a/cmd/cmd.go b/cmd/cmd.go index 11759246c..b9d64e314 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -137,7 +137,8 @@ func Exit(err error) { if err == nil { os.Exit(0) } - log.Printf("Error: %s\n", err) + logger := log.New(os.Stderr, "", 0) + logger.Printf("Error: %s\n", err) if err, ok := err.(*ErrorFail); ok { os.Exit(err.Code) } diff --git a/cmd/detector/main.go b/cmd/detector/main.go index 396c61468..02e3d27a7 100644 --- a/cmd/detector/main.go +++ b/cmd/detector/main.go @@ -31,6 +31,9 @@ func init() { } func main() { + // suppress output from libraries, lifecycle will not use standard logger + log.SetOutput(ioutil.Discard) + flag.Parse() if flag.NArg() != 0 { cmd.Exit(cmd.FailCode(cmd.CodeInvalidArgs, "parse arguments")) diff --git a/cmd/exporter/main.go b/cmd/exporter/main.go index 24c0b7f55..616666105 100644 --- a/cmd/exporter/main.go +++ b/cmd/exporter/main.go @@ -42,6 +42,9 @@ func init() { } func main() { + // suppress output from libraries, lifecycle will not use standard logger + log.SetOutput(ioutil.Discard) + flag.Parse() if flag.NArg() > 1 || flag.Arg(0) == "" || runImageRef == "" { args := map[string]interface{}{"narg": flag.NArg(), "runImage": runImageRef, "layersDir": layersDir} diff --git a/cmd/restorer/main.go b/cmd/restorer/main.go index 5dd5d015a..a20c2a1c2 100644 --- a/cmd/restorer/main.go +++ b/cmd/restorer/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "io/ioutil" "log" "os" @@ -30,6 +31,9 @@ func init() { } func main() { + // suppress output from libraries, lifecycle will not use standard logger + log.SetOutput(ioutil.Discard) + flag.Parse() if flag.NArg() > 0 { args := map[string]interface{}{"narg": flag.NArg(), "layersDir": layersDir}