2012-03-24 22:39:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2012-03-31 09:16:13 +00:00
|
|
|
// Simple wrapper around Android's logging interface that also allows other
|
|
|
|
// implementations, and also some misc utilities.
|
|
|
|
|
|
|
|
|
|
|
|
// Disable annoying warnings in VS
|
2012-03-24 22:39:19 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning (disable:4996) //strcpy may be dangerous
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Logging
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
2012-08-12 13:12:23 +00:00
|
|
|
#undef Crash
|
|
|
|
|
|
|
|
#ifdef _M_X64
|
2012-08-29 11:46:28 +00:00
|
|
|
inline void Crash() { /*DebugBreak();*/ }
|
2012-08-12 13:12:23 +00:00
|
|
|
#else
|
2012-03-24 22:39:19 +00:00
|
|
|
inline void Crash() { __asm { int 3 }; }
|
2012-08-12 13:12:23 +00:00
|
|
|
#endif
|
2012-03-24 22:39:19 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2012-11-26 10:27:35 +00:00
|
|
|
#if defined(ARM)
|
2012-08-12 13:12:23 +00:00
|
|
|
#undef Crash
|
2012-03-24 22:39:19 +00:00
|
|
|
|
|
|
|
inline void Crash() {
|
|
|
|
char *p = (char *)1337;
|
|
|
|
*p = 1;
|
|
|
|
}
|
|
|
|
#else
|
2012-03-31 09:16:13 +00:00
|
|
|
// TODO: 64-bit version
|
2012-03-24 22:39:19 +00:00
|
|
|
inline void Crash() {
|
|
|
|
asm("int $0x3");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
|
|
|
|
#include <android/log.h>
|
|
|
|
|
2012-03-31 09:16:13 +00:00
|
|
|
// Must only be used for logging
|
2012-03-24 22:39:19 +00:00
|
|
|
#ifndef APP_NAME
|
2012-03-31 09:16:13 +00:00
|
|
|
#define APP_NAME "NativeApp"
|
2012-03-24 22:39:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ILOG(...) __android_log_print(ANDROID_LOG_INFO, APP_NAME, __VA_ARGS__);
|
|
|
|
#define WLOG(...) __android_log_print(ANDROID_LOG_WARN, APP_NAME, __VA_ARGS__);
|
|
|
|
#define ELOG(...) __android_log_print(ANDROID_LOG_ERROR, APP_NAME, __VA_ARGS__);
|
|
|
|
#define FLOG(...) { __android_log_print(ANDROID_LOG_ERROR, APP_NAME, __VA_ARGS__); Crash(); }
|
|
|
|
|
|
|
|
#define MessageBox(a, b, c, d) __android_log_print(ANDROID_LOG_INFO, APP_NAME, "%s %s", (b), (c));
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2012-03-31 09:16:13 +00:00
|
|
|
// TODO: Win32 version using OutputDebugString
|
|
|
|
|
2012-03-24 22:39:19 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define ILOG(...) {printf("I: %s:%i: ", __FILE__, __LINE__); printf("I: " __VA_ARGS__); printf("\n");}
|
|
|
|
#define WLOG(...) {printf("W: %s:%i: ", __FILE__, __LINE__); printf("W: " __VA_ARGS__); printf("\n");}
|
|
|
|
#define ELOG(...) {printf("E: %s:%i: ", __FILE__, __LINE__); printf("E: " __VA_ARGS__); printf("\n");}
|
|
|
|
#define FLOG(...) {printf("F: %s:%i: ", __FILE__, __LINE__); printf("F: " __VA_ARGS__); printf("\n"); Crash();}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-05-06 18:37:28 +00:00
|
|
|
#undef CHECK
|
|
|
|
|
2012-03-24 22:39:19 +00:00
|
|
|
#define CHECK(a) {if (!(a)) {FLOG("CHECK failed");}}
|
2012-06-03 17:01:08 +00:00
|
|
|
#define CHECK_P(a, ...) {if (!(a)) {FLOG("CHECK failed: " __VA_ARGS__);}}
|
2012-03-31 09:16:13 +00:00
|
|
|
#define CHECK_EQ(a, b) CHECK((a) == (b));
|
|
|
|
#define CHECK_NE(a, b) CHECK((a) != (b));
|
2012-06-03 17:01:08 +00:00
|
|
|
#define CHECK_GT(a, b) CHECK((a) > (b));
|
|
|
|
#define CHECK_GE(a, b) CHECK((a) >= (b));
|
|
|
|
#define CHECK_LT(a, b) CHECK((a) < (b));
|
|
|
|
#define CHECK_LE(a, b) CHECK((a) <= (b));
|