diff --git a/Src/IACore/inc/hpp/IACore/Exception.hpp b/Src/IACore/inc/hpp/IACore/Exception.hpp index c933923..0cbb5dc 100644 --- a/Src/IACore/inc/hpp/IACore/Exception.hpp +++ b/Src/IACore/inc/hpp/IACore/Exception.hpp @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { enum class ExceptionKind { @@ -132,7 +132,7 @@ private: #define DEFINE_THROWER(name) \ template NORETURN VOID THROW_##name(Args... args) { \ const auto msg = BuildString(args...); \ - printf(#name " %s\n", msg.c_str()); \ + Logger::Error("EXCEPT", "(", #name, "): ", msg); \ throw RuntimeException(ExceptionKind::name, msg); \ } FOR_EACH_RUNTIME_EXCEPT_TYPE(DEFINE_THROWER); diff --git a/Src/IACore/inc/hpp/IACore/Logger.hpp b/Src/IACore/inc/hpp/IACore/Logger.hpp index 01ca8bd..086830d 100644 --- a/Src/IACore/inc/hpp/IACore/Logger.hpp +++ b/Src/IACore/inc/hpp/IACore/Logger.hpp @@ -18,6 +18,10 @@ #include +#ifdef __ANDROID__ +#include +#endif + namespace ia { class Logger @@ -27,21 +31,44 @@ namespace ia { StringStream ss; UNUSED((ss << ... << args)); - printf("\033[32m[INFO]: [%s] %s\033[39m\n", tag, ss.str().c_str()); +#ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_DEBUG, "IAApp", ss.str().c_str()); +#else + printf("\033[0;37m[INFO]: [%s] %s\033[39m\n", tag, ss.str().c_str()); +#endif + } + + template STATIC VOID Success(PCCHAR tag, Args... args) + { + StringStream ss; + UNUSED((ss << ... << args)); +#ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_INFO, "IAApp", ss.str().c_str()); +#else + printf("\033[32m[SUCCESS]: [%s] %s\033[39m\n", tag, ss.str().c_str()); +#endif } template STATIC VOID Warn(PCCHAR tag, Args... args) { StringStream ss; UNUSED((ss << ... << args)); +#ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_DEBUG, "IAApp", ss.str().c_str()); +#else printf("\033[33m[WARN]: [%s] %s\033[39m\n", tag, ss.str().c_str()); +#endif } template STATIC VOID Error(PCCHAR tag, Args... args) { StringStream ss; UNUSED((ss << ... << args)); +#ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_ERROR, "IAApp", ss.str().c_str()); +#else printf("\033[31m[ERROR]: [%s] %s\033[39m\n", tag, ss.str().c_str()); +#endif } private: