This repository has been archived by the owner on Feb 27, 2020. It is now read-only.
Enhance logging infrastructure to cope with C and C++ style strings. #786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances our logging infrastructure to allow you to pass in C++ strings. This has two advantages:
.c_str()
everywhere.TRC_DEBUG("Hello %s", get_name().c_str());
and call .c_str() on an rvalue, which results in a dangling pointer.I've tested this by changing one of the logs in Ralf to pass in a C++ string, and checked that the log still works.
I've wrote this code and disassambled it.
The
test
function calls the correct template instantiation:which calls the right instantiation of
_loggable
:which does call c_str 馃檪
This also confirms that the rvalue that is returned by
name()
is converted to an lvalue by the time that the function that actually does the logging is called.I was also worried about binary sizes. I checked building sprout with and without this change. The sprout executable was 79MB before and 80MB after, so I'm not too worried.