Skip to content

Commit fb9b681

Browse files
authored
Merge pull request #55 from snowp/priority-construction
allow creating a PlatformLogWriter directly from a priority
2 parents 3467ae0 + ec1262e commit fb9b681

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,28 @@ pub struct PlatformLogWriter<'a> {
267267

268268
impl<'a> PlatformLogWriter<'a> {
269269
#[cfg(target_os = "android")]
270-
pub fn new(level: Level, tag: &CStr) -> PlatformLogWriter {
270+
pub fn new_with_priority(priority: log_ffi::LogPriority, tag: &CStr) -> PlatformLogWriter {
271271
#[allow(deprecated)] // created an issue #35 for this
272272
PlatformLogWriter {
273-
priority: match level {
274-
Level::Warn => LogPriority::WARN,
275-
Level::Info => LogPriority::INFO,
276-
Level::Debug => LogPriority::DEBUG,
277-
Level::Error => LogPriority::ERROR,
278-
Level::Trace => LogPriority::VERBOSE,
279-
},
273+
priority,
280274
len: 0,
281275
last_newline_index: 0,
282276
tag,
283277
buffer: uninit_array(),
284278
}
285279
}
286280

281+
#[cfg(target_os = "android")]
282+
pub fn new(level: Level, tag: &CStr) -> PlatformLogWriter {
283+
Self::new_with_priority(match level {
284+
Level::Warn => LogPriority::WARN,
285+
Level::Info => LogPriority::INFO,
286+
Level::Debug => LogPriority::DEBUG,
287+
Level::Error => LogPriority::ERROR,
288+
Level::Trace => LogPriority::VERBOSE,
289+
})
290+
}
291+
287292
#[cfg(not(target_os = "android"))]
288293
pub fn new(level: Level, tag: &CStr) -> PlatformLogWriter {
289294
#[allow(deprecated)] // created an issue #35 for this

0 commit comments

Comments
 (0)