Skip to content

Commit

Permalink
feat: add shortcut for log-level=debug (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo authored Nov 16, 2024
1 parent a728e21 commit 323d8f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions pkg/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 323d8f5

Please sign in to comment.