Nettoyage du code généré par IA.

Remise à plat des états de l'application (saisie, affichage...)
This commit is contained in:
2025-05-19 22:32:03 +02:00
parent aa26634e82
commit 18da265098
4 changed files with 149 additions and 138 deletions

View File

@@ -1,8 +1,7 @@
use crate::models::{LogEntry, SMTPSession};
use chrono::{Datelike, NaiveDateTime};
use regex::Regex;
use std::{collections::HashMap, path::Path, time::SystemTime};
use anyhow::Context;
use std::{collections::HashMap};
lazy_static::lazy_static! {
static ref LOG_LINE_RE: Regex = Regex::new(
@@ -19,10 +18,6 @@ fn get_log_year(file_path: Option<&str>) -> Option<i32> {
})
}
pub fn parse_log_file(contents: &str) -> anyhow::Result<Vec<SMTPSession>> {
parse_log_file_with_path(contents, None)
}
pub fn parse_log_file_with_path(contents: &str, file_path: Option<&str>) -> anyhow::Result<Vec<SMTPSession>> {
let mut sessions: HashMap<String, SMTPSession> = HashMap::new();
let log_year = get_log_year(file_path).unwrap_or_else(|| chrono::Local::now().year());
@@ -32,8 +27,6 @@ pub fn parse_log_file_with_path(contents: &str, file_path: Option<&str>) -> anyh
let month = &captures["month"];
let day = &captures["day"];
let time = &captures["time"];
let hostname = captures["hostname"].to_string();
let process = captures["process"].to_string();
let message = captures["message"].to_string();
// Create a timestamp string in the format that chrono can parse
@@ -52,8 +45,6 @@ pub fn parse_log_file_with_path(contents: &str, file_path: Option<&str>) -> anyh
let entry = LogEntry {
timestamp,
hostname,
process,
message: message.clone(),
};