ic_testkit/pic/
diagnostics.rs1use candid::Principal;
2
3use super::{Pic, startup};
4
5impl Pic {
6 pub fn dump_canister_debug(&self, canister_id: Principal, context: &str) {
8 eprintln!("{context}: debug for canister {canister_id}");
9
10 match self.canister_status(canister_id, None) {
11 Ok(status) => eprintln!("canister_status: {status:?}"),
12 Err(err) => {
13 let message = err.to_string();
14 if startup::is_dead_instance_transport_error(&message) {
15 eprintln!("canister_status unavailable: PocketIC instance no longer reachable");
16 return;
17 }
18 eprintln!("canister_status failed: {err:?}");
19 }
20 }
21
22 match self.fetch_canister_logs(canister_id, Principal::anonymous()) {
23 Ok(records) => {
24 if records.is_empty() {
25 eprintln!("canister logs: <empty>");
26 } else {
27 for record in records {
28 eprintln!("canister log: {record:?}");
29 }
30 }
31 }
32 Err(err) => {
33 let message = err.to_string();
34 if startup::is_dead_instance_transport_error(&message) {
35 eprintln!(
36 "fetch_canister_logs unavailable: PocketIC instance no longer reachable"
37 );
38 return;
39 }
40 eprintln!("fetch_canister_logs failed: {err:?}");
41 }
42 }
43 }
44}