diff --git a/src/log_store.rs b/src/log_store.rs index 488215c..4ac5039 100644 --- a/src/log_store.rs +++ b/src/log_store.rs @@ -160,6 +160,7 @@ impl LogStoreLinear { Utc, ), severity: model::LogLevel::Error, + session_id: Some(0), message: "Foo".to_string(), source_id: 0, visible: crate::model_internal::VISIBLE_ON, diff --git a/src/main.rs b/src/main.rs index 437f9c0..3392740 100644 --- a/src/main.rs +++ b/src/main.rs @@ -360,8 +360,14 @@ fn draw( //We want to anchor on top left though, so calculate that away: let font_offset_y = offset_y + store.font_size - ctx.font_extents().unwrap().descent(); + if let Some(session_id) = &entry.session_id + { + ctx.move_to(store.border_left, font_offset_y); + ctx.show_text(&session_id.to_string()).unwrap(); + } + let date_str = entry.timestamp.format("%d.%m.%y %T%.3f").to_string(); - ctx.move_to(store.border_left, font_offset_y); + ctx.move_to(store.border_left + 40.0, font_offset_y); ctx.show_text(&date_str).unwrap(); let short_sev = match entry.severity { @@ -373,7 +379,7 @@ fn draw( model::LogLevel::Trace => "TRC", }; - ctx.move_to(store.border_left + 180.0, font_offset_y); + ctx.move_to(store.border_left + 220.0, font_offset_y); ctx.show_text(&short_sev).unwrap(); if let Some(anchor_offset) = store.anchor_offset { @@ -400,7 +406,7 @@ fn draw( } } - ctx.move_to(store.border_left + 210.0, font_offset_y); + ctx.move_to(store.border_left + 250.0, font_offset_y); /*let font_face = ctx.get_font_face(); let new_font_face = cairo::FontFace::toy_create("cairo :monospace", font_face.toy_get_slant(), font_face.toy_get_weight()); diff --git a/src/model_internal.rs b/src/model_internal.rs index f063c92..855ae00 100644 --- a/src/model_internal.rs +++ b/src/model_internal.rs @@ -13,6 +13,7 @@ pub const VISIBLE_OFF_FILTER: u8 = 0x4; pub struct LogEntryExt { pub timestamp: chrono::DateTime, pub severity: model::LogLevel, + pub session_id: Option, pub message: String, pub source_id: u32, pub visible: u8, @@ -65,15 +66,26 @@ impl LogSourceExt { } model::LogSourceContents::Entries(v) => LogSourceContentsExt::Entries( v.into_iter() - .map(move |entry| LogEntryExt { - timestamp: entry.timestamp, - severity: entry.severity, - message: remove_nul_bytes(entry.message), - source_id: 0, - visible: VISIBLE_ON, - entry_id: 0, - prev_offset: 0, - next_offset: 0, + .map(move |entry| { + let session_id = entry.custom_fields.get("SessionId").and_then(|custom_field| { + // If the "SessionId" field exists in the HashMap, attempt to extract the value and convert it to `Option` + match custom_field { + model::CustomField::UInt32(value) => Some(*value), + _ => None, // Return None for other variants or if the key doesn't exist + } + }); + + LogEntryExt { + timestamp: entry.timestamp, + severity: entry.severity, + session_id: session_id, + message: remove_nul_bytes(entry.message), + source_id: 0, + visible: VISIBLE_ON, + entry_id: 0, + prev_offset: 0, + next_offset: 0, + } }) .collect(), ),