The sample prints messages for all levels, except for debug.
Add such messages.

To make sure they are actually printed, enable debug assertions.

This example will become even more useful when dynamic debug is
implemented for Rust.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
 samples/rust/Makefile           | 2 ++
 samples/rust/rust_print_main.rs | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/samples/rust/Makefile b/samples/rust/Makefile
index b986b681cde5..bc27f8851571 100644
--- a/samples/rust/Makefile
+++ b/samples/rust/Makefile
@@ -18,6 +18,8 @@ obj-$(CONFIG_SAMPLE_RUST_DRIVER_SERDEV)               += 
rust_driver_serdev.o
 obj-$(CONFIG_SAMPLE_RUST_CONFIGFS)             += rust_configfs.o
 obj-$(CONFIG_SAMPLE_RUST_SOC)                  += rust_soc.o
 
+RUSTFLAGS_rust_print_main.o += -Cdebug-assertions=y
+
 rust_print-y := rust_print_main.o rust_print_events.o
 
 subdir-$(CONFIG_SAMPLE_RUST_HOSTPROGS)         += hostprogs
diff --git a/samples/rust/rust_print_main.rs b/samples/rust/rust_print_main.rs
index 01729e87d6b5..6b9f59d7fec7 100644
--- a/samples/rust/rust_print_main.rs
+++ b/samples/rust/rust_print_main.rs
@@ -69,6 +69,7 @@ fn init(_module: &'static ThisModule) -> Result<Self> {
         pr_warn!("Warning message (level 4) without args\n");
         pr_notice!("Notice message (level 5) without args\n");
         pr_info!("Info message (level 6) without args\n");
+        pr_debug!("Debug message (level 7) without args\n");
 
         pr_info!("A line that");
         pr_cont!(" is continued");
@@ -81,6 +82,7 @@ fn init(_module: &'static ThisModule) -> Result<Self> {
         pr_warn!("{} message (level {}) with args\n", "Warning", 4);
         pr_notice!("{} message (level {}) with args\n", "Notice", 5);
         pr_info!("{} message (level {}) with args\n", "Info", 6);
+        pr_debug!("{} message (level {}) with args\n", "Debug", 7);
 
         pr_info!("A {} that", "line");
         pr_cont!(" is {}", "continued");

-- 
2.56.0


Reply via email to