From 323d8f5a9a4d65b01d85654b3b68e4da5528f763 Mon Sep 17 00:00:00 2001 From: Matt Ketmo Date: Sat, 16 Nov 2024 09:33:46 +0100 Subject: [PATCH] feat: add shortcut for log-level=debug (#87) --- README.md | 1 + pkg/app/flags.go | 4 ++++ pkg/app/run.go | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index cd27696..294a624 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ GLOBAL OPTIONS: --chain-id value to ensure all nodes matches the specific network (dismiss to auto-detected) --http-addr value http server address (default: ":8080") --log-level value log level (debug, info, warn, error) (default: "info") + --debug shortcut for --log-level=debug (default: false) --namespace value namespace for Prometheus metrics (default: "cosmos_validator_watcher") --no-color disable colored output (default: false) --node value [ --node value ] rpc node endpoint to connect to (specify multiple for high availability) (default: "http://localhost:26657") diff --git a/pkg/app/flags.go b/pkg/app/flags.go index 67705a7..768dc2f 100644 --- a/pkg/app/flags.go +++ b/pkg/app/flags.go @@ -21,6 +21,10 @@ var Flags = []cli.Flag{ Usage: "log level (debug, info, warn, error)", Value: "info", }, + &cli.BoolFlag{ + Name: "debug", + Usage: "shortcut for --log-level=debug", + }, &cli.StringFlag{ Name: "namespace", Usage: "namespace for Prometheus metrics", diff --git a/pkg/app/run.go b/pkg/app/run.go index 0ee2278..afe3b1a 100644 --- a/pkg/app/run.go +++ b/pkg/app/run.go @@ -34,6 +34,7 @@ func RunFunc(cCtx *cli.Context) error { // Config flags chainID = cCtx.String("chain-id") + debug = cCtx.Bool("debug") httpAddr = cCtx.String("http-addr") logLevel = cCtx.String("log-level") namespace = cCtx.String("namespace") @@ -61,6 +62,9 @@ func RunFunc(cCtx *cli.Context) error { zerolog.TimeFieldFormat = zerolog.TimeFormatUnix log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) zerolog.SetGlobalLevel(logLevelFromString(logLevel)) + if debug { + zerolog.SetGlobalLevel(zerolog.DebugLevel) + } // Disable colored output if requested color.NoColor = noColor