Logging
When the Auric CLI generates your app skeleton with the init or new subcommand, the
following default code is added into your src/main.rs which initializes the console_log
crate:
fn main() {
console_error_panic_hook::set_once();
auric_runtime::console_log::init_with_level(log::Level::Debug)
.expect("failed initializing logging");
leptos::mount::mount_to_body(generated::views::application::ApplicationView);
}
So to log to the console from anywhere in your app, use console_log macros
such as log::debug! or log::info! like this:
#[derive(AuricController, Default)]
pub struct MyController {}
#[async_trait(?Send)]
impl Controller for MyController {
fn init(&mut self, _context: &dyn Context) -> Result<()> {
let x = 5;
log::debug!("MyController initialized with x={x}");
Ok(())
}
}