Skip to content

Commit 6a30ece

Browse files
committed
feat: verbosity can take a string or int
1 parent fbaa3db commit 6a30ece

File tree

83 files changed

+905
-765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+905
-765
lines changed

cmd/monitor/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var MonitorCmd = &cobra.Command{
6363
// By default, hide logs from `polycli monitor`.
6464
verbosityFlag := cmd.Flag("verbosity")
6565
if verbosityFlag != nil && !verbosityFlag.Changed {
66-
util.SetLogLevel(int(util.Silent))
66+
util.SetLogLevel(util.Silent)
6767
}
6868
prettyFlag := cmd.Flag("pretty-logs")
6969
if prettyFlag != nil && prettyFlag.Value.String() == "true" {

cmd/root.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ import (
4343
)
4444

4545
var (
46-
cfgFile string
47-
verbosity int
48-
pretty bool
46+
cfgFile string
47+
verbosityInput string
48+
pretty bool
4949
)
5050

5151
// rootCmd represents the base command when called without any subcommands
@@ -97,20 +97,32 @@ func NewPolycliCommand() *cobra.Command {
9797
Use: "polycli",
9898
Short: "A Swiss Army knife of blockchain tools.",
9999
Long: "Polycli is a collection of tools that are meant to be useful while building, testing, and running block chain applications.",
100-
PersistentPreRun: func(cmd *cobra.Command, args []string) {
100+
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
101+
verbosity, err := util.ParseVerbosity(verbosityInput)
102+
if err != nil {
103+
return err
104+
}
101105
util.SetLogLevel(verbosity)
102106
logMode := util.JSON
103107
if pretty {
104108
logMode = util.Console
105109
}
106-
_ = util.SetLogMode(logMode)
110+
return util.SetLogMode(logMode)
107111
},
108112
}
109113

110114
// Define flags and configuration settings.
111115
f := cmd.PersistentFlags()
112116
f.StringVar(&cfgFile, "config", "", "config file (default is $HOME/.polygon-cli.yaml)")
113-
f.IntVarP(&verbosity, "verbosity", "v", 500, "0 - silent\n100 panic\n200 fatal\n300 error\n400 warning\n500 info\n600 debug\n700 trace")
117+
f.StringVarP(&verbosityInput, "verbosity", "v", "info", `log level (string or int):
118+
0 - silent
119+
100 - panic
120+
200 - fatal
121+
300 - error
122+
400 - warn
123+
500 - info (default)
124+
600 - debug
125+
700 - trace`)
114126
f.BoolVar(&pretty, "pretty-logs", true, "output logs in pretty format instead of JSON")
115127

116128
// Define local flags which will only run when this action is called directly.

doc/load-testing-guide.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,15 @@ command.
9595
- `--rpc-url`: defines the RPC URL that the test will call when calling the network RPC.
9696
- `--private-key`: defines the private key of the account used to send the transactions to the network.
9797
- `--mode`: defines what kind of load test you want to perform, EOA txs, ERC20, etc.
98-
- `--verbosity`: defines the log level that will be printed to the console: `0 to Silent`, `100 to Panic`,
99-
`200 to Fatal`, `300 to Error`, `400 to Warning`, `500 to Info`, `600 to Debug`, `700 to Trace`, the default is `500`.
98+
- `--verbosity`: defines the log level that will be printed to the console:
99+
- `0` - silent
100+
- `100` - panic
101+
- `200` - fatal
102+
- `300` - error
103+
- `400` - warn
104+
- `500` - info (default)
105+
- `600` - debug
106+
- `700` - trace
100107
- `--requests`: defines the number of requests that will be sent to the network by each concurrent execution.
101108
- `--concurrency`: define the number of concurrent executions of the load test. For example, if `--requests` is set to
102109
`10` and `--concurrency` is set to `2`, then 2 load test executions will start concurrently and each concurrent

doc/polycli.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ Polycli is a collection of tools that are meant to be useful while building, tes
1919
## Flags
2020

2121
```bash
22-
--config string config file (default is $HOME/.polygon-cli.yaml)
23-
-h, --help help for polycli
24-
--pretty-logs output logs in pretty format instead of JSON (default true)
25-
-t, --toggle help message for toggle
26-
-v, --verbosity int 0 - silent
27-
100 panic
28-
200 fatal
29-
300 error
30-
400 warning
31-
500 info
32-
600 debug
33-
700 trace (default 500)
22+
--config string config file (default is $HOME/.polygon-cli.yaml)
23+
-h, --help help for polycli
24+
--pretty-logs output logs in pretty format instead of JSON (default true)
25+
-t, --toggle help message for toggle
26+
-v, --verbosity string log level (string or int):
27+
0 - silent
28+
100 - panic
29+
200 - fatal
30+
300 - error
31+
400 - warn
32+
500 - info (default)
33+
600 - debug
34+
700 - trace (default "info")
3435
```
3536

3637
## See also

doc/polycli_abi.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,17 @@ In addition to the function selector data, we'll also get a breakdown of input d
184184
The command also inherits flags from parent commands.
185185

186186
```bash
187-
--config string config file (default is $HOME/.polygon-cli.yaml)
188-
--pretty-logs output logs in pretty format instead of JSON (default true)
189-
-v, --verbosity int 0 - silent
190-
100 panic
191-
200 fatal
192-
300 error
193-
400 warning
194-
500 info
195-
600 debug
196-
700 trace (default 500)
187+
--config string config file (default is $HOME/.polygon-cli.yaml)
188+
--pretty-logs output logs in pretty format instead of JSON (default true)
189+
-v, --verbosity string log level (string or int):
190+
0 - silent
191+
100 - panic
192+
200 - fatal
193+
300 - error
194+
400 - warn
195+
500 - info (default)
196+
600 - debug
197+
700 - trace (default "info")
197198
```
198199

199200
## See also

doc/polycli_abi_decode.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ polycli abi decode Contract.abi [flags]
2828
The command also inherits flags from parent commands.
2929

3030
```bash
31-
--config string config file (default is $HOME/.polygon-cli.yaml)
32-
--pretty-logs output logs in pretty format instead of JSON (default true)
33-
-v, --verbosity int 0 - silent
34-
100 panic
35-
200 fatal
36-
300 error
37-
400 warning
38-
500 info
39-
600 debug
40-
700 trace (default 500)
31+
--config string config file (default is $HOME/.polygon-cli.yaml)
32+
--pretty-logs output logs in pretty format instead of JSON (default true)
33+
-v, --verbosity string log level (string or int):
34+
0 - silent
35+
100 - panic
36+
200 - fatal
37+
300 - error
38+
400 - warn
39+
500 - info (default)
40+
600 - debug
41+
700 - trace (default "info")
4142
```
4243

4344
## See also

doc/polycli_abi_encode.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ polycli abi encode [function signature] [args...] [flags]
2929
The command also inherits flags from parent commands.
3030

3131
```bash
32-
--config string config file (default is $HOME/.polygon-cli.yaml)
33-
--pretty-logs output logs in pretty format instead of JSON (default true)
34-
-v, --verbosity int 0 - silent
35-
100 panic
36-
200 fatal
37-
300 error
38-
400 warning
39-
500 info
40-
600 debug
41-
700 trace (default 500)
32+
--config string config file (default is $HOME/.polygon-cli.yaml)
33+
--pretty-logs output logs in pretty format instead of JSON (default true)
34+
-v, --verbosity string log level (string or int):
35+
0 - silent
36+
100 - panic
37+
200 - fatal
38+
300 - error
39+
400 - warn
40+
500 - info (default)
41+
600 - debug
42+
700 - trace (default "info")
4243
```
4344

4445
## See also

doc/polycli_cdk.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ Basic utility commands for interacting with the cdk contracts
2828
The command also inherits flags from parent commands.
2929

3030
```bash
31-
--config string config file (default is $HOME/.polygon-cli.yaml)
32-
--pretty-logs output logs in pretty format instead of JSON (default true)
33-
-v, --verbosity int 0 - silent
34-
100 panic
35-
200 fatal
36-
300 error
37-
400 warning
38-
500 info
39-
600 debug
40-
700 trace (default 500)
31+
--config string config file (default is $HOME/.polygon-cli.yaml)
32+
--pretty-logs output logs in pretty format instead of JSON (default true)
33+
-v, --verbosity string log level (string or int):
34+
0 - silent
35+
100 - panic
36+
200 - fatal
37+
300 - error
38+
400 - warn
39+
500 - info (default)
40+
600 - debug
41+
700 - trace (default "info")
4142
```
4243

4344
## See also

doc/polycli_cdk_bridge.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ The command also inherits flags from parent commands.
2828
--pretty-logs output logs in pretty format instead of JSON (default true)
2929
--rollup-manager-address string address of rollup contract
3030
--rpc-url string RPC URL of network containing CDK contracts (default "http://localhost:8545")
31-
-v, --verbosity int 0 - silent
32-
100 panic
33-
200 fatal
34-
300 error
35-
400 warning
36-
500 info
37-
600 debug
38-
700 trace (default 500)
31+
-v, --verbosity string log level (string or int):
32+
0 - silent
33+
100 - panic
34+
200 - fatal
35+
300 - error
36+
400 - warn
37+
500 - info (default)
38+
600 - debug
39+
700 - trace (default "info")
3940
```
4041

4142
## See also

doc/polycli_cdk_bridge_dump.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ The command also inherits flags from parent commands.
4444
--pretty-logs output logs in pretty format instead of JSON (default true)
4545
--rollup-manager-address string address of rollup contract
4646
--rpc-url string RPC URL of network containing CDK contracts (default "http://localhost:8545")
47-
-v, --verbosity int 0 - silent
48-
100 panic
49-
200 fatal
50-
300 error
51-
400 warning
52-
500 info
53-
600 debug
54-
700 trace (default 500)
47+
-v, --verbosity string log level (string or int):
48+
0 - silent
49+
100 - panic
50+
200 - fatal
51+
300 - error
52+
400 - warn
53+
500 - info (default)
54+
600 - debug
55+
700 - trace (default "info")
5556
```
5657

5758
## See also

0 commit comments

Comments
 (0)