summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzjp <jiping_zhou@foxmail.com>2023-05-13 13:47:21 +0800
committerDenis Isidoro <denis.isidoro@uber.com>2023-12-10 06:26:32 -0300
commit2026b708cfe4994e283f64d080df1ed0e9b0d9cc (patch)
tree4a9c4c11633262212249335cf2eec7c79b465c04
parent13318c449477a7091f4239b2f2403117e33c8dee (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.md37
-rw-r--r--src/bin/main.rs7
2 files changed, 42 insertions, 2 deletions
diff --git a/docs/config_file.md b/docs/config_file.md
new file mode 100644
index 0000000..25498c0
--- /dev/null
+++ b/docs/config_file.md
@@ -0,0 +1,37 @@
+## Config file
+
+- [Example](#example)
+- [Location](#location)
+- [Creating the file](#creating-the-file)
+
+### Example
+
+An example config can be found by running:
+
+```sh
+navi info config-example
+```
+
+You can also read it online by clicking [here](./config_file_example.yaml).
+
+### Location
+
+Run the following command to check where the config file is/should be located:
+
+```sh
+navi info config-path
+```
+
+### Creating the file
+
+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()