Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts Inspektor Gadget’s internal logger verbosity to follow the node-agent’s global log level at startup.
Changes:
- Add Inspektor Gadget logger import.
- Set Inspektor Gadget default logger level during
main()initialization based onkubescape/go-loggerlevel.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| igconfig "github.com/inspektor-gadget/inspektor-gadget/pkg/config" | ||
| iglogger "github.com/inspektor-gadget/inspektor-gadget/pkg/logger" | ||
| containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection" |
There was a problem hiding this comment.
Import block is no longer gofmt-sorted after adding iglogger (the inspektor-gadget imports should be ordered lexicographically). Please run gofmt or reorder imports to avoid inconsistent formatting across the repo.
| igconfig "github.com/inspektor-gadget/inspektor-gadget/pkg/config" | |
| iglogger "github.com/inspektor-gadget/inspektor-gadget/pkg/logger" | |
| containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection" | |
| containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection" | |
| igconfig "github.com/inspektor-gadget/inspektor-gadget/pkg/config" | |
| iglogger "github.com/inspektor-gadget/inspektor-gadget/pkg/logger" |
| if logger.L().GetLevel() == "debug" { | ||
| iglogger.DefaultLogger().SetLevel(iglogger.DebugLevel) | ||
| } else { | ||
| iglogger.DefaultLogger().SetLevel(iglogger.ErrorLevel) | ||
| } |
There was a problem hiding this comment.
This sets Inspektor Gadget logging to Debug only when the global logger is exactly "debug", and to Error for all other levels. That behavior is not really "based on global log level" (e.g., if the app runs at info/warn, IG warnings/info will be suppressed). Consider mapping the global level to the closest IG level (debug/info/warn/error) or otherwise documenting why IG should be forced to Error in non-debug mode.
📝 WalkthroughWalkthroughIntroduced an import alias for the IG logger and a runtime log level switch: when the global logger level is "debug" set the IG logger to DebugLevel, otherwise set it to ErrorLevel. Minor formatting spacing tweaks were also made. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Summary by CodeRabbit