debug log when loading calendar files

This commit is contained in:
Fabrizio Iannetti 2024-09-14 09:40:31 +02:00
parent dfbb5a11f8
commit 4058623bdd
1 changed files with 4 additions and 1 deletions

View File

@ -3,7 +3,7 @@ use icalendar::{Component, DatePerhapsTime, CalendarDateTime, CalendarComponent}
use chrono::NaiveDate; use chrono::NaiveDate;
use crate::model::events::EventsCollection; use crate::model::events::EventsCollection;
use std::fs; use std::fs;
use log::warn; use log::{warn, debug};
use super::events::EventType; use super::events::EventType;
@ -23,6 +23,7 @@ fn as_date(cal_date: &DatePerhapsTime) -> NaiveDate {
} }
fn create_event(events: &mut EventsCollection, event: &icalendar::Event, ev_type: &EventType) { fn create_event(events: &mut EventsCollection, event: &icalendar::Event, ev_type: &EventType) {
debug!(" calendar event: {:?}", event);
events.create( events.create(
as_date(&event.get_start().unwrap()), as_date(&event.get_start().unwrap()),
as_date(&event.get_end().unwrap()).pred_opt().unwrap(), as_date(&event.get_end().unwrap()).pred_opt().unwrap(),
@ -33,6 +34,8 @@ fn create_event(events: &mut EventsCollection, event: &icalendar::Event, ev_type
pub fn load_calendar(calendar_path: &std::path::Path, events: &mut EventsCollection) { pub fn load_calendar(calendar_path: &std::path::Path, events: &mut EventsCollection) {
let mut calendar = icalendar::Calendar::new(); let mut calendar = icalendar::Calendar::new();
debug!("reading calendar: {:?}", calendar_path);
let contents = match fs::read_to_string(calendar_path) { let contents = match fs::read_to_string(calendar_path) {
Ok(file_content) => file_content, Ok(file_content) => file_content,
Err(e) => { warn!("Could not read the calendar: {}", e); return; }, Err(e) => { warn!("Could not read the calendar: {}", e); return; },