Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit b05a879c authored by Eric Biggers's avatar Eric Biggers
Browse files

Fix Slogf to behave like Slog

Log, Slog, and Slogf without format arguments all log VERBOSE and above
by default.  In contrast, Slogf with format arguments only logs INFO and
above by default.  That's very surprising, and it's causing messages to
disappear from the log after "trivial" conversions to Slogf.

This is caused by Slogf assuming that Log.isLoggable() works in the
expected way.  Unfortunately, Log.isLoggable() has always been advisory
in Android, not enforced.  By default it only returns true for INFO and
above, but it's always been up to the users of the logging methods to
check it, if they want to.  system_server generally does not check it,
or only uses it for boolean knobs at the class level that selected log
messages are conditional on.  system_server also lots quite a bit at
DEBUG level; people would probably be unhappy if it started enforcing
Log.isLoggable() and all DEBUG messages disappeared from the logs.

The end result is that while making logging methods return early if
!Log.isLoggable() at first seems like a perfectly reasonable thing to
do, in the context of system_server it actually results in unexpected
behavior, so it shouldn't be done.  It's up to the callers to decide
what they want to log.

Bug: 182476140
Bug: 268526331
Test: atest FrameworksMockingServicesTests:SlogfTest
Change-Id: If8d2ffe5bda51add08e2c952871e0c646ebb2474
Merged-In: If8d2ffe5bda51add08e2c952871e0c646ebb2474
(cherry picked from commit 84fbdc97)
parent 8128beb1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment