cli_log/mem.rs
1use log::*;
2
3/// log the current and peak physical memory used by
4/// the current process, if the given log level is
5/// reached
6///
7/// This function is only available when the feature
8/// "mem" is enabled and when the OS supports it
9/// (unix-like systems).
10pub fn log_mem(level: Level) {
11 if log_enabled!(level) {
12 if let Ok(mem) = proc_status::mem_usage() {
13 log!(
14 level,
15 "Physical mem usage: current={}, peak={}",
16 file_size::fit_4(mem.current as u64),
17 file_size::fit_4(mem.peak as u64),
18 );
19 }
20 }
21}