-
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
Support for defmt logging #376
Comments
You can write the logs to a ring buffer, and then trigger a snapshot of it through some condition. The utility of this is largely limited to lockups, and while that's nice, I agree with you overall.
I would much prefer that to happen. A separate crate that implements just the proc macro would also be fine. |
Thanks for the feedback! In any case, I'll wait for defmt to stabilize enough for a crates.io release before I try to implement anything... |
I have a PoC of this here akiles@f4cc2c9 It's quite ugly, and it required changing all The ideal solution would be some macro that takes a "supercharged" format string and converts it to a |
Done in #455! With defmt 0.2 there's no longer a need to change |
https://github.com/knurling-rs/defmt is a new approach to tracing/logging from embedded devices which dramatically reduces bandwidth use by deferring formatting to the host, and using indexed format strings.
I think this is a very good fit for embedded smoltcp, since other than in low-traffic situations it is currently basically impossible to use smoltcp's (extensive) logging. With defmt, this might become feasible.
Unfortunately, format strings are not compatible since for compactness,
defmt
format strings need to contain more information about the formatted type (e.g.{:u8}
).Since
defmt
isn't meant for non-embedded use, smoltcp would have to switch between them using a feature flag. The easiest way I could see to support both syntaxes is to use a custom proc macro (net_trace
andnet_debug
are already custom declarative macros anyway), which outputs two versions of the logging call depending on the feature flag selected (and none if logging is switched off). However, it's also conceivable fordefmt
to implement that, so I opened knurling-rs/defmt#149 there.cc @thalesfragoso @adamgreig (stm32-eth developers)
The text was updated successfully, but these errors were encountered: