Reduced logging verbosity and added context through grouping and conditional logging
I looked at the cmd directory in the “bsp-agent” and came up with potential solutions to optimize logging in the cmd directory
I discovered the code by default uses “log.InfoLevel” whenever logs are being generated excessively, so I introduced codes for “log.WarnLevel” and “log.ErrorLevel” with the line “log.SetLevel(log.WarnLevel)” to set the log level to “WarnLevel”, meaning only warnings and errors will be logged.
I also noticed that the code logs messages at various points, like startup and configuration settings. I decided to modify the logging frequency by setting “log.SetLevel(log.WarnLevel), to limit logging to warnings and errors by default.
I also disabled “log.SetReportCaller(false)” preventing redundant caller information and reducing log size. This helps to reduce the logging verbosity. You would also notice the introduction of “log.WithFields” which adds context to log messages, enabling better grouping and filtering.
I also added warning-level logs for noteworthy events or disabled features.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 44.83%. Comparing base (
6366dfc) to head (fd5bf3f).
Additional details and impacted files
@@ Coverage Diff @@
## main #241 +/- ##
=======================================
Coverage 44.83% 44.83%
=======================================
Files 28 28
Lines 1927 1927
=======================================
Hits 864 864
Misses 1028 1028
Partials 35 35
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.