Skip to content

Commit

Permalink
feat: capture and show other fields
Browse files Browse the repository at this point in the history
Has a problem, when data is present the next load appears to be the default
  • Loading branch information
c-git committed Feb 10, 2024
1 parent ef9c748 commit 68b924f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const SPACE_BETWEEN_TABLES: f32 = 10.;
#[derive(serde::Deserialize, serde::Serialize)]
#[serde(default)] // if we add new fields, give them default values when deserializing old state
pub struct LogViewerApp {
#[serde(skip)]
// TODO Fix issue where if data is included in the save load fails? (Need to check if it is failing and check if we can do a round trip on deserialize then serialize then deserialize)
data: Option<Data>,
details_size: f32,

Expand Down Expand Up @@ -151,8 +153,10 @@ impl LogViewerApp {
});
});

let mut iter_extra = selected_log_row.extra.iter();

table.body(|body| {
body.rows(text_height, 4, |mut row| {
body.rows(text_height, 4 + selected_log_row.extra.len(), |mut row| {
let row_index = row.index();
match row_index {
0 => {
Expand Down Expand Up @@ -187,7 +191,17 @@ impl LogViewerApp {
ui.label(selected_log_row.msg());
});
}
_ => todo!("Show all other fields"),
_ => {
let (key, value) = iter_extra
.next()
.expect("should not run out and still get called");
row.col(|ui| {
ui.label(key);
});
row.col(|ui| {
ui.label(value.to_string());
});
}
}
});
});
Expand Down
6 changes: 5 additions & 1 deletion src/app/data.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::BTreeMap;

use anyhow::Context;

#[derive(serde::Deserialize, serde::Serialize, Default, Debug)]
Expand All @@ -13,7 +15,9 @@ pub struct LogRow {
#[serde(rename = "otel.name")]
otel_name: Option<String>,
msg: Option<String>,
// TODO 2: Capture other info

#[serde(flatten)]
pub extra: BTreeMap<String, serde_json::Value>,
}

impl LogRow {
Expand Down

0 comments on commit 68b924f

Please sign in to comment.