mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-11 19:53:37 +00:00
Improve logging
This commit is contained in:
parent
9cb1cf756f
commit
6ce37b44db
@ -315,7 +315,7 @@ static void clone_skeleton(struct node_entry *node) {
|
|||||||
// Copy symlinks directly
|
// Copy symlinks directly
|
||||||
cp_afc(buf2, buf);
|
cp_afc(buf2, buf);
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGD("cplink: %s -> %s\n",buf2, buf);
|
LOGI("cplink: %s -> %s\n",buf2, buf);
|
||||||
#else
|
#else
|
||||||
LOGI("cplink: %s\n", buf);
|
LOGI("cplink: %s\n", buf);
|
||||||
#endif
|
#endif
|
||||||
@ -414,7 +414,7 @@ static void mount_mirrors() {
|
|||||||
xmkdir_p(MIRRDIR "/system", 0755);
|
xmkdir_p(MIRRDIR "/system", 0755);
|
||||||
xmount(buf, MIRRDIR "/system", "ext4", MS_RDONLY, NULL);
|
xmount(buf, MIRRDIR "/system", "ext4", MS_RDONLY, NULL);
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGD("mount: %s -> %s\n", buf, MIRRDIR "/system");
|
LOGI("mount: %s -> %s\n", buf, MIRRDIR "/system");
|
||||||
#else
|
#else
|
||||||
LOGI("mount: %s\n", MIRRDIR "/system");
|
LOGI("mount: %s\n", MIRRDIR "/system");
|
||||||
#endif
|
#endif
|
||||||
@ -426,7 +426,7 @@ static void mount_mirrors() {
|
|||||||
xmkdir_p(MIRRDIR "/vendor", 0755);
|
xmkdir_p(MIRRDIR "/vendor", 0755);
|
||||||
xmount(buf, MIRRDIR "/vendor", "ext4", MS_RDONLY, NULL);
|
xmount(buf, MIRRDIR "/vendor", "ext4", MS_RDONLY, NULL);
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGD("mount: %s -> %s\n", buf, MIRRDIR "/vendor");
|
LOGI("mount: %s -> %s\n", buf, MIRRDIR "/vendor");
|
||||||
#else
|
#else
|
||||||
LOGI("mount: %s\n", MIRRDIR "/vendor");
|
LOGI("mount: %s\n", MIRRDIR "/vendor");
|
||||||
#endif
|
#endif
|
||||||
@ -437,7 +437,7 @@ static void mount_mirrors() {
|
|||||||
if (!seperate_vendor) {
|
if (!seperate_vendor) {
|
||||||
symlink(MIRRDIR "/system/vendor", MIRRDIR "/vendor");
|
symlink(MIRRDIR "/system/vendor", MIRRDIR "/vendor");
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGD("link: %s -> %s\n", MIRRDIR "/system/vendor", MIRRDIR "/vendor");
|
LOGI("link: %s -> %s\n", MIRRDIR "/system/vendor", MIRRDIR "/vendor");
|
||||||
#else
|
#else
|
||||||
LOGI("link: %s\n", MIRRDIR "/vendor");
|
LOGI("link: %s\n", MIRRDIR "/vendor");
|
||||||
#endif
|
#endif
|
||||||
@ -563,10 +563,10 @@ void post_fs_data(int client) {
|
|||||||
monitor_logs();
|
monitor_logs();
|
||||||
|
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
// Start debug logs in new process
|
// Log everything initially
|
||||||
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
|
debug_log_fd = xopen(DEBUG_LOG, O_WRONLY | O_CREAT | O_CLOEXEC | O_TRUNC, 0644);
|
||||||
debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "brief", NULL);
|
xwrite(debug_log_fd, "Boot logs:\n", 11);
|
||||||
close(debug_log_fd);
|
debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "thread", NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOGI("** post-fs-data mode running\n");
|
LOGI("** post-fs-data mode running\n");
|
||||||
@ -769,5 +769,8 @@ core_only:
|
|||||||
// Stop recording the boot logcat after every boot task is done
|
// Stop recording the boot logcat after every boot task is done
|
||||||
kill(debug_log_pid, SIGTERM);
|
kill(debug_log_pid, SIGTERM);
|
||||||
waitpid(debug_log_pid, NULL, 0);
|
waitpid(debug_log_pid, NULL, 0);
|
||||||
|
// Then start to log Magisk verbosely
|
||||||
|
xwrite(debug_log_fd, "\nVerbose logs:\n", 15);
|
||||||
|
debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "thread", "-s", "Magisk", NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ static void *logger_thread(void *args) {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Start logcat
|
// Start logcat
|
||||||
log_pid = exec_command(0, &log_fd, NULL, "logcat", "-s", "Magisk", "-v", "thread", NULL);
|
log_pid = exec_command(0, &log_fd, NULL, "logcat", "-v", "thread", "Magisk:I", "*:S", NULL);
|
||||||
if (log_pid > 0)
|
if (log_pid > 0)
|
||||||
waitpid(log_pid, NULL, 0);
|
waitpid(log_pid, NULL, 0);
|
||||||
// For some reason it went here, clear buffer and restart
|
// For some reason it went here, clear buffer and restart
|
||||||
|
@ -23,13 +23,10 @@ static inline void exit_proc() { exit(1); }
|
|||||||
static inline void exit_thread() { pthread_exit(NULL); }
|
static inline void exit_thread() { pthread_exit(NULL); }
|
||||||
static inline void do_nothing() {}
|
static inline void do_nothing() {}
|
||||||
|
|
||||||
// Dummy function to depress debug message
|
|
||||||
static inline void stub(const char *fmt, ...) {}
|
|
||||||
|
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define LOGD(...) stub(__VA_ARGS__)
|
#define LOGD(...) {}
|
||||||
#endif
|
#endif
|
||||||
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
||||||
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
|
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
|
||||||
|
@ -312,7 +312,7 @@ int mkdir_p(const char *pathname, mode_t mode) {
|
|||||||
int bind_mount(const char *from, const char *to) {
|
int bind_mount(const char *from, const char *to) {
|
||||||
int ret = xmount(from, to, NULL, MS_BIND, NULL);
|
int ret = xmount(from, to, NULL, MS_BIND, NULL);
|
||||||
#ifdef MAGISK_DEBUG
|
#ifdef MAGISK_DEBUG
|
||||||
LOGD("bind_mount: %s -> %s\n", from, to);
|
LOGI("bind_mount: %s -> %s\n", from, to);
|
||||||
#else
|
#else
|
||||||
LOGI("bind_mount: %s\n", to);
|
LOGI("bind_mount: %s\n", to);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user