diff --git a/lib/src/event.rs b/lib/src/event.rs index f012ea9..c64f1bd 100644 --- a/lib/src/event.rs +++ b/lib/src/event.rs @@ -8,6 +8,7 @@ use std::{ collections::HashMap, + fmt, path::{Path, PathBuf}, process::ExitStatus, }; @@ -61,3 +62,25 @@ impl Event { }) } } + +impl fmt::Display for Event { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Event")?; + for p in &self.particulars { + match p { + Particle::Path(p) => write!(f, " path={}", p.display())?, + Particle::Source(s) => write!(f, " source={:?}", s)?, + Particle::Process(p) => write!(f, " process={}", p)?, + Particle::Signal(s) => write!(f, " signal={:?}", s)?, + Particle::ProcessCompletion(None) => write!(f, " command-completed")?, + Particle::ProcessCompletion(Some(c)) => write!(f, " command-completed({})", c)?, + } + } + + if !self.metadata.is_empty() { + write!(f, " meta: {:?}", self.metadata)?; + } + + Ok(()) + } +}