| Crates.io | file_log |
| lib.rs | file_log |
| version | 0.1.1 |
| created_at | 2024-02-06 20:00:11.574607+00 |
| updated_at | 2024-02-06 20:01:23.643153+00 |
| description | A library to write logs to files with an index. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1129417 |
| size | 7,491 |
The file_log module provides functionality for logging messages to files. Using different indexes for each run of your code.
The idea of this crate is to maintain all previous logs without needing to change the code.
This crate creates a file called log_index to maintain the last index created. Unless the environment variable FILE_LOG_INDEX is found.
Add the following to your Cargo.toml file:
[dependencies]
file_log = "0.1.0"
use file_log::{log, index};
fn main() {
log!("log", "Hello"); // this will append "hello" to log_<index>.log
log!("log" "xyz", "{} {} {}", index(), index(), index()); // this will append "<index> <index> <index>" to log_<index>.xyz
}
By running:
$ cargo run
You create the log_index file that mantains the last index used, and every log file used in the log! macro.
Or, using:
$ FILE_LOG_INDEX=10 cargo run
The log_index file will not be created, and the index in the file_log::index() function, will be 10.
See the brief example at Example
This project is licensed under the MIT License.