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

[logging] reduce logging overhead #616

Open
tijyojwad opened this issue Dec 10, 2020 · 0 comments
Open

[logging] reduce logging overhead #616

tijyojwad opened this issue Dec 10, 2020 · 0 comments
Labels
enhancement New feature or request sdk Overall SDK related improvements

Comments

@tijyojwad
Copy link
Contributor

Suggestions from @ahehn-nv -

You could avoid the construction of the std::string by directly operating on the stream:

std::ostream& operator << (std::ostream& os, LogLevel level)
{
    switch(level)
    {
       case critical: os << "CRITICAL"; break;
       ...
    }
    return os;
}
or, if you dislike overloading operators, a similar function void add_prefix(std::ostream& os, LogLevel level).
We could actually base the whole logger on overloading << instead of macros and std::strings, providing a syntax like:

 log(LogLevel::debug) << "here's some debug integer: " << some_integer << std::endl;
Advantages:

common C++ syntax.
messages become almost no-ops if a higher logging level is selected.
Disadvantage:

more templates -> Slightly higher compilation times.
@tijyojwad tijyojwad added the sdk Overall SDK related improvements label Dec 10, 2020
@ahehn-nv ahehn-nv added the enhancement New feature or request label Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sdk Overall SDK related improvements
Projects
None yet
Development

No branches or pull requests

2 participants