-
Notifications
You must be signed in to change notification settings - Fork 0
Introduce Logger and LogParams #7
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
Conversation
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
I couldn't resolve the conflicts in the files above without having it look like I did all the work! Not wanting to steal credit I've left this PR as-is. The conflict resolution was easy though - I created a local branch and want through the process. |
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
I appreciate the consideration. I knew there would be merge conflicts because of the little bit of overlap between the PRs, and I planned on resolving that once the other PRs were merged. Thanks for doing the test run! I've resolve the merge conflicts now, and also fixed the formatting. |
Sadly I just noticed that One other thing I'd like to do is use
But I think we can leave this for a follow-up PR and move forward with merging this PR once the |
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
I'd hit the same issue locally (we were using 1.79) - easy enough for us to upgrade our local rust, but good call on the upstream version (I'm afraid to say I'd not even looked into that).
That's a nice idea and I agree that we should create a separate PR for that work - it would be nice to get the logging integrated if possible. |
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
Signed-off-by: Michael X. Grey <[email protected]>
I think this one is finally ready to merge with CI being green. After that #11 should be ready for review. |
This PR introduces a
Logger
struct and makes some significant changes to the mechanics of the macros for reasons that I'll outline below.The most obvious change is that
LogConditions
has been replaced withLogParams
and the logging macros no longer have an overload that takes in aLogConditions
argument. Instead the first argument of each macro is an expression that can be evaluated to something that implements theAsLogParams
trait. All of the conditions that used to be expressed byLogConditions
are now packed intoLogParams
.As an example, in the previous code we had
but the new equivalent would be
More examples of the new syntax can be found in
fn test_logging_macros
insidelogging.rs
.Another notable feature is the introduction of
Logger
which has two roles:Finally there was some significant restructuring of the log macro implementation, most of which was meant to avoid redundantly allocating CStrings on the heap every time the same log macro gets called. With the new implementation, each CString gets allocated exactly once, the first time it's needed. The only exception to this is the log message itself which may change each time the macro is called, so it's impractical to cache it.
One thing that could use improvement is we should add assertions to
test_logging_macros
to validate that the right output is being produced for every macro call. I'm deliberating whether to do this by capturing stdout/stderr or by subscribing to the rosout topics.