mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Optimizing log code
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use super::{FileTransferActivity, InputField, InputMode, LogLevel, LogRecord, PopupType};
|
||||
use super::{Color, FileTransferActivity, InputField, InputMode, LogLevel, LogRecord, PopupType};
|
||||
|
||||
impl FileTransferActivity {
|
||||
/// ### log
|
||||
@@ -38,6 +38,20 @@ impl FileTransferActivity {
|
||||
self.log_index = 0;
|
||||
}
|
||||
|
||||
/// ### log_and_alert
|
||||
///
|
||||
/// Add message to log events and also display it as an alert
|
||||
pub(super) fn log_and_alert(&mut self, level: LogLevel, msg: String) {
|
||||
// Set input mode
|
||||
let color: Color = match level {
|
||||
LogLevel::Error => Color::Red,
|
||||
LogLevel::Info => Color::Green,
|
||||
LogLevel::Warn => Color::Yellow,
|
||||
};
|
||||
self.log(level, msg.as_str());
|
||||
self.input_mode = InputMode::Popup(PopupType::Alert(color, msg));
|
||||
}
|
||||
|
||||
/// ### create_quit_popup
|
||||
///
|
||||
/// Create quit popup input mode (since must be shared between different input handlers)
|
||||
|
||||
Reference in New Issue
Block a user