Skip to content

Conversation

Klynic
Copy link

@Klynic Klynic commented Mar 1, 2024

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.

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant