Ensure that logger function is always set

I700cbfbbfc45e3ae58606fc0c2a77f592f7d652a introduced a change that the
static variable `logger_function` is initialized at runtime (via the
static initializer) rather than at compile time. This actually was
unsafe because the static variable can be used "before" it is
initialized. For example, b/248162391 shows that it was used in the
context of the dynamic linker. The similar situation can happen if the
static variable is called from another static initializer (as C++
doesn't guarantee the order of static initializers).

This change fixes the issue by ensuring that `logger_function` (and
another static variable `file_logger`) is set before it is used.

Bug: 248162391
Test: Do the mixed build test as described in b/248162391#comment2
Change-Id: I1aa3606d6f3acbb3a9578ed502c960701c98ab7c
GitOrigin-RevId: d9bc3289bd2661cafbafcc28926a6a04a897213b
1 file changed
tree: 839710b9f69af7746b3bb2326b21254ea2d253d2
  1. liblog/