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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
use PathBuf;
use process;
use log4rs;
use Lazy;
use RwLock;
use Uuid;
use crateLogIdFormat;
/// Global target log name (default: "log4you")
pub static LOG_TARGET: = new;
/// A struct responsible for initializing and managing the logger for the application.
///
/// The `Logger` struct handles the configuration of the logging system, allowing you to
/// define log levels, log formats, and the log output destinations such as the console
/// and rolling file logs. It also ensures that logs are enriched with a unique `log_id`
/// and optional `service_name` for easier traceability across different parts of the application.
///
/// You can initialize the logger with a specific log identifier (`log_id`), path to a configuration
/// file (`config_path`), and the service name (`service_name`). The configuration is applied
/// through a YAML configuration file, which defines the log format and the output policy.
///
/// # Example Usage
///
/// ```rust
/// use log4you::{logger::Logger, log_id, log_info, log_info_with_id};
///
/// fn main() {
/// 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_id = log4you::log_id!();
/// log_info_with_id!(custom_id, "This log uses custom log_id");
/// }
/// ```
///
/// ## Methods
/// - `init`: Initializes the logger with the given `log_id`, `config_path`, and `service_name`.
///
/// ## Notes
/// - Make sure that the log configuration file exists at the specified path and is accessible.
/// - By default, the logger will write logs to the console (`stdout`) and to the log file if configured.
/// - The logger will automatically apply the log configuration defined in the YAML file.
///
/// ## Example YAML Configuration:
/// See the [`log4rs` configuration documentation](https://docs.rs/log4rs/latest/log4rs/#configuration)
/// for details on how to configure the loggers, appenders, and log levels.
;