24 #include <flw/Config.h> 25 #include <flw/PlatformSW.h> 28 #if defined(FILLWAVE_COMPILATION_RELEASE) || defined(FILLWAVE_BENCHMARK_TESTS) 30 #define FLOGINIT_DEFAULT() 31 #define FLOGINIT_MASK(mask) 32 #define FLOGINIT(tag, mask) 33 #define FLOGINIT_NONE() 36 #define fLogF(...) { } 37 #define fLogI(...) { } 38 #define fLogD(...) { } 39 #define fLogU(...) { } 40 #define fLogW(...) { } 41 #define fLogE(...) { } 42 #define fLogC(...) { } 46 #define FBIT(offset) (1 << offset) 47 #define FERROR FBIT(0) 49 #define FDEBUG FBIT(2) 50 #define FFATAL FBIT(3) 52 #define FWARNING FBIT(5) 53 #define FBIT_MAX (FERROR | FINFO | FDEBUG | FFATAL | FUSER | FWARNING) 54 #define FIF(mask) (::_mask_ & mask) 55 #define FSTR_HELPER(x) #x 56 #define FTO_STRING(x) FSTR_HELPER(x) 59 #include <android/log.h> 66 constexpr
auto FLOG_BLACK =
"";
67 constexpr
auto FLOG_RED =
"";
68 constexpr
auto FLOG_GREEN =
"";
69 constexpr
auto FLOG_YELLOW =
"";
70 constexpr
auto FLOG_BLUE =
"";
71 constexpr
auto FLOG_MAGENTA =
"";
72 constexpr
auto FLOG_CYAN =
"";
73 constexpr
auto FLOG_WHITE =
"";
74 constexpr
auto FLOG_END =
"";
76 constexpr
auto FLOG_BLACK =
"\033[0;30m";
77 constexpr
auto FLOG_RED =
"\033[0;31m";
78 constexpr
auto FLOG_GREEN =
"\033[0;32m";
79 constexpr
auto FLOG_YELLOW =
"\033[0;33m";
80 constexpr
auto FLOG_BLUE =
"\033[0;34m";
81 constexpr
auto FLOG_MAGENTA =
"\033[0;35m";
82 constexpr
auto FLOG_CYAN =
"\033[0;36m";
83 constexpr
auto FLOG_WHITE =
"\033[0;37m";
84 constexpr
auto FLOG_END =
"\033[0m";
89 #define FLOGINIT_DEFAULT() \ 90 static const std::string _tag_ = ( \ 91 std::string(__FILE__).find(FILLWAVE_OS_SEPRATOR) == std::string::npos ? std::string(__FILE__) : \ 92 std::string(__FILE__).substr(std::string(__FILE__).find_last_of( \ 93 FILLWAVE_OS_SEPRATOR) + 1, std::string(__FILE__).size())); \ 94 static const char _mask_ = FBIT_MAX; 96 #define FLOGINIT_MASK(mask) \ 97 static const std::string _tag_ = ( \ 98 std::string(__FILE__).find(FILLWAVE_OS_SEPRATOR) == std::string::npos ? std::string(__FILE__) : \ 99 std::string(__FILE__).substr(std::string(__FILE__).find_last_of( \ 100 FILLWAVE_OS_SEPRATOR) + 1, std::string(__FILE__).size())); \ 101 static const char _mask_ = (mask); 103 #define FLOGINIT(tag, mask) \ 104 static const std::string _tag_ = (tag); \ 105 static const char _mask_ = (mask); 107 #define FLOGINIT_NONE() \ 108 static const std::string _tag_ = ""; \ 109 static const char _mask_ = 0; 113 #define GPU_FATAL ANDROID_LOG_FATAL 114 #define GPU_ERROR ANDROID_LOG_ERROR 115 #define GPU_INFO ANDROID_LOG_INFO 116 #define GPU_DEBUG ANDROID_LOG_DEBUG 117 #define GPU_WARN ANDROID_LOG_WARN 118 #define GPU_USER ANDROID_LOG_WARN 122 #define GPU_FATAL FLOG_MAGENTA 123 #define GPU_ERROR FLOG_RED 124 #define GPU_INFO FLOG_WHITE 125 #define GPU_DEBUG FLOG_GREEN 126 #define GPU_WARN FLOG_YELLOW 127 #define GPU_USER FLOG_BLUE 134 #define fLog() __android_log_print(LOG_FLAG, ::_tag_.c_str(), "") 135 #define fLogBase(LOG_CONDITION, LOG_FLAG, ...)\ 136 do { if ( FIF(LOG_CONDITION) ) (void)__android_log_print(LOG_FLAG, ::_tag_.c_str(), __VA_ARGS__); } while(0) 141 static void fLogWithStream(std::stringstream& s,
const T& t) {
142 std::cout << s.str() << t << FLOG_END <<
"\n";
144 template<
typename T,
typename... Args>
145 static void fLogWithStream(std::stringstream& s,
const T& t, Args... args) {
147 fLogWithStream(s, args...);
150 #define fLogBase(COLOR, COND, ...)\ 153 std::stringstream s;\ 155 fLogWithStream(s, ::_tag_,":", __LINE__, " ", __VA_ARGS__);\ 167 GLenum errorCode = glGetError();\ 168 if ( errorCode != GL_NO_ERROR) {\ 169 (void)__android_log_print(ANDROID_LOG_ERROR, ::_tag_.c_str(), "[%s 0x%04x] ", "CORE ERROR:", errorCode);\ 170 (void)__android_log_print(ANDROID_LOG_ERROR, ::_tag_.c_str(), __VA_ARGS__);\ 171 if (errorCode == 0x0506) { \ 172 GLenum status = getFramebufferStatus();\ 173 (void)__android_log_print(ANDROID_LOG_ERROR, ::_tag_.c_str(), "[%s 0x%04x] ", "FRAMEBUFFER_STATUS:", status);\ 180 #define FILLWAVE_SPRINTF sprintf_s 182 #define FILLWAVE_SPRINTF sprintf 185 #define fLogC(...) do {\ 187 GLenum errorCode = getGlError();\ 188 if (0 != errorCode) { \ 190 int n = FILLWAVE_SPRINTF(glBuffer, "[%s 0x%04x] ", "CORE ERROR:", errorCode);\ 194 if (errorCode == 0x0506) { \ 195 GLenum status = getFramebufferStatus();\ 196 n = FILLWAVE_SPRINTF(glBuffer, "[%s 0x%04x] ", "FRAMEBUFFER_STATUS:", status);\ 209 #define fLogF(...) fLogBase(FLOG_MAGENTA, FFATAL, __VA_ARGS__) 210 #define fLogE(...) fLogBase(FLOG_RED, FERROR, __VA_ARGS__) 211 #define fLogI(...) fLogBase(FLOG_WHITE, FINFO, __VA_ARGS__) 212 #define fLogU(...) fLogBase(FLOG_BLUE, FUSER, __VA_ARGS__) 213 #define fLogD(...) fLogBase(FLOG_GREEN, FDEBUG, __VA_ARGS__) 214 #define fLogW(...) fLogBase(FLOG_YELLOW, FWARNING, __VA_ARGS__)