Skip to content

Commit

Permalink
Group debug implementations by features
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 31, 2024
1 parent ac26f65 commit d550d61
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ impl std::fmt::Debug for crate::System {
}
}

#[cfg(feature = "system")]
impl std::fmt::Debug for crate::Process {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Process")
.field("pid", &self.pid())
.field("parent", &self.parent())
.field("name", &self.name())
.field("environ", &self.environ())
.field("command", &self.cmd())
.field("executable path", &self.exe())
.field("current working directory", &self.cwd())
.field("memory usage", &self.memory())
.field("virtual memory usage", &self.virtual_memory())
.field("CPU usage", &self.cpu_usage())
.field("status", &self.status())
.field("root", &self.root())
.field("disk_usage", &self.disk_usage())
.field("user_id", &self.user_id())
.field("effective_user_id", &self.effective_user_id())
.finish()
}
}

#[cfg(feature = "disk")]
impl std::fmt::Debug for crate::Disk {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -53,29 +76,6 @@ impl std::fmt::Debug for crate::Disks {
}
}

#[cfg(feature = "system")]
impl std::fmt::Debug for crate::Process {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Process")
.field("pid", &self.pid())
.field("parent", &self.parent())
.field("name", &self.name())
.field("environ", &self.environ())
.field("command", &self.cmd())
.field("executable path", &self.exe())
.field("current working directory", &self.cwd())
.field("memory usage", &self.memory())
.field("virtual memory usage", &self.virtual_memory())
.field("CPU usage", &self.cpu_usage())
.field("status", &self.status())
.field("root", &self.root())
.field("disk_usage", &self.disk_usage())
.field("user_id", &self.user_id())
.field("effective_user_id", &self.effective_user_id())
.finish()
}
}

#[cfg(feature = "component")]
impl std::fmt::Debug for crate::Components {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down

0 comments on commit d550d61

Please sign in to comment.