From 3143e801d8c111371c4cd2ede3b43568cd19dd53 Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Mon, 7 Oct 2024 15:08:10 +0200 Subject: [PATCH] Fix logging levels in scheduler (#635) --- crates/scheduler/CHANGELOG.md | 2 ++ crates/scheduler/src/lib.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/scheduler/CHANGELOG.md b/crates/scheduler/CHANGELOG.md index 14ab311b..f9c034ee 100644 --- a/crates/scheduler/CHANGELOG.md +++ b/crates/scheduler/CHANGELOG.md @@ -8,6 +8,7 @@ ### Minor +- Trap applets calling into host during init (except for debug printing) - Support `PlatformLock` protocol call - Support `AppletExitStatus` protocol call (the platform keeps running when the applet exits) - Support `Applet{Install,Uninstall}` protocol calls @@ -16,6 +17,7 @@ ### Patch +- Reduce logging level of applet trapping (those are not errors) - Make sure at compile-time that exactly one `native` or `wasm` feature is enabled - Use `derive-where` instead of `derivative` - Implement `defmt::Format` for `Key` when `defmt` is enabled diff --git a/crates/scheduler/src/lib.rs b/crates/scheduler/src/lib.rs index 6a3c6f3b..5d25cd3b 100644 --- a/crates/scheduler/src/lib.rs +++ b/crates/scheduler/src/lib.rs @@ -362,7 +362,10 @@ impl Scheduler { while let Some(call) = self.applet.get().unwrap().store_mut().last_call() { match self.host_funcs[call.index()].descriptor().name { "dp" => (), - x => log::panic!("init called {} into host", log::Debug2Format(&x)), + x => { + log::warn!("init called {} into host", log::Debug2Format(&x)); + return Ok(applet_trapped(self, Some(x))); + } } self.process_applet(); } @@ -493,10 +496,10 @@ impl Scheduler { fn applet_trapped(scheduler: &mut Scheduler, reason: Option<&'static str>) { match reason { - None => log::error!("Applet trapped in wasm (think segfault)."), - Some("sa") => log::error!("Applet aborted (probably a panic)."), - Some("se") => log::warn!("Applet exited."), - Some(name) => log::error!("Applet trapped calling host {:?}.", name), + None => log::warn!("Applet trapped in wasm (think segfault)."), + Some("sa") => log::warn!("Applet aborted (probably a panic)."), + Some("se") => log::info!("Applet exited."), + Some(name) => log::warn!("Applet trapped calling host {:?}.", name), } scheduler.stop_applet(match reason { Some("se") => ExitStatus::Exit,