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

Improved logging API for performance #182

Merged
merged 2 commits into from
Dec 4, 2017

Conversation

ethouris
Copy link
Collaborator

@ethouris ethouris commented Dec 4, 2017

To solve #181.

Changes:

  1. The call to CheckEnabled is taken out of the internal functions. Instead it will be called inside the macrodefinition used for logging so that the arguments that need not be used for logging won't even be evaluated.
  2. The LOGP macro (rarely used - this is useful only for C++11, otherwise it can take only one argument) is only added the CheckEnabled call inside.
  3. A new LOGF macro is added to replace cases of LOGC(fa.disp).form(...). This calls the form method of LogDispatcher as before, but the macro is added the if condition, like the others.
  4. The LOGC macro has changed the syntax. Previous syntax:
LOGC(fa_specifyer.SeverityDispatcher) << arg1 << arg2 << arg3;

New syntax:

LOGC(fa_specifyer.SeverityDispatcher, arg1 << arg2 << arg3);

So, actually the only visible difference between LOGC and LOGP is that in LOGC the further arguments to be printed are separated by << instead of ,. This is required because there's no possibility to resolve the series of comma-separated macro arguments into a series of << operator separated arguments by preprocessor macros because preprocessor macros can't be evaluated recursively. The only language facility capable of doing it is variadic templates, available only in C++11 and already available for the LOGP macro.

Mikołaj Małecki added 2 commits December 4, 2017 12:01
…tted logging. Logging macros use if inside to prevent evaluation when logging is off.
@ethouris
Copy link
Collaborator Author

ethouris commented Dec 4, 2017

The new syntax for LOGC is:

 LOGC(fa_specifyer.SeverityDispatcher, log << arg1 << arg2 << arg3);

Where log is a local symbol defined inside this macro, not visible outside it. The expression is put into a sub-instruction under an if-statement, so the symbol is local for a context, as well as the destructor-to-EOL binding works the same as when the proxy object was a temporary object.

@rndi rndi merged commit 89a8d8c into Haivision:dev Dec 4, 2017
@ethouris ethouris deleted the dev-logging-api-improvement branch January 17, 2018 10:29
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.

2 participants