| Crates.io | logcat |
| lib.rs | logcat |
| version | 0.0.1 |
| created_at | 2024-12-03 13:01:18.034201+00 |
| updated_at | 2024-12-03 13:01:18.034201+00 |
| description | A simple and lightweight logging library. |
| homepage | https://github.com/tspstudio/logcat |
| repository | https://github.com/tspstudio/logcat |
| max_upload_size | |
| id | 1469968 |
| size | 6,487 |
Logcat is simple logging library written in Rust
use logcat::logger::Logger;
fn main() {
// Creating logging class
let mut logger = Logger::new(String::from("output/log/filename.txt"));
// Logging
logger.info(String::from("This is info!"));
logger.warning(String::from("This is warning!"));
logger.error(String::from("This is error!"));
logger.custom(String::from("CUSTOM"), String::from("This is custom log!"));
logger.export(); // Will export all logs with timestamp.
logger.critical(String::from("This is critical error! Program will export logs and exit with code -1!"));
}
Output:
[INFO] 14:42:29 >> This is info!
[WARNING] 14:42:29 >> This is warning!
[ERROR] 14:42:29 >> This is error!
[CUSTOM] 14:42:29 >> This is custom log!
[INFO] 14:42:29 >> Log exported successfully!
[CRITICAL ERROR] 14:42:29 >> This is critical error! Program will exit with code -1!
[INFO] 14:42:29 >> Log exported successfully!
Log file:
# Log generated by Logcat v0.0.1
# Exported at 14:42:29
[INFO] 14:42:29 >> This is info!
[WARNING] 14:42:29 >> This is warning!
[ERROR] 14:42:29 >> This is error!
[CUSTOM] 14:42:29 >> This is custom log!
[INFO] 14:42:29 >> Log exported successfully!
[CRITICAL ERROR] 14:42:29 >> This is critical error! Program will exit with code -1!