conquerstellar_tauri_core/
lib.rs1use tauri::plugin::{Builder, TauriPlugin};
2use tauri::Runtime;
3use tauri_plugin_log::{Target, TargetKind, RotationStrategy, TimezoneStrategy};
4use log::{info, error, debug, warn};
5
6pub fn init<R: Runtime>() -> TauriPlugin<R> {
7 Builder::new("conquerstellar-core")
8 .setup(|app, _| {
9 app.plugin(tauri_plugin_store::Builder::new().build())?;
11
12 app.plugin(
14 tauri_plugin_log::Builder::new()
15 .level(log::LevelFilter::Debug)
16 .target(Target::new(TargetKind::Stdout))
17 .target(Target::new(TargetKind::LogDir {
18 file_name: Some("app".into()),
19 }))
20 .rotation_strategy(RotationStrategy::KeepAll)
21 .max_file_size(10_000_000)
22 .timezone_strategy(TimezoneStrategy::UseLocal)
23 .build(),
24 )?;
25
26 Ok(())
27 })
28 .invoke_handler(tauri::generate_handler![
29 log_info,
30 log_error,
31 log_debug,
32 log_warn
33 ])
34 .build()
35}
36
37
38#[tauri::command]
39fn log_info(message: String) {
40 info!("{}", message);
41}
42
43#[tauri::command]
44fn log_error(message: String) {
45 error!("{}", message);
46}
47
48#[tauri::command]
49fn log_debug(message: String) {
50 debug!("{}", message);
51}
52
53#[tauri::command]
54fn log_warn(message: String) {
55 warn!("{}", message);
56}