-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
48 lines (43 loc) · 1005 Bytes
/
debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package debug
import (
"fmt"
"os"
"github.com/nknorg/nkn/api/httpjson/client"
. "github.com/nknorg/nkn/cli/common"
"github.com/urfave/cli"
)
func debugAction(c *cli.Context) (err error) {
if c.NumFlags() == 0 {
cli.ShowSubcommandHelp(c)
return nil
}
level := c.Int("level")
if level != -1 {
resp, err := client.Call(Address(), "setdebuginfo", 0, map[string]interface{}{"level": level})
if err != nil {
fmt.Fprintln(os.Stderr, err)
return err
}
FormatOutput(resp)
}
return nil
}
func NewCommand() *cli.Command {
return &cli.Command{Name: "debug",
Usage: "blockchain node debugging",
Description: "With nknc debug, you could debug blockchain node.",
ArgsUsage: "[args]",
Flags: []cli.Flag{
cli.IntFlag{
Name: "level, l",
Usage: "log level 0-6",
Value: -1,
},
},
Action: debugAction,
OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error {
PrintError(c, err, "debug")
return cli.NewExitError("", 1)
},
}
}