See discussion: https://reviews.bitcoinabc.org/D1425
Details
- Reviewers
deadalnix schancel - Group Reviewers
Restricted Project - Commits
- rSTAGING080890188304: Added error message when logging on categories NONE and ALL
rABC080890188304: Added error message when logging on categories NONE and ALL
make check
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- arcpatch-D1431
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 2765 Build 3640: Bitcoin ABC Buildbot (legacy) Build 3639: arc lint + arc unit
Event Timeline
Planned changes: Adding a test to make sure the assert() is enforced for all logging methods that accept a category. I'll only write these tests if this change is acceptable to everyone else.
src/logging.cpp | ||
---|---|---|
212 ↗ | (On Diff #3915) | This needs to be a static assert. Can we make the logger a template somehow? |
src/logging.cpp | ||
---|---|---|
212 ↗ | (On Diff #3915) | This cannot be a static_assert because category is not a constant expression. The intent here is to prevent calls made using ALL. Is there a better way to do this so that static_assert still works? Conceptually, catching this at compile-time makes sense, but I don't think it can be done in a way that catches all cases. Not sure exactly what you mean by making the logger a template, but I was talking with jimpo about logging improvements, which he started on here: https://reviews.bitcoinabc.org/D1277 Most of our conversation was in slack I believe. We talked about templating some of the functions, iirc, but I would have to dig through the chat logs. |
src/logging.cpp | ||
---|---|---|
212 ↗ | (On Diff #3915) | Having the logger potentially crashing the app seems like a very bad tradeof. |
src/logging.cpp | ||
---|---|---|
215 ↗ | (On Diff #4128) | This seems to cause incorrect log message to not get logged at all, and instead only the above error message is printed. (See: logging.h macro LogPrint) Please change to true |
src/logging.cpp | ||
---|---|---|
215 ↗ | (On Diff #4128) | My original intent was to not log the original message so the caller is forced to fix it, otherwise the error message can be ignored. |
src/logging.cpp | ||
---|---|---|
215 ↗ | (On Diff #4128) | I understand, but I still disagree. A build which uses this should hopefully never make it into production, but we don't have any linters yet. If it did make it into a production release, and we needed the log message for something -- not having it would be really frustrating. |
Removed the test, as it's no longer necessary. Also added a newline to the error message.