sigchain: use libasync_safe logging.

__android_log_write doesn't have async safe guarantees. Use
libasync_safe, which has the added benefit of setting the abort message
for fatal errors.

Bug: http://b/67632085
Test: treehugger
Change-Id: I4d710753fddbce43fca44485443c446ed745ec30
diff --git a/sigchainlib/sigchain.cc b/sigchainlib/sigchain.cc
index 3127c5c..2e5f46c 100644
--- a/sigchainlib/sigchain.cc
+++ b/sigchainlib/sigchain.cc
@@ -14,13 +14,6 @@
  * limitations under the License.
  */
 
-#ifdef ART_TARGET_ANDROID
-#include <android/log.h>
-#else
-#include <stdarg.h>
-#include <iostream>
-#endif
-
 #include <dlfcn.h>
 #include <errno.h>
 #include <pthread.h>
@@ -35,6 +28,7 @@
 #include <type_traits>
 #include <utility>
 
+#include "log.h"
 #include "sigchain.h"
 
 #if defined(__APPLE__)
@@ -65,21 +59,6 @@
 //               doesn't have SA_RESTART, and raise the signal to avoid restarting syscalls that are
 //               expected to be interrupted?
 
-static void log(const char* format, ...) {
-  char buf[256];
-  va_list ap;
-  va_start(ap, format);
-  vsnprintf(buf, sizeof(buf), format, ap);
-#ifdef ART_TARGET_ANDROID
-  __android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
-#else
-  std::cout << buf << "\n";
-#endif
-  va_end(ap);
-}
-
-#define fatal(...) log(__VA_ARGS__); abort()
-
 #if defined(__BIONIC__) && !defined(__LP64__) && !defined(__mips__)
 static int sigismember(const sigset64_t* sigset, int signum) {
   return sigismember64(sigset, signum);