android: log into logcat

This commit is contained in:
Sebastian Krzyszkowiak 2018-11-02 06:07:49 +01:00
parent bbba7da52f
commit f922ffe997
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
2 changed files with 11 additions and 1 deletions

View file

@ -26,4 +26,8 @@ SET_TARGET_PROPERTIES("libsuperderpy" PROPERTIES PREFIX "")
target_link_libraries("libsuperderpy" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_VIDEO_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} m dl)
if (ANDROID)
target_link_libraries("libsuperderpy" log)
endif (ANDROID)
install(TARGETS "libsuperderpy" DESTINATION ${LIB_INSTALL_DIR})

View file

@ -26,6 +26,9 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
#ifdef ALLEGRO_ANDROID
#include <android/log.h>
#endif
// TODO: split to separate files
@ -397,7 +400,7 @@ __attribute__((__format__(__printf__, 5, 0))) SYMBOL_EXPORT void PrintConsoleWit
ALLEGRO_DEBUG("%s\n", text);
SUPPRESS_END
#ifndef __EMSCRIPTEN__
#if !defined(__EMSCRIPTEN__) && !defined(ALLEGRO_ANDROID)
if (game->config.debug)
#endif
{
@ -405,6 +408,9 @@ __attribute__((__format__(__printf__, 5, 0))) SYMBOL_EXPORT void PrintConsoleWit
printf("%s:%d ", file, line);
}
printf("[%s] %s\n", func, text);
#ifdef ALLEGRO_ANDROID
__android_log_print(ANDROID_LOG_DEBUG, al_get_app_name(), "[%s] %s", func, text);
#endif
fflush(stdout);
}
game->_priv.console_pos++;