Skip to content

Log plugins

If you’re running CrabNebula DevTools next to another tracing/log plugin or crate, DevTools will prevent any other logger from being initialized.

Terminal window
thread 'main' panicked at src/main.rs:24:10:
error while running tauri application: PluginInitialization("log", "attempted to set a logger after the logging system was already initialized")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We recommend using only CrabNebula DevTools in development mode, and any other tracing/tracking crates in production.

fn run() {
let mut builder = tauri::Builder::default();
#[cfg(debug_assertions)]
{
let devtools = tauri_plugin_devtools::init();
builder = builder.plugin(devtools);
}
#[cfg(not(debug_assertions))]
{
use tauri_plugin_log::{Builder, Target, TargetKind};
let log_plugin = Builder::default()
.targets([
Target::new(TargetKind::Stdout),
Target::new(TargetKind::LogDir { file_name: None }),
Target::new(TargetKind::Webview),
])
.build();
builder = builder.plugin(log_plugin);
}
builder
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}