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

Add a sonarcube rule to catch the log overhead #197

Open
leonardocarreras opened this issue Mar 8, 2023 · 0 comments
Open

Add a sonarcube rule to catch the log overhead #197

leonardocarreras opened this issue Mar 8, 2023 · 0 comments

Comments

@leonardocarreras
Copy link
Collaborator

We were talking after @LennartSchu achieved good results by using a macro in #194:

1. Logger uses macros now. i.e. instead of
   
   * `mSLog->info("{}", some_expensive_function())`,    we use
   * `SPDLOG_LOGGER_INFO(mSLog, "{}", some_expensive_function())` 

The problem was somehow the following:

in logger calls like logger_call_with_some_level(...,"variable %var", function_calculating_var()) the function that feeds the data function_calculating_var() can get called even for cases when the log level is not set for that case. That brings nice overheads that he just improved in the PR #194, but it will keep being something that the developer needs to remember.

A possible solution to eliminate this use of loggers calls in code instead of the proposed macro would be a rule in sonar that catches the direct calls to logger function and invites you to use the macro he proposed. There is a chance that people will forget in the long run, so at least a warning is important and maybe we suggest the insertion of the SPDLOG_LOGGER macro.

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

No branches or pull requests

1 participant