Skip to content

Commit

Permalink
try different approach
Browse files Browse the repository at this point in the history
  • Loading branch information
ragibkl committed Aug 26, 2024
1 parent 607fc7b commit c7cf9fa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/logs_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
};

use chrono::{DateTime, Duration, NaiveDateTime, Utc};
use serde::Deserialize;

use crate::tasks::dnstap::read_dnstap_logs;

Expand Down Expand Up @@ -82,13 +81,13 @@ impl From<&RawLog> for QueryLog {
fn extract_query_logs(content: &str) -> HashMap<String, Vec<QueryLog>> {
let mut logs_store: HashMap<String, Vec<QueryLog>> = HashMap::new();

for document in serde_yaml::Deserializer::from_str(content) {
let Ok(raw_log) = RawLog::deserialize(document) else {
for part in content.split("\n---\n").map(|s| s.trim()) {
let Ok(raw_log) = serde_yaml::from_str::<RawLog>(part) else {
tracing::info!("LogsStore extract_query_logs fail to extract part: {part}");
continue;
};

let query_log = QueryLog::from(&raw_log);
tracing::info!("LogsStore extracted query_log");
match logs_store.get_mut(&query_log.ip) {
Some(queries) => {
queries.push(query_log);
Expand Down Expand Up @@ -154,6 +153,7 @@ impl LogsStore {

tracing::info!("LogsStore logs_hash_map");
self.merge_logs(logs_hash_map);
self.remove_expired_logs();
tracing::info!("LogsStore logs_hash_map. DONE");
}

Expand Down

0 comments on commit c7cf9fa

Please sign in to comment.