From 076f0c8e1bcef78be2ba3b37991bf56d194fab5c Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Tue, 26 May 2015 23:38:58 +0600 Subject: [PATCH] GLideNHQ: Output debug messages to android log instead of file. --- src/GLideNHQ/TxDbg.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/GLideNHQ/TxDbg.cpp b/src/GLideNHQ/TxDbg.cpp index 6f070f2b..74d34347 100644 --- a/src/GLideNHQ/TxDbg.cpp +++ b/src/GLideNHQ/TxDbg.cpp @@ -28,6 +28,34 @@ #include #include +#ifdef ANDROID +#include + +TxDbg::TxDbg() +{ + _level = DBG_LEVEL; +} + +TxDbg::~TxDbg() +{} + + +void +TxDbg::output(const int level, const wchar_t *format, ...) +{ + if (level > _level) + return; + + char fmt[2048]; + wcstombs(fmt, format, 2048); + + va_list ap; + va_start(ap, format); + __android_log_vprint(ANDROID_LOG_DEBUG, "GLideN64", fmt, ap); + va_end(ap); +} + +#else // ANDROID TxDbg::TxDbg() { _level = DBG_LEVEL; @@ -53,12 +81,12 @@ TxDbg::~TxDbg() void TxDbg::output(const int level, const wchar_t *format, ...) { - va_list args; - wchar_t newformat[4095]; - if (level > _level) return; + va_list args; + wchar_t newformat[4095]; + va_start(args, format); swprintf(newformat, 4095, L"%d:\t", level); wcscat(newformat, format); @@ -70,3 +98,4 @@ TxDbg::output(const int level, const wchar_t *format, ...) #endif va_end(args); } +#endif // ANDROID