summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2020-09-30 22:06:57 -0400
committerGitHub <noreply@github.com>2020-09-30 22:06:57 -0400
commit9afb6d7c88ca515ecd8d37134b567b6d17e0f0fb (patch)
tree0f5918a7ba31de81d388bc9c1b738423386fe9d8 /src/utils
parent57e87d88d09e6282770a2315977fe43ef52958b4 (diff)
feature: add --debug flag for logging (#259)
Adds a `--debug` flag to aid in debugging issues. This saves to `/tmp/bottom_debug.log`.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/logging.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/utils/logging.rs b/src/utils/logging.rs
index 72822897..fcd1e211 100644
--- a/src/utils/logging.rs
+++ b/src/utils/logging.rs
@@ -1,5 +1,6 @@
-#[cfg(debug_assertions)]
-pub fn init_logger() -> Result<(), fern::InitError> {
+pub fn init_logger(
+ min_level: log::LevelFilter, debug_file_name: &str,
+) -> Result<(), fern::InitError> {
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
@@ -10,12 +11,8 @@ pub fn init_logger() -> Result<(), fern::InitError> {
message
))
})
- .level(if cfg!(debug_assertions) {
- log::LevelFilter::Debug
- } else {
- log::LevelFilter::Info
- })
- .chain(fern::log_file("debug.log")?)
+ .level(min_level)
+ .chain(fern::log_file(debug_file_name)?)
.apply()?;
Ok(())