openwsn-berkeley / lakers

EDHOC implemented in Rust, optimized for microcontrollers, with bindings for C and Python.
https://crates.io/crates/lakers
BSD 3-Clause "New" or "Revised" License
12 stars 10 forks source link

Use defmt or log #295

Open WilliamTakeshi opened 3 days ago

WilliamTakeshi commented 3 days ago

This PR addresses issue #280 . It introduces two new optional dependencies: defmt and defmt-or-log. Additionally, it makes the log dependency optional.

The purpose of this change is to allow users to specify either log or defmt as a feature for the lib. This flexibility should simplify debugging the lib on microcontrollers.

As this is my first PR for this library, I am open to feedback and suggestions! Please let me know if any changes are needed.

geonnave commented 2 days ago

Thanks for this PR @WilliamTakeshi!

For my understanding:

Before merging, I would like to have it tested on an embedded device, like running the no_std example in the nRF52840. However, I am leaving for holidays next week and I don't have a board at home, so I will tag @malishav / @chrysn: if one of you guys could verify that it just works as before.

WilliamTakeshi commented 2 days ago

are we still able to use RUST_LOG to set the log level?

Yes, RUST_LOG is still supported (I have tested it using the log feature). For example, you can test it with the following commands:

RUST_LOG=error cargo run --bin coapclient
RUST_LOG=trace cargo run --bin coapserver

allowing you to see only logs on the server.

since both log and defmt are optional, should I select one via features or there is one that is the default? (maybe log is the default since the CI just passed?)

By default, neither log nor defmt is enabled. You can enable either one by specifying the desired feature. As for the CI passing, I wasn't aware that we had a test for the log, so it might have been luck that it passed!

In addition to specifying one of these features, you could also pass another logger configuration, such as embassy-sync/defmt or embassy-sync/log. However, it would be great if someone with an embedded device could test this to confirm.