-
Notifications
You must be signed in to change notification settings - Fork 433
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
Add defmt logging support #455
Conversation
|
||
defmt-trace = [] | ||
defmt-debug = [] | ||
defmt-info = [] | ||
defmt-warn = [] | ||
defmt-error = [] | ||
|
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.
Hm, what's the point of these, are they needed by defmt
?
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.
Yes, the defmt macros only emit code if the corresponding log level (or lower) is enabled. The end-user is supposed to depend on smoltcp with defmt, defmt-debug
features to see up to debug
level, for example. This is so log level is configurable per-crate.
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.
But don't you need to forward the features then? I'm confused about how this would work as-is in this PR.
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.
Sweet! Any comparison available between typical binary size and defmt
enabled?
I guess the best option is to declare our MSRV is 1.40 except if you're using defmt, in which case the limiting factor is defmt's MSRV. |
Unfortunately no :( I've been using this internally for a while already and no longer have a firmware that uses |
This adds basic support for optionally logging with
defmt
instead oflog
, controlled via Cargo features.Any struct that can implement
defmt::Format
now does so. There's a few left, due to:defmt
.managed
types.The left structs are not used in log statements anyway, and are usually "big" structs, like sockets. Since this is already fully functional for integration in a firmware that uses
defmt
I would merge this now, and add the missing impls later when they're unblocked.Fixes #376