Skip to content

Commit

Permalink
surpresses ggcr output
Browse files Browse the repository at this point in the history
* NOTE: we are silencing the standard logger
* all lifecycle phases must create and use their own logger

[buildpacks/roadmap#45]

Signed-off-by: Emily Casey <[email protected]>
Signed-off-by: Danny Joyce <[email protected]>
  • Loading branch information
ekcasey authored and Danny Joyce committed Mar 28, 2019
1 parent bf380a3 commit b58cbda
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -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 == "" {
Expand Down
5 changes: 5 additions & 0 deletions cmd/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"flag"
"io/ioutil"
"log"
"os"
"path/filepath"

Expand Down Expand Up @@ -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"))
Expand Down
3 changes: 3 additions & 0 deletions cmd/cacher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/detector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
3 changes: 3 additions & 0 deletions cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions cmd/restorer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit b58cbda

Please sign in to comment.