SmartRedis
SmartRedis copied to clipboard
Refactor logging string creation
Description
We have extensive logic in some places in the SmartRedis library for creating message strings. It would be good to refactor this logic in some way to skip creation of the strings when they won't be used, such as when the logging level is not detailed enough to emit them.
message = "Retrieved value \"";
message += cfg_val == NULL ? "<NULL>" : cfg_val;
message += "\"";
if ((NULL == cfg_val) && !no_default)
message += ". Using default value of " + std::to_string(default_value);
log_data("SmartRedis Library", LLDebug, message);
Justification
There is a risk of performance and memory overhead with the way that these strings are created today.
Implementation Strategy
One strategy might be to have an override of std::string that accepts a log level and skips added data unless the log level is fine enough
From backlog, variadic approach could be used.