Improve logging

This commit is contained in:
topjohnwu 2017-09-27 04:06:44 +08:00
parent 9cb1cf756f
commit 6ce37b44db
4 changed files with 13 additions and 13 deletions

View File

@ -315,7 +315,7 @@ static void clone_skeleton(struct node_entry *node) {
// Copy symlinks directly
cp_afc(buf2, buf);
#ifdef MAGISK_DEBUG
LOGD("cplink: %s -> %s\n",buf2, buf);
LOGI("cplink: %s -> %s\n",buf2, buf);
#else
LOGI("cplink: %s\n", buf);
#endif
@ -414,7 +414,7 @@ static void mount_mirrors() {
xmkdir_p(MIRRDIR "/system", 0755);
xmount(buf, MIRRDIR "/system", "ext4", MS_RDONLY, NULL);
#ifdef MAGISK_DEBUG
LOGD("mount: %s -> %s\n", buf, MIRRDIR "/system");
LOGI("mount: %s -> %s\n", buf, MIRRDIR "/system");
#else
LOGI("mount: %s\n", MIRRDIR "/system");
#endif
@ -426,7 +426,7 @@ static void mount_mirrors() {
xmkdir_p(MIRRDIR "/vendor", 0755);
xmount(buf, MIRRDIR "/vendor", "ext4", MS_RDONLY, NULL);
#ifdef MAGISK_DEBUG
LOGD("mount: %s -> %s\n", buf, MIRRDIR "/vendor");
LOGI("mount: %s -> %s\n", buf, MIRRDIR "/vendor");
#else
LOGI("mount: %s\n", MIRRDIR "/vendor");
#endif
@ -437,7 +437,7 @@ static void mount_mirrors() {
if (!seperate_vendor) {
symlink(MIRRDIR "/system/vendor", MIRRDIR "/vendor");
#ifdef MAGISK_DEBUG
LOGD("link: %s -> %s\n", MIRRDIR "/system/vendor", MIRRDIR "/vendor");
LOGI("link: %s -> %s\n", MIRRDIR "/system/vendor", MIRRDIR "/vendor");
#else
LOGI("link: %s\n", MIRRDIR "/vendor");
#endif
@ -563,10 +563,10 @@ void post_fs_data(int client) {
monitor_logs();
#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_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "brief", NULL);
close(debug_log_fd);
xwrite(debug_log_fd, "Boot logs:\n", 11);
debug_log_pid = exec_command(0, &debug_log_fd, NULL, "logcat", "-v", "thread", NULL);
#endif
LOGI("** post-fs-data mode running\n");
@ -769,5 +769,8 @@ core_only:
// Stop recording the boot logcat after every boot task is done
kill(debug_log_pid, SIGTERM);
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
}

View File

@ -26,7 +26,7 @@ static void *logger_thread(void *args) {
while (1) {
// 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)
waitpid(log_pid, NULL, 0);
// For some reason it went here, clear buffer and restart

View File

@ -23,13 +23,10 @@ static inline void exit_proc() { exit(1); }
static inline void exit_thread() { pthread_exit(NULL); }
static inline void do_nothing() {}
// Dummy function to depress debug message
static inline void stub(const char *fmt, ...) {}
#ifdef MAGISK_DEBUG
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#else
#define LOGD(...) stub(__VA_ARGS__)
#define LOGD(...) {}
#endif
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)

View File

@ -312,7 +312,7 @@ int mkdir_p(const char *pathname, mode_t mode) {
int bind_mount(const char *from, const char *to) {
int ret = xmount(from, to, NULL, MS_BIND, NULL);
#ifdef MAGISK_DEBUG
LOGD("bind_mount: %s -> %s\n", from, to);
LOGI("bind_mount: %s -> %s\n", from, to);
#else
LOGI("bind_mount: %s\n", to);
#endif