Use tmp_dir rather than /tmp/ (#260)
Uses a less hard-coded method of writing to /tmp/.
This commit is contained in:
parent
9afb6d7c88
commit
5b33e8d6b4
|
@ -262,7 +262,7 @@ fn read_proc<S: core::hash::BuildHasher>(
|
||||||
.ok_or(BottomError::MinorError)?
|
.ok_or(BottomError::MinorError)?
|
||||||
.to_string();
|
.to_string();
|
||||||
let command = {
|
let command = {
|
||||||
let cmd = read_path_contents(&pid_stat.proc_cmdline_path)?;
|
let cmd = read_path_contents(&pid_stat.proc_cmdline_path)?; // FIXME: [PROC] Use full proc name all the time
|
||||||
if cmd.trim().is_empty() {
|
if cmd.trim().is_empty() {
|
||||||
format!("[{}]", name)
|
format!("[{}]", name)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,6 +7,7 @@ use bottom::{canvas, constants::*, data_conversion::*, options::*, *};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
|
ffi::OsStr,
|
||||||
io::{stdout, Write},
|
io::{stdout, Write},
|
||||||
panic,
|
panic,
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -29,11 +30,13 @@ fn main() -> Result<()> {
|
||||||
let matches = clap::get_matches();
|
let matches = clap::get_matches();
|
||||||
let is_debug = matches.is_present("debug");
|
let is_debug = matches.is_present("debug");
|
||||||
if is_debug {
|
if is_debug {
|
||||||
utils::logging::init_logger(log::LevelFilter::Trace, "/tmp/bottom_debug.log")?;
|
let mut tmp_dir = std::env::temp_dir();
|
||||||
|
tmp_dir.push("bottom_debug.log");
|
||||||
|
utils::logging::init_logger(log::LevelFilter::Trace, tmp_dir.as_os_str())?;
|
||||||
} else {
|
} else {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
utils::logging::init_logger(log::LevelFilter::Debug, "debug.log")?;
|
utils::logging::init_logger(log::LevelFilter::Debug, OsStr::new("debug.log"))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ When searching for a process, enables case sensitivity by default.\n\n",
|
||||||
.help("Enables debug logging.")
|
.help("Enables debug logging.")
|
||||||
.long_help(
|
.long_help(
|
||||||
"\
|
"\
|
||||||
Enables debug logging to /tmp/bottom_debug.log.",
|
Enables debug logging. The program will print where it logged to after running.",
|
||||||
);
|
);
|
||||||
let disable_click = Arg::with_name("disable_click")
|
let disable_click = Arg::with_name("disable_click")
|
||||||
.long("disable_click")
|
.long("disable_click")
|
||||||
|
|
|
@ -254,7 +254,9 @@ pub fn cleanup_terminal(
|
||||||
terminal.show_cursor()?;
|
terminal.show_cursor()?;
|
||||||
|
|
||||||
if is_debug {
|
if is_debug {
|
||||||
println!("Your debug file is located at \"/tmp/bottom_debug.log\".",);
|
let mut tmp_dir = std::env::temp_dir();
|
||||||
|
tmp_dir.push("bottom_debug.log");
|
||||||
|
println!("Your debug file is located at {:?}", tmp_dir.as_os_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
use std::ffi::OsStr;
|
||||||
|
|
||||||
pub fn init_logger(
|
pub fn init_logger(
|
||||||
min_level: log::LevelFilter, debug_file_name: &str,
|
min_level: log::LevelFilter, debug_file_name: &OsStr,
|
||||||
) -> Result<(), fern::InitError> {
|
) -> Result<(), fern::InitError> {
|
||||||
fern::Dispatch::new()
|
fern::Dispatch::new()
|
||||||
.format(|out, message, record| {
|
.format(|out, message, record| {
|
||||||
|
|
Loading…
Reference in New Issue