-
Notifications
You must be signed in to change notification settings - Fork 18
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
updates to logging to automatically include file name, function name … #9
base: main
Are you sure you want to change the base?
Conversation
…and execution line. this will be useful for debugging. formating improvements will allow us to use GUI tools for log viewing
@travisdesell the idea was to improve logging by determining where a log function was invoked. Still need to compile and test this on Ubuntu and cluster. Working on my Mac without modifying CMake or environment variables. Some more work to be done to get log messages to be well formatted in output. Delimiting log message sections with ':' so we can use some GUI log viewers for search and filtering. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little worried a bout performance effects of this change. The reason I had the va_list/va_start buried a bit further into the functions was to only use them when needed -- many times (depending on log level) they'll never be needed if the message is ignored.
Just a thought -- is it possible to put the guards in the |
My thought is that then the compiler might even be able to optimize out those statements. Which would be ideal especially if a block of code had a number of trace/debug statements that could really slow things down. |
Right that makes sense, i.e. ideally avoid prep work prior to log calls. I removed Logs that used So to get performance, shut logs off by potentially disabling them at compile time. Review existing use of log to make sure additional work to prepare a log message is minimized. |
@travisdesell so won't get optimized away because |
Yeah I think it's worth doing because branch prediction should be pretty good at catching them and it will save us unneeded function calls. I imagine eventually we could set things up where we also had a compile flag to specify logging levels if we really wanted to squeeze out some more performance. |
… provided argument parameter functions
@travisdesell So two observations implementing this.
|
@@ -239,3 +235,8 @@ void Log::log(const char *file, size_t filelen, const char *func, size_t funclen | |||
bool Log::at_level(log_level_t level) { | |||
return level >= std_message_level || level >= file_message_level; | |||
} | |||
|
|||
bool Log::should_log(log_level_t level) { | |||
return !(std_message_level < level && file_message_level < level) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@travisdesell I'll simplify this
…and execution line. this will be useful for debugging. formating improvements will allow us to use GUI tools for log viewing