summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-12-19 22:48:37 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-12-19 22:48:37 +0100
commit904e7a053c519d6d93ba802b7931da3fbc97cc19 (patch)
tree3d9111db71fad683695f278429b2394c1f2f95ed
parent77b3592fba4fd9aed61efbcbfc72dceb31cfd2be (diff)
Add Gossip message logging
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--gui/src/app/mod.rs37
1 files changed, 29 insertions, 8 deletions
diff --git a/gui/src/app/mod.rs b/gui/src/app/mod.rs
index 857debf..ba0675b 100644
--- a/gui/src/app/mod.rs
+++ b/gui/src/app/mod.rs
@@ -36,6 +36,7 @@ enum Distrox {
timeline: Timeline,
log_visible: bool,
+ log: std::collections::VecDeque<distrox_lib::gossip::GossipMessage>,
},
FailedToStart,
}
@@ -95,7 +96,8 @@ impl Application for Distrox {
input: text_input::State::default(),
input_value: String::default(),
timeline: Timeline::new(),
- log_visible: false
+ log_visible: false,
+ log: std::collections::VecDeque::with_capacity(1000),
};
@@ -103,7 +105,7 @@ impl Application for Distrox {
iced::Command::none()
},
- Distrox::Loaded { profile, ref mut input_value, timeline, log_visible, .. } => {
+ Distrox::Loaded { profile, ref mut input_value, timeline, log_visible, log, .. } => {
match message {
Message::InputChanged(input) => {
*input_value = input;
@@ -160,6 +162,15 @@ impl Application for Distrox {
iced::Command::none()
}
+ Message::GossipHandled(msg) => {
+ log::trace!("Gossip handled, adding to log: {:?}", msg);
+ log.push_back(msg);
+ while log.len() > 1000 {
+ let _ = log.pop_front();
+ }
+ iced::Command::none()
+ }
+
_ => iced::Command::none(),
}
}
@@ -187,7 +198,7 @@ impl Application for Distrox {
.into()
}
- Distrox::Loaded { input, input_value, timeline, scroll, log_visible, .. } => {
+ Distrox::Loaded { input, input_value, timeline, scroll, log_visible, log, .. } => {
let left_column = Column::new()
.into();
@@ -230,11 +241,21 @@ impl Application for Distrox {
.push(content);
if *log_visible {
- let log = Column::new()
- .push({
- iced::Text::new("Here goes some log,... not yet implemented!")
- .size(8)
- });
+ let log = Column::with_children({
+ log.iter()
+ .map(|msg| {
+ use distrox_lib::gossip::GossipMessage;
+ match msg {
+ GossipMessage::CurrentProfileState { peer_id, cid } => {
+ format!("Peer {:?} is at {:?}", peer_id, cid)
+ }
+ }
+ })
+ .map(iced::Text::new)
+ .map(|txt| txt.size(8))
+ .map(iced::Element::from)
+ .collect()
+ });
content.push(log)
} else {
content