Enable debug mode from different places (#287)

This commit is contained in:
Itxaka 2024-04-11 08:51:08 +00:00 committed by GitHub
parent 80aad89fa8
commit 1cca516738
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

20
main.go
View File

@ -801,9 +801,25 @@ The kairos agent is a component to abstract away node ops, providing a common fe
UsageText: ``, UsageText: ``,
Copyright: "kairos authors", Copyright: "kairos authors",
Before: func(c *cli.Context) error { Before: func(c *cli.Context) error {
// Set debug from here already, so it's loaded by the ReadConfigRun var debug bool
viper.Set("debug", c.Bool("debug")) // 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") { 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 litter.Config.HidePrivateFields = false
// Hide logger and client fields from litter as otherwise the config dumps are huge and a bit useless // 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`) litter.Config.FieldExclusions = regexp.MustCompile(`Logger|logger|Client`)