Wrapped repeating code in a function - #3400
Conversation
bob-carpenter
left a comment
There was a problem hiding this comment.
Thanks---this is useful and we should merge, but I just asked for a little doc and simplification in calling.
| virtual void fatal(const std::stringstream& message) {} | ||
| }; | ||
|
|
||
| inline void log_if_nonempty(logger& log, const std::stringstream& message) { |
There was a problem hiding this comment.
Given that this hard codes the "info" level, it'd be nice if that's in its name, as in log_info_if_nonempty.
There was a problem hiding this comment.
If you could also add function doc, that'd be helpful.
| }; | ||
|
|
||
| inline void log_if_nonempty(logger& log, const std::stringstream& message) { | ||
| if (message.str().length() > 0) { |
There was a problem hiding this comment.
If you reorder the two functions, this can be reduced to
log_if_nonempty(logger, msg.str()).
I also think the variable should be called logger rather than log.
|
There may also be a lot more places this comes up in the code, but I'm not sure. I'm happy to take just this many fixes. |
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
Submission Checklist
./runTests.py src/test/unitmake cpplintSummary
Intended Effect
How to Verify
Side Effects
Documentation
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company):
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: