Remove max_level
in favour of extracting it from the Filter
#94
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #80
Documentation for
log
specifies that all implementations must have a way to initializelog::set_max_level()
(because it otherwise defaults toOff
), in our case via thewith_max_level()
builder - and by callinginit_once()
. Over timeandroid_logger
receivedenv_filter
support for much more fine-grained control over filtering, makingandroid_logger
similar toenv_logger
in its implementation.With this change however, ambiguity arises when independently configuring log levels through
.with_max_level()
andenv_filter::Filter
. The former acts as an early performance save directly inlog::log!()
macros while the latter applies additional filtering insideandroid_logger
. In short:log::max_level()
must be at least as high as whatFilter
can process, otherwise messages get lost before they reach theFilter
.env_logger
solved this ambiguity by hiding direct access tolog::set_max_level()
as an implementation detail and initializing it to the highest level that could possibly be processed by theFilter
. Mimick this insideandroid_logger
by removing thewith_max_level()
setter. In addition all internalis_enabled()
filtering and related tests are removed because we rely on thelog
macros themselves to filter, and no longer trackmax_level
inside. Keeping in mind that any user can techincally changelog::set_max_level()
to increase or decrease global verbosity.The only complexity remains around
__android_log_is_loggable_len()
on Android 30 and above (if enabled on the crate by the user - not necessarily based on the actual minimum nor target SDK level yet!) which asks the Android system forenv_filter
-like per-module (tag) level overrides.TODO
env_filter
non-Option
al?Builder
-constructors likefilter_level()
andfilter_module()
, just likeenv_logger
.env_logger
/env_filter
's environment variables? These are less common to be set for Android apps.Error
makes sense here.AndroidLogger
level.README
in these tests, either:#![doc = include_str!("README.md")]
;