Add stream-style logging macros
Problem statement:
- Existing logging and assertion is kind of awkward, for example, it doesn't accept stream-style operation, meanwhile it uses string as the macro parameter, which means we have to concatenate the message beforehand.
- (minor) It might hurts performance, I see a lot of the message construction is made by
operator+, which could create temporary strings - (major) it reduces logging util usability
- (minor) It might hurts performance, I see a lot of the message construction is made by
In this PR, I propose to add a new macro, which combines both assertion and logging with stream style operation.
How I tested: https://onlinegdb.com/PZiB5VT2A
@dentiny Thanks for sending this. We will take a look at it. It might make more sense to use a third-party header-only logger.
Thanks @apavlo for taking a look! It would be nice to support CHECK_EQ-like syntax, which
- Allows comparison logic
- Prints out value for lhs and rhs if comparison logic fails
- Code location (i.e. filename and line number) is included in the error message
For this PR, I mostly target at code simplicity w/o extra deps :)
Curious if there're any updates on this PR? :eyes:
@dentiny End of semester crunch. We will look at this soon.
If you can fix the CI then I think this is fine to merge!
If you can fix the CI then I think this is fine to merge!
Thank you @connortsui20 for the review! I think the code is benign so I simply suppress the linter warnings.