Recent Bionic have a slew of async_safe_* logging functions that are
basically the liblog ones but included within the libc. They have the advantage
of not allocating memory. async_safe_write_log does no formatting and is
likely the best candidate for logging.
Use a weak definition to try and use it. Also, avoid API level checks (as
the toolchain is compiled at a rather low API level) for __android_log_write
in favor of a weak definition as well.
Keep the fallback to syslog if nothing else was found.
I tried to overhaul the code block to only have a single #if SANITIZER_ANDROID
but I am not particularly attached to the form. LMKWYT.
Please preserve the comment about syslog being broken pre-L. This is another reason why we prefer __android_log_write when both are available.
__android_log_write may not allocate memory, but it does call pthread_mutex_lock sometimes.