mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-18 21:19:31 +03:00
feat: Add support for logging to Android logcat
This commit is contained in:
parent
db3d8485d2
commit
26d7d45e0c
1 changed files with 12 additions and 1 deletions
|
@ -12,7 +12,9 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
#include <stdio.h> // stdin/stdout
|
#include <stdio.h> // stdin/stdout
|
||||||
#include <stdlib.h> // abort
|
#include <stdlib.h> // abort
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#include <android/log.h> // Output to android logcat
|
||||||
|
#endif
|
||||||
|
|
||||||
static long mi_max_error_count = 16; // stop outputting errors after this (use < 0 for no limit)
|
static long mi_max_error_count = 16; // stop outputting errors after this (use < 0 for no limit)
|
||||||
static long mi_max_warning_count = 16; // stop outputting warnings after this (use < 0 for no limit)
|
static long mi_max_warning_count = 16; // stop outputting warnings after this (use < 0 for no limit)
|
||||||
|
@ -395,6 +397,9 @@ void _mi_verbose_message(const char* fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args,fmt);
|
va_start(args,fmt);
|
||||||
mi_vfprintf(NULL, NULL, "mimalloc: ", fmt, args);
|
mi_vfprintf(NULL, NULL, "mimalloc: ", fmt, args);
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
__android_log_vprint(ANDROID_LOG_VERBOSE, "mimalloc", fmt, args);
|
||||||
|
#endif
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,6 +409,9 @@ static void mi_show_error_message(const char* fmt, va_list args) {
|
||||||
if (mi_max_error_count >= 0 && (long)mi_atomic_increment_acq_rel(&error_count) > mi_max_error_count) return;
|
if (mi_max_error_count >= 0 && (long)mi_atomic_increment_acq_rel(&error_count) > mi_max_error_count) return;
|
||||||
}
|
}
|
||||||
mi_vfprintf_thread(NULL, NULL, "mimalloc: error: ", fmt, args);
|
mi_vfprintf_thread(NULL, NULL, "mimalloc: error: ", fmt, args);
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
__android_log_vprint(ANDROID_LOG_ERROR, "mimalloc", fmt, args);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void _mi_warning_message(const char* fmt, ...) {
|
void _mi_warning_message(const char* fmt, ...) {
|
||||||
|
@ -414,6 +422,9 @@ void _mi_warning_message(const char* fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args,fmt);
|
va_start(args,fmt);
|
||||||
mi_vfprintf_thread(NULL, NULL, "mimalloc: warning: ", fmt, args);
|
mi_vfprintf_thread(NULL, NULL, "mimalloc: warning: ", fmt, args);
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
__android_log_vprint(ANDROID_LOG_WARN, "mimalloc", fmt, args);
|
||||||
|
#endif
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue