Move Android logging out of libutils

This commit is contained in:
topjohnwu
2020-05-10 00:48:41 -07:00
parent 0f8f4e361b
commit 122b4d66b6
3 changed files with 27 additions and 49 deletions

View File

@@ -1,13 +1,11 @@
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include <libgen.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <android/log.h>
#include <magisk.hpp>
#include <utils.hpp>
@@ -112,6 +110,19 @@ static void *request_handler(void *args) {
return nullptr;
}
static void android_logging() {
static constexpr char TAG[] = "Magisk";
#ifdef MAGISK_DEBUG
log_cb.d = [](auto fmt, auto ap){ return __android_log_vprint(ANDROID_LOG_DEBUG, TAG, fmt, ap); };
#else
log_cb.d = nop_log;
#endif
log_cb.i = [](auto fmt, auto ap){ return __android_log_vprint(ANDROID_LOG_INFO, TAG, fmt, ap); };
log_cb.w = [](auto fmt, auto ap){ return __android_log_vprint(ANDROID_LOG_WARN, TAG, fmt, ap); };
log_cb.e = [](auto fmt, auto ap){ return __android_log_vprint(ANDROID_LOG_ERROR, TAG, fmt, ap); };
log_cb.ex = nop_ex;
}
static void daemon_entry(int ppid) {
android_logging();