summaryrefslogtreecommitdiffstats
path: root/src/session.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.rs')
-rw-r--r--src/session.rs25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/session.rs b/src/session.rs
index 360e2e1..a7ed261 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -11,21 +11,13 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Default)]
pub struct Sessions {
inner: HashMap<String, State>,
- hostname: Option<String>,
+ exclude: Vec<String>,
}
impl Sessions {
- pub fn new() -> Self {
- let hostname = match hostname::get() {
- Ok(h) => Some(h.to_string_lossy().into()),
- Err(err) => {
- tracing::error!(%err, "Failed to get hostname to filter output.");
- None
- }
- };
-
+ pub fn new(exclude: Vec<String>) -> Self {
Self {
- hostname,
+ exclude,
..Default::default()
}
}
@@ -49,16 +41,12 @@ impl Sessions {
Ok(())
}
- fn add(&mut self, item: Session) {
+ pub fn add(&mut self, item: Session) {
let span = tracing::trace_span!("Entry", ?item);
let _guard = span.enter();
- if self
- .hostname
- .as_ref()
- .map(|h| h == &item.name)
- .unwrap_or_default()
- {
+ if self.exclude.contains(&item.name) {
+ tracing::debug!(item.name, "Skipping excluded item");
return;
}
@@ -107,6 +95,7 @@ pub enum State {
Created(Duration),
#[serde(with = "epoch_timestamp")]
Attached(Duration),
+ LocalHost,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]