Crates.io | ez_logging |
lib.rs | ez_logging |
version | 0.1.2 |
source | src |
created_at | 2024-10-15 20:26:10.128878 |
updated_at | 2024-10-16 01:12:00.409236 |
description | A simple, dirt-cheap logging system |
homepage | |
repository | |
max_upload_size | |
id | 1410193 |
size | 18,918 |
ez_logging
is a simple, easy-to-use logging library for Rust projects. It overrides the standard println!
macro to log messages to both the console and a file simultaneously, with automatic timestamping.
println!
to log messages to console and file simultaneouslyAdd this to your Cargo.toml
:
[dependencies]
ez_logging = { git = "https://github.com/yourusername/ez_logging.git" }
Or, if you're using it as a local dependency:
[dependencies]
ez_logging = { path = "../ez_logging" }
#[macro_use]
extern crate ez_logging;
fn main() {
ez_logging::init();
// Your code here
}
println!
as you normally would. It will now log to both console and file:println!("This is a log message");
println!("You can use {} too", "formatting");
server.log
in your project directory.#[macro_use]
extern crate ez_logging;
fn main() {
ez_logging::init();
println!("Starting application");
for i in 1..=5 {
println!("Processing item {}", i);
}
println!("Application finished");
}
Console and server.log
:
[2023-05-20 15:30:45] Logging system initialized
[2023-05-20 15:30:45] Starting application
[2023-05-20 15:30:45] Processing item 1
[2023-05-20 15:30:45] Processing item 2
[2023-05-20 15:30:45] Processing item 3
[2023-05-20 15:30:45] Processing item 4
[2023-05-20 15:30:45] Processing item 5
[2023-05-20 15:30:45] Application finished
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.