Add function to extract logs
This commit is contained in:
		@@ -39,3 +39,20 @@ pub fn save_log(
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Make a logs extraction
 | 
			
		||||
pub fn get_logs(day: u64) -> anyhow::Result<Vec<LogEntry>> {
 | 
			
		||||
    let file = AppConfig::get().log_of_day(day);
 | 
			
		||||
 | 
			
		||||
    if !file.exists() {
 | 
			
		||||
        return Ok(Vec::new());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let content = std::fs::read_to_string(file)?
 | 
			
		||||
        .split('\n')
 | 
			
		||||
        .filter(|l| !l.is_empty())
 | 
			
		||||
        .map(serde_json::from_str)
 | 
			
		||||
        .collect::<Result<Vec<_>, _>>()?;
 | 
			
		||||
 | 
			
		||||
    Ok(content)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
#[derive(serde::Serialize, serde::Deserialize, Copy, Clone, Debug)]
 | 
			
		||||
#[derive(serde::Serialize, serde::Deserialize, Copy, Clone, Debug, PartialOrd, Eq, PartialEq)]
 | 
			
		||||
pub enum LogSeverity {
 | 
			
		||||
    Debug,
 | 
			
		||||
    Debug = 0,
 | 
			
		||||
    Info,
 | 
			
		||||
    Warn,
 | 
			
		||||
    Error,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user