git-igitt icon indicating copy to clipboard operation
git-igitt copied to clipboard

Add log4rs to print log messages to a file

Open KarlHeitmann opened this issue 2 years ago • 0 comments

I like this tui crate, and I've built some "explorer" applications with it (to git commit explorer (very similar to this project), a wrapper for ripgrep to explore files and an explorer for Ruby on Rails projects)

tui is an awesome crate, but for me sometimes is very difficult to get to know what is happening under the hood when my applications are not working as expected. That's why I decided to use a logger on my latest explorer project (rails_explorer), and found out that this log4rs is very useful.

I don't know what is your criteria to add other crates to your project. But this is a suggestion. If you have a better technique (eg: you use a debugger or a special IDE or another rust feature to build your project) let me know so I can study your code and start contributing. I need a good tool to use on my personal and work related github repos.

Commit message:

You can use this crate to send log messages to a file, there are 5 level filters for logging:

Error
Warn
Info
Debug
Trace

To use it, just add one of these lines to the code. You can use the format as println!()

log::error!("...");
log::warn!("...");
log::info!("...");
log::debug!("...");
log::trace!("...");

The example setup provided here is taken from
https://github.com/estk/log4rs/blob/master/examples/log_to_file.rs

KarlHeitmann avatar Jun 07 '23 04:06 KarlHeitmann