1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! # log4you
//!
//! > Structured logging for Rust with dynamic UUID log IDs, built on [log4rs](https://docs.rs/log4rs).
//!
//!
//! **log4you** is a lightweight logging crate, designed for applications that need consistent, structured logging with unique log identifiers (UUIDs). It allows simple, efficient, and consistent logging with unique log IDs for each request.
//!
//! ---
//!
//! ## โจ Features
//!
//! - ๐ง Powered by `log4rs`, configure logging dynamically with YAML configuration files, compatible with the standard Rust `log` facade
//! - โ
Structured logging with automatic **UUID log IDs**
//! - ๐ Generates a unique `log_id` (UUID v7) per log entry using Uuid::now_v7().simple() via `log_id!` macro
//! - ๐ช Easy-to-use macros: `log_info!`, `log_error!`, etc.
//! - ๐ ๏ธ Supports dynamic config paths, log rotation, and file size management
//! - ๐ Easy setup and integration โ works out of the box
//! - ๐งต Great for async or multithreaded apps
//!
//! Perfect for microservices, APIs, and any system where traceability and clean logs matter.
//!
//! ---
//!
//! ## โ๏ธ Example YAML Configuration
//!
//! See the [`log4rs` configuration documentation](https://docs.rs/log4rs/latest/log4rs/#configuration) for more details.
//!
//! ```yaml
//! appenders:
//! stdout:
//! kind: console
//! encoder:
//! pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l})} {f}:{L}] - {m}{n}"
//!
//! log4you:
//! kind: rolling_file
//! path: "logs/log4you.log"
//! policy:
//! kind: compound
//! trigger:
//! kind: size
//! limit: 100MB
//! roller:
//! kind: fixed_window
//! pattern: "logs/log4you-{}.log"
//! count: 5
//! encoder:
//! pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l})} {f}:{L}] - {m}{n}"
//!
//! root:
//! level: info
//! appenders:
//! - stdout
//!
//! loggers:
//! log4you:
//! level: debug
//! appenders:
//! - log4you
//! ```
//!
//! ---
//!
//! ## ๐ ๏ธ Usage Example
//!
//! ```rust
//! use log4you::{logger::Logger, log_id, log_info, log_info_with_id};
//!
//! let logid = log_id!();
//! // Initialize the logger with a log_id, a path to the YAML config, and the service name
//! Logger::init(&logid, Some("config/log4you.yaml"), Some("log4you"));
//!
//! // Log an info message, logid will be generated automatically
//! log_info!("Service started");
//!
//! // Log an info message, logid is defined by yourself
//! let custom_log_id = log_id!();
//! log_info_with_id!(custom_log_id, "This log uses custom log_id");
//! ```
//!
//! ---
//!
//! ## ๐ License
//!
//! Licensed under:
//! - Apache License, Version 2.0 [LICENSE](http://www.apache.org/licenses/LICENSE-2.0.txt)
//!
//! ---
//!
//! ## ๐งโ๐ป Author
//!
//! Created and maintained by [Jerry Maheswara](https://github.com/jerry-maheswara-github)
//!
//! Feel free to reach out for suggestions, issues, or improvements!
//!
//! ---
//!
//! ## โค๏ธ Built with Love in Rust
//!
//! This project is built with โค๏ธ using **Rust** โ a systems programming language that is safe, fast, and concurrent. Rust is the perfect choice for building reliable and efficient applications.
//!
//! ---
//!
//! ## ๐ Contributing
//!
//! Pull requests, issues, and feedback are welcome!
//! If you find this crate useful, give it a โญ and share it with others in the Rust community.
//!
//! ---
pub use log as __log_crate;
pub use uuid as __uuid_crate;