2017-09-14 15:54:56 +02:00
|
|
|
/* logging.h - Error handling and logging
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LOGGING_H_
|
|
|
|
#define _LOGGING_H_
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef IS_DAEMON
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#define LOG_TAG "Magisk"
|
|
|
|
|
|
|
|
#ifdef MAGISK_DEBUG
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
|
|
|
#else
|
2017-09-26 22:06:44 +02:00
|
|
|
#define LOGD(...) {}
|
2017-09-14 15:54:56 +02:00
|
|
|
#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__)
|
|
|
|
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
|
|
|
|
2017-10-13 16:25:16 +02:00
|
|
|
#define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
|
2017-09-14 15:54:56 +02:00
|
|
|
|
2017-10-08 23:05:52 +02:00
|
|
|
enum {
|
|
|
|
HIDE_EVENT,
|
|
|
|
LOG_EVENT,
|
|
|
|
DEBUG_EVENT
|
|
|
|
};
|
|
|
|
extern int logcat_events[];
|
|
|
|
|
|
|
|
void monitor_logs();
|
|
|
|
void start_debug_full_log();
|
|
|
|
void stop_debug_full_log();
|
2017-10-10 13:49:15 +02:00
|
|
|
void start_debug_log();
|
2017-10-08 23:05:52 +02:00
|
|
|
|
2017-09-14 15:54:56 +02:00
|
|
|
#else // IS_DAEMON
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-09-14 17:11:56 +02:00
|
|
|
#define LOGE(...) { fprintf(stderr, __VA_ARGS__); exit(1); }
|
2017-09-14 15:54:56 +02:00
|
|
|
#define PLOGE(fmt, args...) { fprintf(stderr, fmt " failed with %d: %s\n\n", ##args, errno, strerror(errno)); exit(1); }
|
|
|
|
|
|
|
|
#endif // IS_DAEMON
|
|
|
|
|
|
|
|
#endif // _LOGGING_H_
|