@@ -65,6 +65,48 @@ Therefore this library will only log a warning for subsequent `init_once` calls.
6565This library ensures that logged messages do not overflow Android log message limits
6666by efficiently splitting messages into chunks.
6767
68+ ## Consistent log filtering in mixed Rust/C/C++ apps
69+
70+ Android's C logging API determines the effective log level based on [ a
71+ combination] ( https://cs.android.com/android/platform/superproject/main/+/main:system/logging/liblog/properties.cpp;l=243;drc=b74a506c1b69f5b295a8cdfd7e2da3b16db15934 ) ,
72+ of a process-wide global variable, [ system-wide
73+ properties] ( https://cs.android.com/android/platform/superproject/main/+/main:system/logging/logd/README.property;l=45;drc=99c545d3098018a544cb292e1501daca694bee0f ) ,
74+ and call-specific default. ` log ` + ` android_logger ` crates add another layer of
75+ log filtering on top of that, independent from the C API.
76+
77+ ```
78+ .-----.
79+ | app |
80+ '-----' Rust
81+ C/C++ | '--------------.
82+ | v
83+ | .-----------. filter by log::STATIC_MAX_LEVEL +
84+ | | log crate | - log::MAX_LOG_LEVEL_FILTER,
85+ | '-----------' overrideable via log::set_max_level
86+ | |
87+ | v
88+ | .----------------------.
89+ | | android_logger crate | - filter by Config::max_level
90+ | '----------------------'
91+ | |
92+ | .------------'
93+ v v
94+ .--------.
95+ | liblog | - filter by global state or system-wide properties
96+ '--------'
97+ ```
98+
99+ ` liblog ` APIs introduced in Android API 30 let ` android_logger ` delegate log
100+ filtering decision to ` liblog ` , making the log level consistent across C, C++
101+ and Rust calls.
102+
103+ If you build ` android_logger ` with ` android-api-30 ` feature enabled, the logger
104+ will consider the process-wide global state (set via
105+ [ ` __android_log_set_minimum_priority ` ] ( https://cs.android.com/android/platform/superproject/main/+/main:prebuilts/runtime/mainline/runtime/sdk/common_os/include/system/logging/liblog/include/android/log.h;l=364;drc=4cf460634134d51dba174f8af60dffb10f703f51 )
106+ and Android system properties when deciding if a message should be logged or
107+ not. In this case, the effective log level is the _ least verbose_ of the levels
108+ set between those and Rust log facilities.
109+
68110## License
69111
70112Licensed under either of
0 commit comments