Skip to content

Commit

Permalink
Enable debug mode from different places (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored and mudler committed Apr 11, 2024
1 parent c9a7e98 commit 0283b7b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,9 +796,25 @@ The kairos agent is a component to abstract away node ops, providing a common fe
UsageText: ``,
Copyright: "kairos authors",
Before: func(c *cli.Context) error {
// Set debug from here already, so it's loaded by the ReadConfigRun
viper.Set("debug", c.Bool("debug"))
var debug bool
// Get debug from env or cmdline
cmdline, _ := os.ReadFile("/proc/cmdline")
if strings.Contains(string(cmdline), "rd.kairos.debug") {
debug = true
}

if os.Getenv("KAIROS_AGENT_DEBUG") == "true" {
debug = true
}

if c.Bool("debug") {
debug = true
}

// Set debug from here already, so it's loaded by the Config unmarshall
viper.Set("debug", debug)
if debug {
// Dont hide private fields, we want the full object biew
litter.Config.HidePrivateFields = false
// Hide logger and client fields from litter as otherwise the config dumps are huge and a bit useless
litter.Config.FieldExclusions = regexp.MustCompile(`Logger|logger|Client`)
Expand Down

0 comments on commit 0283b7b

Please sign in to comment.