diff options
author | Toby Vincent <tobyv13@gmail.com> | 2023-04-02 23:08:31 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2023-04-02 23:08:31 -0500 |
commit | 8a6631053a48a64f0c3b21ec0d92b6b687de9638 (patch) | |
tree | 9d05c30fa7c10666000f35a9fdd74590c471597c /src/session.rs | |
parent | c90dc69bd3dccfad43e3a2f26713543b5c876005 (diff) |
feat: add exclude flag and localhost session
Diffstat (limited to 'src/session.rs')
-rw-r--r-- | src/session.rs | 25 |
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)] |