Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/log_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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());
Expand Down
30 changes: 21 additions & 9 deletions src/model_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub const VISIBLE_OFF_FILTER: u8 = 0x4;
pub struct LogEntryExt {
pub timestamp: chrono::DateTime<Utc>,
pub severity: model::LogLevel,
pub session_id: Option<u32>,
pub message: String,
pub source_id: u32,
pub visible: u8,
Expand Down Expand Up @@ -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<u32>`
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(),
),
Expand Down