Skip to content

Commit 1b02dba

Browse files
author
Marcin Radomski
committed
Add android-api-30 feature
1 parent cdd266f commit 1b02dba

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ targets = [
2525
[features]
2626
default = ["regex"]
2727
regex = ["env_filter/regex"]
28+
android-api-30 = []
2829

2930
[dependencies.log]
3031
version = "0.4"

src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn android_log(
160160
fn android_log(_buf_id: Option<LogId>, _priority: Level, _tag: &CStr, _msg: &CStr) {}
161161

162162
/// Outputs log to Android system.
163-
#[cfg(target_os = "android")]
163+
#[cfg(all(target_os = "android", feature = "android-api-30"))]
164164
fn android_is_loggable_len(
165165
prio: log_ffi::LogPriority,
166166
tag: &str,
@@ -188,7 +188,7 @@ fn android_log_priority_from_level(level: Level) -> LogPriority {
188188
}
189189
}
190190

191-
#[cfg(target_os = "android")]
191+
#[cfg(all(target_os = "android", feature = "android-api-30"))]
192192
fn should_log(tag: &str, level: Level, logger_config: &Config) -> bool {
193193
let prio = android_log_priority_from_level(level);
194194
// Priority to use in case no system-wide or process-wide overrides are set.
@@ -203,6 +203,11 @@ fn should_log(tag: &str, level: Level, logger_config: &Config) -> bool {
203203
android_is_loggable_len(prio, tag, default_prio)
204204
}
205205

206+
#[cfg(all(target_os = "android", not(feature = "android-api-30")))]
207+
fn should_log(_tag: &str, level: Level, logger_config: &Config) -> bool {
208+
level <= logger_config.log_level.unwrap_or_else(log::max_level)
209+
}
210+
206211
/// Dummy placeholder for tests.
207212
#[cfg(not(target_os = "android"))]
208213
fn should_log(_tag: &str, level: Level, logger_config: &Config) -> bool {

0 commit comments

Comments
 (0)