mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 20:17:40 +00:00
Clean up logging on C++ side
This commit is contained in:
parent
bbda0cdffe
commit
c0d1bf63bc
@ -18,8 +18,6 @@ static int fmt_and_log_with_rs(LogLevel level, const char *fmt, va_list ap) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int (*cpp_logger)(LogLevel level, const char *fmt, va_list ap) = fmt_and_log_with_rs;
|
|
||||||
|
|
||||||
// Used to override external C library logging
|
// Used to override external C library logging
|
||||||
extern "C" int magisk_log_print(int prio, const char *tag, const char *fmt, ...) {
|
extern "C" int magisk_log_print(int prio, const char *tag, const char *fmt, ...) {
|
||||||
LogLevel level;
|
LogLevel level;
|
||||||
@ -52,17 +50,16 @@ extern "C" int magisk_log_print(int prio, const char *tag, const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
va_list argv;
|
va_list argv;
|
||||||
va_start(argv, fmt);
|
va_start(argv, fmt);
|
||||||
int ret = cpp_logger(level, fmt_buf, argv);
|
int ret = fmt_and_log_with_rs(level, fmt_buf, argv);
|
||||||
va_end(argv);
|
va_end(argv);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOG_BODY(level) { \
|
#define LOG_BODY(level) \
|
||||||
va_list argv; \
|
va_list argv; \
|
||||||
va_start(argv, fmt); \
|
va_start(argv, fmt); \
|
||||||
cpp_logger(LogLevel::level, fmt, argv); \
|
fmt_and_log_with_rs(LogLevel::level, fmt, argv); \
|
||||||
va_end(argv); \
|
va_end(argv); \
|
||||||
}
|
|
||||||
|
|
||||||
// LTO will optimize out the NOP function
|
// LTO will optimize out the NOP function
|
||||||
#if MAGISK_DEBUG
|
#if MAGISK_DEBUG
|
||||||
@ -76,5 +73,5 @@ void LOGE(const char *fmt, ...) { LOG_BODY(Error) }
|
|||||||
|
|
||||||
// Export raw symbol to fortify compat
|
// Export raw symbol to fortify compat
|
||||||
extern "C" void __vloge(const char* fmt, va_list ap) {
|
extern "C" void __vloge(const char* fmt, va_list ap) {
|
||||||
cpp_logger(LogLevel::Error, fmt, ap);
|
fmt_and_log_with_rs(LogLevel::Error, fmt, ap);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include <base-rs.hpp>
|
#include <base-rs.hpp>
|
||||||
|
|
||||||
extern int (*cpp_logger)(LogLevel level, const char *fmt, va_list ap);
|
|
||||||
|
|
||||||
void LOGD(const char *fmt, ...) __printflike(1, 2);
|
void LOGD(const char *fmt, ...) __printflike(1, 2);
|
||||||
void LOGI(const char *fmt, ...) __printflike(1, 2);
|
void LOGI(const char *fmt, ...) __printflike(1, 2);
|
||||||
void LOGW(const char *fmt, ...) __printflike(1, 2);
|
void LOGW(const char *fmt, ...) __printflike(1, 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user