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
Loading
Please register or sign in to comment