Is it possible to get the ic_cdk::println!() data when i exec ` dfx deploy backend --verbose --network ic`

#[pre_upgrade]
#[trace]
fn pre_upgrade() {

    ...
    some json files
    ...
    // save to db
    let json = serde_json::to_string(&payload).unwrap();
    ic_cdk::println!(
      "\x1b[31m SAVING THE PAYLOAD INTO STABLE STUCTURE: \x1b[0m  \n {}",
      json
    );
    let mut memory = get_upgrades_memory();
    let mut writer = get_writer(&mut memory);
    let ret = writer.write_all(json.as_bytes());
    ret.expect("Failed to write to writer");
  });
}

I know that when i exec dfx deploy backend --verbose the print info will print at dfx start terminal .
BUT
is it possible to get the ic_cdk::println!() data when i exec dfx deploy backend --verbose --network ic ?

There’s currently no way to get those printlns. This is in the works: Canister Logging Support [Community Consideration]

1 Like

ok. since this situation. i can try to use http outcalls to save the info into a web2 server for debugging.

I would (and have in the past) personally simply write a crappy ring buffer log that you can query later. Outcalls are very expensive ‘just’ for logging

1 Like

Wahoo . That will be great! Thank you so much for your reply.
So, i should goto Canister Logging Support [Community Consideration] or somewhere you mentioned to get the ring buffer log maybe ?

Hello!
While the mentioned feature is under development, you can give canistergeek.app a try (rust library).

What I meant was to roll your own. E.g:

let log: Vec<String> = Vec::new();

fn log(text: String) {
  log.push(text);
  if log.len() > 10 {
    log.remove(0);
  }
}
1 Like