From c73686c9ebae2ff934c75971057dfcd856be8c3c Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 19 Dec 2012 11:12:26 +0000 Subject: [PATCH] Support logging debug information to logcat on Android. --- src/debug.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/debug.h b/src/debug.h index 199b2eb8..8f009fbe 100644 --- a/src/debug.h +++ b/src/debug.h @@ -3,10 +3,31 @@ //#define DEBUG_ENABLED +#ifdef ANDROID + +#include +#define LOG_TAG "eSpeak" + #ifdef DEBUG_ENABLED +#define ENTER(text) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, text) +#define SHOW(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) +#else +#define ENTER(text) +#define SHOW(format,...) +#endif + +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) +#define SHOW_TIME(text) + +#else + +#ifdef DEBUG_ENABLED + #define ENTER(text) debug_enter(text) #define SHOW(format,...) debug_show(format,__VA_ARGS__); +#define LOGE(format,...) debug_show(format,__VA_ARGS__); #define SHOW_TIME(text) debug_time(text); + extern void debug_enter(const char* text); extern void debug_show(const char* format,...); extern void debug_time(const char* text); @@ -15,12 +36,15 @@ extern void debug_time(const char* text); #ifdef NO_VARIADIC_MACROS #define SHOW(format) // VC6 doesn't allow "..." +#define LOGE(format) // VC6 doesn't allow "..." #else #define SHOW(format,...) +#define LOGE(format,...) #endif + #define SHOW_TIME(text) #define ENTER(text) -#endif - #endif +#endif +#endif