feat(logging): IRONBAR_LOG and IRONBAR_FILE_LOG env vars

This commit is contained in:
Jake Stanger 2022-10-16 13:42:59 +01:00
parent 70e1b526a9
commit ec1d59677b
No known key found for this signature in database
GPG Key ID: C51FC8F9CB0BEA61
3 changed files with 15 additions and 5 deletions

View File

@ -14,3 +14,4 @@ I welcome contributions of any kind with open arms. That said, please do stick t
- For issues:
- Please provide as much information as you can - share your config, any logs, steps to reproduce...
- If reporting an error, please ensure you use `IRONBAR_LOG` or `IRONBAR_FILE_LOG` set to `debug`.

View File

@ -1,6 +1,6 @@
# Ironbar
Ironbar is a customisable and feature-rich bar targeting wlroots compositors, written in Rust.
Ironbar is a customisable and feature-rich bar for wlroots compositors, written in Rust.
It uses GTK3 and gtk-layer-shell.
The bar can be styled to your liking using CSS and hot-loads style changes.
@ -8,9 +8,8 @@ For information and examples on styling please see the [wiki](https://github.com
![Screenshot of fully configured bar with MPD widget open](https://user-images.githubusercontent.com/5057870/184539623-92d56a44-a659-49a9-91f9-5cdc453e5dfb.png)
## Installation
Run using `ironbar`.
## Installation
### Cargo
@ -42,6 +41,15 @@ install target/release/ironbar ~/.local/bin/ironbar
[repo](https://github.com/jakestanger/ironbar)
## Running
All of the above installation methods provide a binary called `ironbar`.
You can set the `IRONBAR_LOG` or `IRONBAR_FILE_LOG` environment variables to
`error`, `warn`, `info`, `debug` or `trace` to configure the log output level.
These default to `IRONBAR_LOG=info` and `IRONBAR_FILE_LOG=error`.
File output can be found at `~/.local/share/ironbar/error.log`.
## Configuration
Ironbar gives a lot of flexibility when configuring, including multiple file formats

View File

@ -32,9 +32,10 @@ impl<'a> MakeWriter<'a> for MakeFileWriter {
/// for the lifetime of the application for logging to file to work.
pub fn install_tracing() -> Result<WorkerGuard> {
let fmt_layer = fmt::layer().with_target(true);
let filter_layer = EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new("info"))?;
let filter_layer = EnvFilter::try_from_env("IRONBAR_LOG").or_else(|_| EnvFilter::try_new("info"))?;
let file_filter_layer =
EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new("warn"))?;
EnvFilter::try_from_env("IRONBAR_FILE_LOG").or_else(|_| EnvFilter::try_new("warn"))?;
let log_path = data_dir().unwrap_or(env::current_dir()?).join("ironbar");