Skip to content

Commit c885937

Browse files
Dragon-GCSestk
authored andcommitted
docs: Revise the document based on the review comments
1 parent 1abde55 commit c885937

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@
174174
//! # fn main() {}
175175
//! ```
176176
//!
177-
//! ## Custom with log4rs
177+
//! ## Custom implementations of logging components
178178
//!
179179
//! You can impl some trait for your struct and use it with log4rs. For example:
180180
//! - Impl [log4rs::append::Append](append/trait.Append.html) for your custom appender.
181181
//! - Impl [log4rs::encode::Encode](encode/trait.Encode.html) for your custom encoder.
182182
//! - Impl [log4rs::filter::Filter](filter/trait.Filter.html) for your custom filter.
183183
//!
184-
//! Here is a very sample example to create a custom appender,
184+
//! Here is a very simple example to create a custom appender,
185185
//! for more examples about custom, see [examples/custom.rs](https://github.com/estk/log4rs/tree/main/examples/custom.rs):
186186
//! ```no_run
187187
//! # fn f() {
@@ -194,7 +194,7 @@
194194
//! // impl your process record logic here
195195
//! impl Append for MyAppender {
196196
//! fn append(&self, record: &log::Record) -> anyhow::Result<()> {
197-
//! println!("{record:?}");
197+
//! println!("appender({}): {record:?}", self.0);
198198
//! Ok(())
199199
//! }
200200
//! fn flush(&self) {}
@@ -219,15 +219,16 @@
219219
//! # fn main() {}
220220
//! ```
221221
//!
222-
//! To config with file, you should implement [log4rs::config::Deserialize](config/trait.Deserialize.html) for your config and **register it in default Deserializers**.
222+
//! To configure log4rs with a file, you should implement [log4rs::config::Deserialize](config/trait.Deserialize.html) for your config and be sure to register it with [log4rs::config::Deserializers](config/struct.Deserializers.html) as shown in the example below.
223223
//!
224-
//! Here is a very simple example to use custom appender with custom config,
225-
//! for more examples about custom config file, see [examples/custom_config.rs](https://github.com/estk/log4rs/tree/main/examples/custom_config.rs):
224+
//! Here is a very simple example to use a custom appender with custom config.
225+
//! For more examples about custom config file, see [examples/custom_config.rs](https://github.com/estk/log4rs/tree/main/examples/custom_config.rs):
226226
//! ```yaml
227227
//! # custom_config.yml
228228
//! appenders:
229229
//! my_appender:
230230
//! kind: custom_appender
231+
//! appender_data: 42
231232
//!
232233
//! root:
233234
//! level: INFO
@@ -239,15 +240,15 @@
239240
//! # #[cfg(feature = "config_parsing")]
240241
//! # fn f() {
241242
//! use log4rs::append::Append;
242-
//! use log4rs::config::{Appender, Deserialize, Deserializers, Root};
243+
//! use log4rs::config::{Deserialize, Deserializers};
243244
//!
244245
//! #[derive(Debug)]
245246
//! struct MyAppender(usize);
246247
//!
247248
//! // impl your process record logic here
248249
//! impl Append for MyAppender {
249250
//! fn append(&self, record: &log::Record) -> anyhow::Result<()> {
250-
//! println!("{record:?}");
251+
//! println!("appender({}): {record:?}", self.0);
251252
//! Ok(())
252253
//! }
253254
//! fn flush(&self) {}
@@ -272,7 +273,7 @@
272273
//! config: MyAppenderConfig,
273274
//! _: &Deserializers,
274275
//! ) -> anyhow::Result<Box<Self::Trait>> {
275-
//! let appender_data = config.appender_data.unwrap_or(10000);
276+
//! let appender_data = config.appender_data.unwrap_or(0);
276277
//! let appender = MyAppender(appender_data);
277278
//! Ok(Box::new(appender))
278279
//! }

0 commit comments

Comments
 (0)