mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 19:24:17 +02:00
add --debug-goroutines
This commit is contained in:
@@ -119,6 +119,12 @@ func Main() int {
|
|||||||
Usage: "enable HTTP debugging",
|
Usage: "enable HTTP debugging",
|
||||||
Destination: &conf.DebugHTTP,
|
Destination: &conf.DebugHTTP,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "debug-goroutines",
|
||||||
|
Value: false,
|
||||||
|
Usage: "enable goroutine debugging",
|
||||||
|
Destination: &conf.DebugGoRoutines,
|
||||||
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "align-ints",
|
Name: "align-ints",
|
||||||
Aliases: []string{"I"},
|
Aliases: []string{"I"},
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ type Config struct {
|
|||||||
Force bool // ccr follower renew: -f
|
Force bool // ccr follower renew: -f
|
||||||
|
|
||||||
DebugHTTP bool // root: --debug-http
|
DebugHTTP bool // root: --debug-http
|
||||||
|
DebugGoRoutines bool // root: --debug-goroutines
|
||||||
Separator string // role diff: -s
|
Separator string // role diff: -s
|
||||||
NotDeployed bool // role diff: -n
|
NotDeployed bool // role diff: -n
|
||||||
Undefined bool // role diff: -u
|
Undefined bool // role diff: -u
|
||||||
|
|||||||
@@ -40,10 +40,15 @@ type Table struct {
|
|||||||
lenHeaders []int
|
lenHeaders []int
|
||||||
alignInts bool
|
alignInts bool
|
||||||
maxwidth int
|
maxwidth int
|
||||||
|
debugGoRoutines bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
||||||
table := new(Table{Mode: conf.Output, maxwidth: cfg.GetTermWidth()})
|
table := new(Table{
|
||||||
|
Mode: conf.Output,
|
||||||
|
maxwidth: cfg.GetTermWidth(),
|
||||||
|
debugGoRoutines: conf.DebugGoRoutines,
|
||||||
|
})
|
||||||
|
|
||||||
table.Headers = make([]string, columns)
|
table.Headers = make([]string, columns)
|
||||||
table.RawHeaders = make([]string, columns)
|
table.RawHeaders = make([]string, columns)
|
||||||
@@ -55,7 +60,11 @@ func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTableEmpty(conf *cfg.Config) *Table {
|
func NewTableEmpty(conf *cfg.Config) *Table {
|
||||||
table := new(Table{Mode: conf.Output, maxwidth: cfg.GetTermWidth()})
|
table := new(Table{
|
||||||
|
Mode: conf.Output,
|
||||||
|
maxwidth: cfg.GetTermWidth(),
|
||||||
|
debugGoRoutines: conf.DebugGoRoutines,
|
||||||
|
})
|
||||||
table.alignInts = conf.AlignInts
|
table.alignInts = conf.AlignInts
|
||||||
|
|
||||||
return table
|
return table
|
||||||
@@ -75,16 +84,24 @@ func (table *Table) WithHeaders(headers ...string) *Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (table *Table) Print() error {
|
func (table *Table) Print() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
switch table.Mode {
|
switch table.Mode {
|
||||||
case "json":
|
case "json":
|
||||||
return table.PrintJSON()
|
err = table.PrintJSON()
|
||||||
case "yaml":
|
case "yaml":
|
||||||
return table.PrintYAML()
|
err = table.PrintYAML()
|
||||||
case "csv":
|
case "csv":
|
||||||
return table.PrintCSV()
|
err = table.PrintCSV()
|
||||||
default:
|
default:
|
||||||
return table.PrintTSV()
|
err = table.PrintTSV()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if table.debugGoRoutines {
|
||||||
|
printGoRoutineMetrics()
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
Reference in New Issue
Block a user