1#[cfg(feature = "system")]
4impl std::fmt::Debug for crate::Cpu {
5 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6 f.debug_struct("Cpu")
7 .field("name", &self.name())
8 .field("CPU usage", &self.cpu_usage())
9 .field("frequency", &self.frequency())
10 .field("vendor ID", &self.vendor_id())
11 .field("brand", &self.brand())
12 .finish()
13 }
14}
15
16#[cfg(feature = "system")]
17impl std::fmt::Debug for crate::System {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 f.debug_struct("System")
20 .field("global CPU usage", &self.global_cpu_usage())
21 .field("load average", &Self::load_average())
22 .field("total memory", &self.total_memory())
23 .field("free memory", &self.free_memory())
24 .field("total swap", &self.total_swap())
25 .field("free swap", &self.free_swap())
26 .field("nb CPUs", &self.cpus().len())
27 .field("nb processes", &self.processes().len())
28 .finish()
29 }
30}
31
32#[cfg(feature = "system")]
33impl std::fmt::Debug for crate::Process {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 f.debug_struct("Process")
36 .field("pid", &self.pid())
37 .field("parent", &self.parent())
38 .field("name", &self.name())
39 .field("environ", &self.environ())
40 .field("command", &self.cmd())
41 .field("executable path", &self.exe())
42 .field("current working directory", &self.cwd())
43 .field("memory usage", &self.memory())
44 .field("virtual memory usage", &self.virtual_memory())
45 .field("CPU usage", &self.cpu_usage())
46 .field("accumulated CPU time", &self.accumulated_cpu_time())
47 .field("status", &self.status())
48 .field("root", &self.root())
49 .field("disk_usage", &self.disk_usage())
50 .field("user_id", &self.user_id())
51 .field("effective_user_id", &self.effective_user_id())
52 .finish()
53 }
54}
55
56#[cfg(feature = "disk")]
57impl std::fmt::Debug for crate::Disk {
58 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59 write!(
60 fmt,
61 "Disk({:?})[FS: {:?}][Type: {:?}][removable: {}][I/O: {:?}] mounted on {:?}: {}/{} B",
62 self.name(),
63 self.file_system(),
64 self.kind(),
65 if self.is_removable() { "yes" } else { "no" },
66 self.usage(),
67 self.mount_point(),
68 self.available_space(),
69 self.total_space(),
70 )
71 }
72}
73
74#[cfg(feature = "disk")]
75impl std::fmt::Debug for crate::Disks {
76 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
77 f.debug_list().entries(self.iter()).finish()
78 }
79}
80
81#[cfg(feature = "component")]
82impl std::fmt::Debug for crate::Components {
83 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
84 f.debug_list().entries(self.iter()).finish()
85 }
86}
87
88#[cfg(feature = "component")]
89impl std::fmt::Debug for crate::Component {
90 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
91 write!(f, "{} ", self.label())?;
92 if let Some(temperature) = self.temperature() {
93 write!(f, "temperature: {temperature}°C (")?;
94 } else {
95 f.write_str("temperature: unknown (")?;
96 }
97 if let Some(max) = self.max() {
98 write!(f, "max: {max}°C / ")?;
99 } else {
100 f.write_str("max: unknown / ")?;
101 }
102 if let Some(critical) = self.critical() {
103 write!(f, "critical: {critical}°C)")
104 } else {
105 f.write_str("critical: unknown)")
106 }
107 }
108}
109
110#[cfg(feature = "network")]
111impl std::fmt::Debug for crate::Networks {
112 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113 f.debug_list().entries(self.iter()).finish()
114 }
115}
116
117#[cfg(feature = "network")]
118impl std::fmt::Debug for crate::NetworkData {
119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120 f.debug_struct("NetworkData")
121 .field("income", &self.received())
122 .field("total income", &self.total_received())
123 .field("outcome", &self.transmitted())
124 .field("total outcome", &self.total_transmitted())
125 .field("packets income", &self.packets_received())
126 .field("total packets income", &self.total_packets_received())
127 .field("packets outcome", &self.packets_transmitted())
128 .field("total packets outcome", &self.total_packets_transmitted())
129 .field("errors income", &self.errors_on_received())
130 .field("total errors income", &self.total_errors_on_received())
131 .field("errors outcome", &self.errors_on_transmitted())
132 .field("total errors outcome", &self.total_errors_on_transmitted())
133 .field("maximum transfer unit", &self.mtu())
134 .finish()
135 }
136}
137
138#[cfg(feature = "user")]
139impl std::fmt::Debug for crate::Users {
140 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
141 f.debug_list().entries(self.iter()).finish()
142 }
143}
144
145#[cfg(feature = "user")]
146impl std::fmt::Debug for crate::User {
147 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
148 f.debug_struct("User")
149 .field("uid", &self.id())
150 .field("gid", &self.group_id())
151 .field("name", &self.name())
152 .finish()
153 }
154}