-
Notifications
You must be signed in to change notification settings - Fork 70
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
Encapsulate std::cerr under a single point of control #656
Conversation
When integrating this library into a larger application, downstream code doesn't always want to spew onto cerr. To allow customization, we'll refactor to encapsulate the destination inside of a function. Future work can extent this with a mechanism to redirect it (e.g., to send it to spdlog instead of cerr). Signed-off-by: Jeremy Nimmer <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## gz-math8 #656 +/- ##
============================================
+ Coverage 95.71% 95.73% +0.01%
============================================
Files 150 151 +1
Lines 10390 10429 +39
============================================
+ Hits 9945 9984 +39
Misses 445 445 ☔ View full report in Codecov by Sentry. |
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.
just a minor change, otherwise look good to me
Signed-off-by: Jeremy Nimmer <[email protected]>
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.
Thanks for the PR. FYI, we have recently added spdlog based logging in gz-utils (gazebosim/gz-utils#134). The long term plan is to replace all console logging here in gz-math with the that.
Signed-off-by: Jeremy Nimmer <[email protected]>
I pushed a rename from FYI on spdlog -- I'm less enamored with spdlog than I was years ago. I don't really think it is API and ABI-stable enough to be used a public (header file) dependency in low-level libraries like this one, especially those that try themselves to be ABI-stable. I especially recommend against using spdlog in header files -- I'm going to be working on removing it from Drake header files this year. I realize you can pin it to the distro or something to improve stability, but to me it seems like a bridge too far. My recommendation is to limit the use of spdlog to just the one new If you want to work improving the error architecture in gz-math, my advice would actually be to stop printing messages entirely (in a future major release that has API changes). Functions that receive bad input shouldn't log and proceed anyway, they should either throw an exception with the message, or return a |
(This isn't necessarily a new feature, but there doesn't seem to be a "cleanup" or "refactor" PR template.)
🎉 New feature
Closes (n/a).
Summary
When integrating this library into a larger application, downstream code doesn't always want to spew onto cerr. To allow customization, we'll refactor to encapsulate the destination inside of a function. Future work can extend this with a mechanism to redirect it (e.g., to send it to spdlog instead of cerr, or to throw an exception instead of returning wrong answers).
Test it
The existing unit tests provide the same level of code-coverage for error printing as previously (e.g., demonstrating that the error printing does not crash).
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.