2017-09-14 13:54:56 +00:00
|
|
|
/* logging.h - Error handling and logging
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LOGGING_H_
|
|
|
|
#define _LOGGING_H_
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-11-05 21:41:03 +00:00
|
|
|
#define str(a) #a
|
|
|
|
#define xstr(a) str(a)
|
|
|
|
|
2017-12-01 09:38:57 +00:00
|
|
|
/**************
|
|
|
|
* No logging *
|
|
|
|
**************/
|
|
|
|
|
2017-12-06 17:30:48 +00:00
|
|
|
#define LOGD(...)
|
2017-12-01 09:38:57 +00:00
|
|
|
#define LOGI(...)
|
2017-12-06 17:30:48 +00:00
|
|
|
#define LOGW(...)
|
2017-12-01 09:38:57 +00:00
|
|
|
#define LOGE(...)
|
|
|
|
#define PLOGE(...)
|
|
|
|
|
|
|
|
/******************
|
|
|
|
* Daemon logging *
|
|
|
|
******************/
|
|
|
|
|
2017-09-14 13:54:56 +00:00
|
|
|
#ifdef IS_DAEMON
|
|
|
|
|
2017-12-01 09:38:57 +00:00
|
|
|
#undef LOGI
|
2017-12-06 17:30:48 +00:00
|
|
|
#undef LOGW
|
2017-12-01 09:38:57 +00:00
|
|
|
#undef LOGE
|
|
|
|
#undef PLOGE
|
|
|
|
|
2017-09-14 13:54:56 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
#define LOG_TAG "Magisk"
|
|
|
|
|
|
|
|
#ifdef MAGISK_DEBUG
|
2017-12-06 17:30:48 +00:00
|
|
|
#undef LOGD
|
2017-09-14 13:54:56 +00:00
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
|
|
|
|
#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 14:25:16 +00:00
|
|
|
#define PLOGE(fmt, args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
|
2017-09-14 13:54:56 +00:00
|
|
|
|
2017-10-08 21:05:52 +00:00
|
|
|
enum {
|
|
|
|
HIDE_EVENT,
|
|
|
|
LOG_EVENT,
|
|
|
|
DEBUG_EVENT
|
|
|
|
};
|
2017-12-18 10:17:37 +00:00
|
|
|
|
|
|
|
struct log_listener {
|
|
|
|
int fd;
|
|
|
|
int (*filter) (const char*);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct log_listener log_events[];
|
2017-10-08 21:05:52 +00:00
|
|
|
|
|
|
|
void monitor_logs();
|
|
|
|
void start_debug_full_log();
|
|
|
|
void stop_debug_full_log();
|
2017-10-10 11:49:15 +00:00
|
|
|
void start_debug_log();
|
2017-10-08 21:05:52 +00:00
|
|
|
|
2017-12-01 09:38:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/********************
|
|
|
|
* Tools Log & Exit *
|
|
|
|
********************/
|
|
|
|
|
|
|
|
#ifdef XWRAP_EXIT
|
|
|
|
|
|
|
|
#undef LOGE
|
|
|
|
#undef PLOGE
|
2017-09-14 13:54:56 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-09-14 15:11:56 +00:00
|
|
|
#define LOGE(...) { fprintf(stderr, __VA_ARGS__); exit(1); }
|
2017-09-14 13:54:56 +00:00
|
|
|
#define PLOGE(fmt, args...) { fprintf(stderr, fmt " failed with %d: %s\n\n", ##args, errno, strerror(errno)); exit(1); }
|
|
|
|
|
2017-12-01 09:38:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-14 13:54:56 +00:00
|
|
|
|
|
|
|
#endif // _LOGGING_H_
|