Use SDL logging functions in ERROR/WARNING/NOTICE

They choose appropriate destination depending on the platform.
This commit is contained in:
kichikuou
2021-01-09 11:07:41 +09:00
parent 00df3274ac
commit 7f1d41ae61
2 changed files with 4 additions and 23 deletions
+1 -2
View File
@@ -13,13 +13,12 @@ add_subdirectory(../deps/fmgen fmgen)
if (ANDROID)
add_library(system3 SHARED)
find_library(ndk_log log)
target_sources(system3 PRIVATE
android/nact_android.cpp
android/mako.cpp
)
target_link_libraries(system3 PRIVATE SDL2 SDL2_ttf fmgen ${ndk_log})
target_link_libraries(system3 PRIVATE SDL2 SDL2_ttf fmgen)
elseif (EMSCRIPTEN)
add_executable(system3)
+3 -21
View File
@@ -12,10 +12,6 @@
#include <limits.h>
#include <stdio.h>
#ifdef __ANDROID__
#include <android/log.h>
#endif
#ifdef EMSCRIPTEN
#include <emscripten.h>
#define SDL_Delay emscripten_sleep
@@ -31,25 +27,11 @@ typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
#ifdef __ANDROID__
#define ERROR(fmt, ...) \
__android_log_print(ANDROID_LOG_ERROR, "System3", "(%s:%d): " fmt, __func__, __LINE__, ##__VA_ARGS__)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
#define WARNING(fmt, ...) \
__android_log_print(ANDROID_LOG_WARN, "System3", "(%s:%d): " fmt, __func__, __LINE__, ##__VA_ARGS__)
#define NOTICE(fmt, ...) \
__android_log_print(ANDROID_LOG_INFO, "System3", fmt, ##__VA_ARGS__)
#else // __ANDROID__
#define ERROR(fmt, ...) \
fprintf(stderr, "*ERROR*(%s:%d): " fmt "\n", __func__, __LINE__, ##__VA_ARGS__)
#define WARNING(fmt, ...) \
fprintf(stderr, "*WARNING*(%s:%d): " fmt "\n", __func__, __LINE__, ##__VA_ARGS__)
#define NOTICE(fmt, ...) \
fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#endif // __ANDROID__
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "%s:%d: " fmt, __func__, __LINE__, ##__VA_ARGS__)
#define NOTICE SDL_Log
#ifndef WIN32