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

Refactor logging string creation #332

Open
billschereriii opened this issue Apr 28, 2023 · 1 comment
Open

Refactor logging string creation #332

billschereriii opened this issue Apr 28, 2023 · 1 comment
Labels
area: C++ Issues related to the C++ client type: refactor Issues focused on refactoring existing code

Comments

@billschereriii
Copy link
Contributor

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

@billschereriii billschereriii added type: refactor Issues focused on refactoring existing code area: C++ Issues related to the C++ client labels Apr 28, 2023
@mellis13
Copy link
Collaborator

mellis13 commented May 5, 2023

From backlog, variadic approach could be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: C++ Issues related to the C++ client type: refactor Issues focused on refactoring existing code
Projects
None yet
Development

No branches or pull requests

2 participants