From a76892a1eb909d96ae3d39539f97143de643e1f2 Mon Sep 17 00:00:00 2001 From: Max Holland Date: Fri, 5 Jan 2024 15:29:32 +0000 Subject: [PATCH] Switch success line to glog Also bump go-tools (reduced logging) and set logtostderr, glog.Info lines didn't show otherwise --- catalyst-uploader.go | 18 ++++++++++++------ go.mod | 2 +- go.sum | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/catalyst-uploader.go b/catalyst-uploader.go index 465b3fb..02f823d 100644 --- a/catalyst-uploader.go +++ b/catalyst-uploader.go @@ -20,6 +20,10 @@ func main() { } func run() int { + err := flag.Set("logtostderr", "true") + if err != nil { + glog.Fatal(err) + } // cmd line args describe := flag.Bool("j", false, "Describe supported storage services in JSON format and exit") timeout := flag.Duration("t", 30*time.Second, "Upload timeout") @@ -37,7 +41,6 @@ func run() int { } // replace stdout to prevent any lib from writing debug output there - stdout := os.Stdout os.Stdout, _ = os.Open(os.DevNull) uri := flag.Arg(0) @@ -46,17 +49,20 @@ func run() int { return 1 } - err := core.Upload(os.Stdin, uri, WaitBetweenWrites, *timeout) + err = core.Upload(os.Stdin, uri, WaitBetweenWrites, *timeout) if err != nil { glog.Fatalf("Uploader failed for %s: %s", uri, err) return 1 } // success, write uploaded file details to stdout - err = json.NewEncoder(stdout).Encode(map[string]string{"uri": uri}) - if err != nil { - glog.Fatal(err) - return 1 + if glog.V(5) { + b, err := json.Marshal(map[string]string{"uri": uri}) + if err != nil { + glog.Fatal(err) + return 1 + } + glog.Info(string(b)) } return 0 diff --git a/go.mod b/go.mod index eadf0d5..c023463 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/cenkalti/backoff/v4 v4.2.1 github.com/golang/glog v1.1.0 github.com/google/uuid v1.3.0 - github.com/livepeer/go-tools v0.3.3 + github.com/livepeer/go-tools v0.3.4 github.com/stretchr/testify v1.8.4 ) diff --git a/go.sum b/go.sum index 16547a4..25168f0 100644 --- a/go.sum +++ b/go.sum @@ -1433,6 +1433,8 @@ github.com/livepeer/go-tools v0.3.2 h1:5pOUrOmkkGbbcWnpCt2yrSD6cD85G4GcpO4B25NpM github.com/livepeer/go-tools v0.3.2/go.mod h1:qs31y68b3PQPmSr8nR8l5WQiIWI623z6pqOccqebjos= github.com/livepeer/go-tools v0.3.3 h1:Je2P+ovDIIlFWtlns5v+MmHtdIytsAJS6+XyeZ8sFJI= github.com/livepeer/go-tools v0.3.3/go.mod h1:qs31y68b3PQPmSr8nR8l5WQiIWI623z6pqOccqebjos= +github.com/livepeer/go-tools v0.3.4 h1:Otl8VkGA5FdNQMTTN/yh0V72vhSbSQevUTL67AXz6kU= +github.com/livepeer/go-tools v0.3.4/go.mod h1:qs31y68b3PQPmSr8nR8l5WQiIWI623z6pqOccqebjos= github.com/lucas-clemente/quic-go v0.19.3/go.mod h1:ADXpNbTQjq1hIzCpB+y/k5iz4n4z4IwqoLb94Kh5Hu8= github.com/lucas-clemente/quic-go v0.28.1/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0= github.com/lucas-clemente/quic-go v0.29.1/go.mod h1:CTcNfLYJS2UuRNB+zcNlgvkjBhxX6Hm3WUxxAQx2mgE=