| Crates.io | esp-println |
| lib.rs | esp-println |
| version | 0.15.0 |
| created_at | 2022-06-14 15:48:55.068219+00 |
| updated_at | 2025-07-16 10:49:02.608893+00 |
| description | Provides `print!` and `println!` implementations various Espressif devices |
| homepage | |
| repository | https://github.com/esp-rs/esp-hal |
| max_upload_size | |
| id | 605914 |
| size | 48,162 |
A library that provides print!, println!, dbg! implementations and
logging capabilities for Espressif devices.
defmt backendesp-println = { version = "0.11.0", features = ["esp32c2"] }
or cargo add esp-println --features esp32c2
It's important to specify your target device as feature.
Then in your program:
use esp_println::println;
You can now println!("Hello world") as usual.
With the feature log-04 activated, and version 0.4 of the log crate added to your dependencies,
you can initialize a simple logger like this:
init_logger(log::LevelFilter::Info);
There is a default feature colors which enables colored log output.
Additionally, you can use
init_logger_from_env();
In this case the following environment variables are used:
ESP_LOG log messages you want to show, similar to RUST_LOG. RegEx is not supported. e.g. warn,test::foo=info,test::foo::bar=debugIf this simple logger implementation isn't sufficient for your needs, you can implement your own logger on top of esp-println. See Implementing a Logger section log documentaion
defmtUsing the defmt-espflash feature, esp-println will install a defmt global logger. The logger will
output to the same data stream as println!(), and adds framing bytes so it can be used even with
other, non-defmt output. Using the defmt-espflash feature automatically uses the rzCOBS encoding and does
not allow changing the encoding.
Follow the defmt book's setup instructions on how to
set up defmt. Remember, the global logger is already installed for you by esp-println!
Please note that defmt does not provide MSRV guarantees with releases, and as such we are not able to make any MSRV guarantees when this feature is enabled. For more information refer to the MSRV section of defmt's README:
https://github.com/knurling-rs/defmt?tab=readme-ov-file#msrv
If you experience linker errors, make sure you have some reference to esp_println in your code.
If you don't use esp_println directly, you'll need to add e.g. use esp_println as _; to your
import statements. This ensures that the global logger will not be removed by the compiler.
This crate is guaranteed to compile when using the latest stable Rust version at the time of the crate's release. It might compile with older versions, but that may change in any new release, including patches.
Licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.