From 0283b7b5a75b8cd178aa3ce58c1fea012450d692 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Thu, 11 Apr 2024 08:51:08 +0000 Subject: [PATCH] Enable debug mode from different places (#287) --- main.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 38900b04..e27e8a6b 100644 --- a/main.go +++ b/main.go @@ -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`)