mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-16 09:52:31 +00:00
Better logging system
Use C++ magic to strip out debug logs at compile time
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include <selinux.hpp>
|
||||
#include <db.hpp>
|
||||
#include <resetprop.hpp>
|
||||
#include <flags.h>
|
||||
#include <flags.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -129,16 +129,14 @@ shortcut:
|
||||
close(client);
|
||||
}
|
||||
|
||||
#define vlog __android_log_vprint
|
||||
|
||||
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.d = [](auto fmt, auto ap){ return vlog(ANDROID_LOG_DEBUG, TAG, fmt, ap); };
|
||||
log_cb.i = [](auto fmt, auto ap){ return vlog(ANDROID_LOG_INFO, TAG, fmt, ap); };
|
||||
log_cb.w = [](auto fmt, auto ap){ return vlog(ANDROID_LOG_WARN, TAG, fmt, ap); };
|
||||
log_cb.e = [](auto fmt, auto ap){ return vlog(ANDROID_LOG_ERROR, TAG, fmt, ap); };
|
||||
log_cb.ex = nop_ex;
|
||||
}
|
||||
|
||||
|
@@ -1,21 +1,17 @@
|
||||
#include <sys/mount.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <utils.hpp>
|
||||
#include <magisk.hpp>
|
||||
#include <daemon.hpp>
|
||||
#include <selinux.hpp>
|
||||
#include <flags.h>
|
||||
#include <flags.hpp>
|
||||
|
||||
using namespace std::literals;
|
||||
using namespace std;
|
||||
|
||||
[[noreturn]] static void usage() {
|
||||
fprintf(stderr,
|
||||
NAME_WITH_VER(Magisk) R"EOF( multi-call binary
|
||||
R"EOF(Magisk - Multi-purpose Utility
|
||||
|
||||
Usage: magisk [applet [arguments]...]
|
||||
or: magisk [options]...
|
||||
|
@@ -7,15 +7,10 @@
|
||||
#include <selinux.hpp>
|
||||
#include <daemon.hpp>
|
||||
#include <resetprop.hpp>
|
||||
#include <flags.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef MAGISK_DEBUG
|
||||
#define VLOGI(tag, from, to) LOGI("%-8s: %s <- %s\n", tag, to, from)
|
||||
#else
|
||||
#define VLOGI(tag, from, to) LOGI("%-8s: %s\n", tag, to)
|
||||
#endif
|
||||
|
||||
#define TYPE_MIRROR (1 << 0) /* mount from mirror */
|
||||
#define TYPE_INTER (1 << 1) /* intermediate node */
|
||||
|
Reference in New Issue
Block a user