| Crates.io | bin_common |
| lib.rs | bin_common |
| version | 0.2.0 |
| created_at | 2021-08-22 18:57:23.989673+00 |
| updated_at | 2021-08-22 18:57:23.989673+00 |
| description | A library for common things in binaries. |
| homepage | |
| repository | https://gitlab.com/999eagle/rust_bin_common |
| max_upload_size | |
| id | 440811 |
| size | 18,986 |
A library for common things in binaries. Mainly useful for a quick logging setup with support for logging to files, logging panics and log rotation.
This is an example for how to use this library.
let crate_setup = CrateSetupBuilder::new()
.with_app_name("my-cool-app") // set app name for paths
.build()
.unwrap();
crate_setup
.logging_setup()
.with_verbosity(1) // log only INFO and above messages
.with_log_to_file(true) // write all log messages to file and stdout
.with_log_panics(true) // log panics
.with_log_rotation(true) // rotate log files
.build()
.unwrap();
log::info("{} starting", crate_setup.application_name());
The CrateSetup stores the application name and resulting base directories according to the XDG directory spec and allows setting up logging.