Skip to content

Commit

Permalink
Fix logging levels in scheduler (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 authored Oct 7, 2024
1 parent cc73b7e commit 3143e80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions crates/scheduler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions crates/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ impl<B: Board> Scheduler<B> {
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();
}
Expand Down Expand Up @@ -493,10 +496,10 @@ impl<B: Board> Scheduler<B> {

fn applet_trapped<B: Board>(scheduler: &mut Scheduler<B>, 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,
Expand Down

0 comments on commit 3143e80

Please sign in to comment.