Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable debug mode from different places #287

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,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
Loading