From 9561a4f80a861bfbd61bb36be49a23d89cdc872c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 16 Aug 2020 13:48:31 +0200 Subject: [PATCH] Move MsgHandler into Log.cpp/h --- CMakeLists.txt | 4 ++-- Common/Common.vcxproj | 4 ++-- Common/Common.vcxproj.filters | 6 +++-- Common/FakeEmitter.h | 1 - Common/{MsgHandler.cpp => Log.cpp} | 31 ++++++++++++------------- Common/Log.h | 24 +++++++++++++++---- GPU/Common/TextureScalerCommon.cpp | 1 - UWP/CommonUWP/CommonUWP.vcxproj | 3 +-- UWP/CommonUWP/CommonUWP.vcxproj.filters | 3 +-- android/jni/Android.mk | 2 +- libretro/Makefile.common | 2 +- 11 files changed, 46 insertions(+), 35 deletions(-) rename Common/{MsgHandler.cpp => Log.cpp} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f9eae3205..7651d67276 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -440,6 +440,8 @@ add_library(Common STATIC Common/KeyMap.cpp Common/KeyMap.h Common/Hashmaps.h + Common/Log.h + Common/Log.cpp Common/LogManager.cpp Common/LogManager.h Common/MakeUnique.h @@ -451,8 +453,6 @@ add_library(Common STATIC Common/MemoryUtil.cpp Common/MemoryUtil.h Common/Misc.cpp - Common/MsgHandler.cpp - Common/MsgHandler.h Common/OSVersion.cpp Common/OSVersion.h Common/StringUtils.cpp diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index cfe40b4cf4..62f72077cd 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -354,6 +354,7 @@ + @@ -407,7 +408,6 @@ - @@ -450,6 +450,7 @@ false false + @@ -498,7 +499,6 @@ - Create diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 92551a3e85..6cd39fb4f3 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -14,7 +14,6 @@ - @@ -93,6 +92,8 @@ Serialize + + @@ -103,7 +104,6 @@ - @@ -159,6 +159,8 @@ Serialize + + diff --git a/Common/FakeEmitter.h b/Common/FakeEmitter.h index 25ef39b419..6b827655c8 100644 --- a/Common/FakeEmitter.h +++ b/Common/FakeEmitter.h @@ -24,7 +24,6 @@ #include #include "Common.h" -#include "MsgHandler.h" // VCVT flags #define TO_FLOAT 0 diff --git a/Common/MsgHandler.cpp b/Common/Log.cpp similarity index 99% rename from Common/MsgHandler.cpp rename to Common/Log.cpp index 9df5f14538..4aff42ce37 100644 --- a/Common/MsgHandler.cpp +++ b/Common/Log.cpp @@ -30,6 +30,21 @@ #include "CommonWindows.h" #endif +#if defined(__ANDROID__) + +#define LOG_BUF_SIZE 1024 + +void AndroidAssert(const char *func, const char *file, int line, const char *condition, const char *fmt, ...) { + char buf[LOG_BUF_SIZE]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + __android_log_assert(condition, "PPSSPP", "%s:%d (%s): [%s] %s", file, line, func, condition, buf); + va_end(args); +} + +#endif + bool ShowAssertDialog(const char *function, const char *file, int line, const char *expression, const char* format, ...) { // Read message and write it to the log char text[2048]; @@ -55,19 +70,3 @@ bool ShowAssertDialog(const char *function, const char *file, int line, const ch return false; #endif } - - -#if defined(__ANDROID__) - -#define LOG_BUF_SIZE 1024 - -void AndroidAssert(const char *func, const char *file, int line, const char *condition, const char *fmt, ...) { - char buf[LOG_BUF_SIZE]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, sizeof(buf), fmt, args); - __android_log_assert(condition, "PPSSPP", "%s:%d (%s): [%s] %s", file, line, func, condition, buf); - va_end(args); -} - -#endif diff --git a/Common/Log.h b/Common/Log.h index 4638865639..74dec3fc65 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -20,7 +20,6 @@ #include #include "CommonFuncs.h" -#include "MsgHandler.h" // For ShowAssertDialog #define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and debugprintfs from the game itself. #define ERROR_LEVEL 2 // Important errors. @@ -105,11 +104,11 @@ bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type); GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ } -#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (false) +#define ERROR_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } while (false) #define WARN_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } while (false) -#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (false) -#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (false) -#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (false) +#define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (false) +#define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (false) +#define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (false) #define VERBOSE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LVERBOSE, __VA_ARGS__) } while (false) // If we're in "debug" assert mode @@ -173,3 +172,18 @@ bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type); // Just INFO_LOGs on nonWindows. On Windows it outputs to the VS output console. void OutputDebugStringUTF8(const char *p); + +// Currently only actually shows a dialog box on Windows. +bool ShowAssertDialog(const char *function, const char *file, int line, const char *expression, const char* format, ...) +#ifdef __GNUC__ +__attribute__((format(printf, 5, 6))) +#endif +; + +#if defined(__ANDROID__) + +// Tricky macro to get the basename, that also works if *built* on Win32. +#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : (__builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__)) +void AndroidAssert(const char *func, const char *file, int line, const char *condition, const char *fmt, ...); + +#endif diff --git a/GPU/Common/TextureScalerCommon.cpp b/GPU/Common/TextureScalerCommon.cpp index 63b972403e..6f4c2d3fc4 100644 --- a/GPU/Common/TextureScalerCommon.cpp +++ b/GPU/Common/TextureScalerCommon.cpp @@ -30,7 +30,6 @@ #include "Core/Config.h" #include "Common/Common.h" #include "Common/Log.h" -#include "Common/MsgHandler.h" #include "Common/CommonFuncs.h" #include "Common/ThreadPools.h" #include "Common/CPUDetect.h" diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index 3405d3666f..b6a8a7b933 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -414,7 +414,6 @@ - @@ -445,6 +444,7 @@ + @@ -454,7 +454,6 @@ - diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 57775b7f87..50626b680e 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -19,6 +19,7 @@ + @@ -28,7 +29,6 @@ - @@ -83,7 +83,6 @@ - diff --git a/android/jni/Android.mk b/android/jni/Android.mk index cd30bde35c..36a29682f0 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -209,13 +209,13 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Common/ColorConv.cpp \ $(SRC)/Common/ExceptionHandlerSetup.cpp \ $(SRC)/Common/KeyMap.cpp \ + $(SRC)/Common/Log.cpp \ $(SRC)/Common/LogManager.cpp \ $(SRC)/Common/MemArenaAndroid.cpp \ $(SRC)/Common/MemArenaDarwin.cpp \ $(SRC)/Common/MemArenaWin32.cpp \ $(SRC)/Common/MemArenaPosix.cpp \ $(SRC)/Common/MemoryUtil.cpp \ - $(SRC)/Common/MsgHandler.cpp \ $(SRC)/Common/FileUtil.cpp \ $(SRC)/Common/StringUtils.cpp \ $(SRC)/Common/ThreadPools.cpp \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index d9e90898eb..d92fd54468 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -146,11 +146,11 @@ SOURCES_CXX += \ $(COMMONDIR)/ExceptionHandlerSetup.cpp \ $(COMMONDIR)/FileUtil.cpp \ $(COMMONDIR)/KeyMap.cpp \ + $(COMMONDIR)/Log.cpp \ $(COMMONDIR)/LogManager.cpp \ $(COMMONDIR)/OSVersion.cpp \ $(COMMONDIR)/MemoryUtil.cpp \ $(COMMONDIR)/Misc.cpp \ - $(COMMONDIR)/MsgHandler.cpp \ $(COMMONDIR)/StringUtils.cpp \ $(COMMONDIR)/Timer.cpp \ $(COMMONDIR)/TimeUtil.cpp \