Skip to content

Commit 86005a7

Browse files
committed
update log
1 parent dc40a7a commit 86005a7

1 file changed

Lines changed: 33 additions & 13 deletions

File tree

src-tauri/src/commands/utils.rs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use super::types::{MaaCallbackEvent, MaaState, StateChangedEvent};
66
use crate::ws_broadcast::{WsBroadcast, WsEvent};
7-
use log::error;
7+
use log::{error, warn};
88
use std::path::PathBuf;
99
use std::sync::Arc;
1010
use tauri::{AppHandle, Emitter, Manager};
@@ -308,7 +308,10 @@ pub fn get_checked_task_status_of_instance(
308308
let config = match app_config_state.config.lock() {
309309
Ok(guard) => guard,
310310
Err(e) => {
311-
error!("[MXU_STATUS] fail to lock resource [app_config_state.config]: {:?}", e);
311+
error!(
312+
"[MXU_STATUS] fail to lock resource [app_config_state.config]: {:?}",
313+
e
314+
);
312315
return vec![];
313316
}
314317
};
@@ -345,7 +348,10 @@ pub fn get_checked_task_status_of_instance(
345348
{
346349
Some(inst) => inst,
347350
None => {
348-
error!("[MXU_STATUS] config data [configs/mxu-*.json > .instances] should contains [object] item with whose [.id = {}]", id);
351+
error!(
352+
"[MXU_STATUS] config data [configs/mxu-*.json > .instances] should contains [object] item whose [.id = \"{:?}\"]",
353+
id
354+
);
349355
return vec![];
350356
}
351357
};
@@ -363,17 +369,20 @@ pub fn get_checked_task_status_of_instance(
363369
let instance_runtime_list = match maa_state.instances.lock() {
364370
Ok(guard) => guard,
365371
Err(e) => {
366-
error!("[MXU_STATUS] fail to lock resource [maa_state]: {:?}", e);
372+
error!(
373+
"[MXU_STATUS] fail to lock resource [maa_state]: {:?}",
374+
e
375+
);
367376
return vec![];
368377
}
369378
};
370379

371-
let instance_runtime = match instance_runtime_list.get(instance_id.unwrap_or_default()) {
380+
let instance_runtime = match instance_runtime_list.get(id) {
372381
Some(runtime) => runtime,
373382
None => {
374383
error!(
375-
"[MXU_STATUS] runtime data [maa_state.instances[{}]] should be [object]",
376-
instance_id.unwrap_or_default()
384+
"[MXU_STATUS] runtime data [maa_state.instances[\"{:?}\"]] should be [object]",
385+
id
377386
);
378387
return vec![];
379388
}
@@ -407,7 +416,7 @@ pub fn get_checked_task_status_of_instance(
407416
.unwrap_or("")
408417
.to_string();
409418
let task_name_i18n = i18n
410-
.get(format!("task.{}.label", task_name))
419+
.get(format!("task.{:?}.label", task_name))
411420
.and_then(|v| v.as_str())
412421
.map(|s| s.to_string())
413422
.unwrap_or("".to_string());
@@ -420,19 +429,30 @@ pub fn get_checked_task_status_of_instance(
420429
} else if !task_name.is_empty(){
421430
task_name
422431
} else {
423-
error!(
424-
"[MXU_STATUS] config data [configs/mxu-*.json > .instances[.id = \"{}\"].tasks[.id = \"{}\"].taskName] should be [string]",
432+
warn!(
433+
"[MXU_STATUS] config data [configs/mxu-*.json > .instances[.id = \"{:?}\"].tasks[.id = \"{:?}\"].taskName] should be [non-empty string]",
425434
id,
426435
selected_task_id
427436
);
428437
return None
429438
};
430-
Some(vec![name, status.to_string()])
439+
return Some(vec![name, status.to_string()])
431440
} else {
432-
None
441+
warn!(
442+
"[MXU_STATUS] status not found in runtime data [maa_state.instances[\"{:?}\"].task_run_state.statuses] for task in config data [configs/mxu-*.json > .instances[.id = \"{:?}\"].tasks[.id = \"{:?}\"]",
443+
id,
444+
id,
445+
selected_task_id
446+
);
447+
return None
433448
}
434449
} else {
435-
None
450+
warn!(
451+
"[MXU_STATUS] task not found in config data [configs/mxu-*.json > .instances[.id = \"{:?}\"] related to runtime data [maa_state.instances[\"{:?}\"].task_run_state.pending_task_ids]",
452+
id,
453+
id
454+
);
455+
return None
436456
}
437457
})
438458
.collect();

0 commit comments

Comments
 (0)