fixed, removed log library
This commit is contained in:
@@ -26,7 +26,7 @@ use crate::tui::functions::common::login; // <-- Add login module import
|
||||
use std::time::Instant;
|
||||
use crossterm::cursor::SetCursorStyle;
|
||||
use crossterm::event as crossterm_event;
|
||||
use log; // <-- Add log import
|
||||
use tracing::{info, error};
|
||||
|
||||
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = Config::load()?;
|
||||
@@ -137,7 +137,6 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// --- End Cursor Visibility Logic ---
|
||||
|
||||
// --- 2. Check for Pending Login Action ---
|
||||
// Check *after* drawing, so the loading state was rendered.
|
||||
if login_state.login_request_pending {
|
||||
// Reset the flag *before* calling save
|
||||
login_state.login_request_pending = false;
|
||||
@@ -145,27 +144,33 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create AuthClient and call save
|
||||
match AuthClient::new().await {
|
||||
Ok(mut auth_client_instance) => {
|
||||
// Call the ORIGINAL save function from the login module
|
||||
let save_result = login::save(
|
||||
&mut auth_state,
|
||||
&mut login_state,
|
||||
&mut auth_client_instance,
|
||||
&mut auth_client_instance, // Pass the new client instance
|
||||
&mut app_state,
|
||||
).await;
|
||||
|
||||
// Use tracing for logging the outcome
|
||||
match save_result {
|
||||
Ok(msg) => log::info!("Login save result: {}", msg),
|
||||
Err(e) => log::error!("Error during login save: {}", e),
|
||||
// save returns Result<String, Error>, Ok contains the message
|
||||
Ok(msg) => info!(message = %msg, "Login save result"), // Use tracing::info!
|
||||
Err(e) => error!(error = %e, "Error during login save"), // Use tracing::error!
|
||||
}
|
||||
// Note: save already handles showing the final dialog (success/failure)
|
||||
}
|
||||
Err(e) => {
|
||||
// Handle connection error
|
||||
app_state.show_dialog(
|
||||
// Handle client connection error - show dialog directly
|
||||
// Ensure flag is already false here
|
||||
app_state.show_dialog( // Use show_dialog, not update_dialog_content
|
||||
"Login Failed",
|
||||
&format!("Connection Error: {}", e),
|
||||
vec!["OK".to_string()],
|
||||
DialogPurpose::LoginFailed,
|
||||
DialogPurpose::LoginFailed, // Use appropriate purpose
|
||||
);
|
||||
login_state.error_message = Some(format!("Connection Error: {}", e));
|
||||
log::error!("Failed to create AuthClient: {}", e);
|
||||
error!(error = %e, "Failed to create AuthClient"); // Use tracing::error!
|
||||
}
|
||||
}
|
||||
// After save runs, the state (dialog content, etc.) is updated.
|
||||
|
||||
Reference in New Issue
Block a user