diff options
author | zjp <jiping_zhou@foxmail.com> | 2023-05-13 13:47:21 +0800 |
---|---|---|
committer | zjp <jiping_zhou@foxmail.com> | 2023-05-13 13:47:21 +0800 |
commit | 0fe4bc24472de7f22cf088c273f5a7b6b9cb114e (patch) | |
tree | d2cca61bdb26a89648dd5694361f814cdc75ceab | |
parent | 8a2bf7d1eb1c82ed227f44955849082b4093b124 (diff) |
eprintln init_logger failure (may need redir if it's flushed away)
and add a description on logging
-rw-r--r-- | docs/config_file.md | 6 | ||||
-rw-r--r-- | src/bin/main.rs | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/docs/config_file.md b/docs/config_file.md index d7db573..25498c0 100644 --- a/docs/config_file.md +++ b/docs/config_file.md @@ -29,3 +29,9 @@ Run the following command to generate a config file with the default parameters: ```sh navi info config-example > "$(navi info config-path)" ``` + +### Logging + +The log file will be created under the same directory where the config locates. + +And you can use the `RUST_LOG` env to set the log level, e.g. `RUST_LOG=debug navi`. diff --git a/src/bin/main.rs b/src/bin/main.rs index 01f9ffb..fa12d64 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -24,8 +24,11 @@ impl FileAnIssue { } } -fn main() -> Result<(), anyhow::Error> { - init_logger()?; +fn main() -> anyhow::Result<()> { + if let Err(err) = init_logger() { + // may need redir stderr to a file to show this log initialization error + eprintln!("failed to initialize logging: {err:?}"); + } navi::handle().map_err(|e| { error!("{e:?}"); FileAnIssue::new(e).into() |