Skip to content

Commit 282898a

Browse files
authored
Merge pull request #38 from kjvalencik/master
doc: Add docs for `Config::format`
2 parents af020ad + 21065ce commit 282898a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@
5050
//! // ..
5151
//! }
5252
//! ```
53+
//!
54+
//! ## Example with a custom log formatter
55+
//!
56+
//! ```
57+
//! use android_logger::Config;
58+
//!
59+
//! android_logger::init_once(
60+
//! Config::default()
61+
//! .with_min_level(log::Level::Trace)
62+
//! .format(|f, record| write!(f, "my_app: {}", record.args()))
63+
//! )
64+
//! ```
5365
5466
#[cfg(target_os = "android")]
5567
extern crate android_log_sys as log_ffi;
@@ -240,6 +252,15 @@ impl Config {
240252
self
241253
}
242254

255+
/// Sets the format function for formatting the log output.
256+
/// ```
257+
/// # use android_logger::Config;
258+
/// android_logger::init_once(
259+
/// Config::default()
260+
/// .with_min_level(log::Level::Trace)
261+
/// .format(|f, record| write!(f, "my_app: {}", record.args()))
262+
/// )
263+
/// ```
243264
pub fn format<F>(mut self, format: F) -> Self
244265
where
245266
F: Fn(&mut dyn fmt::Write, &Record) -> fmt::Result + Sync + Send + 'static,

0 commit comments

Comments
 (0)