ro.log.file_logger.path works even via libbase
Previously, even if ro.log.file_logger.path is set, logs written via
libbase APIs were not written to the file. This was because the sysprop
was ignored if a custom logger is set and libbase registers a custom
logger (LogdLogger).
This behavior was very confusing because it meant that depending on
which logging API you use, you get different results; `ALOGI("msg");`
goes to the file, whereas `LOG(INFO) << "msg";` goes to logd, or
silently ignored in a logd-less environment like Microdroid.
This change fixes the issue as follows:
* The sysprop doesn't change the global logger function. This was the
original behavior before the introduction of the sysprop.
* Instead, `__android_log_logd_logger` checks if the sysprop is set, and
if so writes the log to the file. If the sysprop is not set, the log
goes to logd as before.
* The check for sysprop and file descriptor for the file are cached as
before.
Bug: 270566364
Test: vm/vm_shell.sh start-microdroid -- --protected --console \
/data/local/tmp/console.txt --log /data/local/tmp/log.txt
Check that all logs (except for those from init and kernel) are in
log.txt.
Change-Id: I06ea1a6ee3732eb9eafe7794b9dfdcc34f5c1f83
1 file changed