Skip to content

Commit 93d9a40

Browse files
authored
feat: add quiet flag (#1515)
The quiet flag disables all but error logs Fixes #1452
1 parent 7aab034 commit 93d9a40

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmd/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
_ "embed"
2020
"errors"
2121
"fmt"
22+
"io"
2223
"net"
2324
"net/http"
2425
"net/url"
@@ -82,6 +83,7 @@ type Command struct {
8283
healthCheck bool
8384
httpAddress string
8485
httpPort string
86+
quiet bool
8587

8688
// impersonationChain is a comma separated list of one or more service
8789
// accounts. The first entry in the chain is the impersonation target. Any
@@ -236,6 +238,9 @@ func NewCommand(opts ...Option) *Command {
236238
if c.conf.StructuredLogs {
237239
c.logger, c.cleanup = log.NewStructuredLogger()
238240
}
241+
if c.quiet {
242+
c.logger = log.NewStdLogger(io.Discard, os.Stderr)
243+
}
239244
err := parseConfig(c, c.conf, args)
240245
if err != nil {
241246
return err
@@ -303,6 +308,7 @@ https://cloud.google.com/storage/docs/requester-pays`)
303308
cmd.PersistentFlags().StringVar(&c.impersonationChain, "impersonate-service-account", "",
304309
`Comma separated list of service accounts to impersonate. Last value
305310
is the target account.`)
311+
cmd.PersistentFlags().BoolVar(&c.quiet, "quiet", false, "Log error messages only")
306312

307313
// Global and per instance flags
308314
cmd.PersistentFlags().StringVarP(&c.conf.Addr, "address", "a", "127.0.0.1",

0 commit comments

Comments
 (0)