Move MsgHandler into Log.cpp/h

This commit is contained in:
Henrik Rydgård 2020-08-16 13:48:31 +02:00
parent 5704ebfb61
commit 9561a4f80a
11 changed files with 46 additions and 35 deletions

View file

@ -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

View file

@ -354,6 +354,7 @@
<ClInclude Include="ArmEmitter.h" />
<ClInclude Include="BitScan.h" />
<ClInclude Include="BitSet.h" />
<ClInclude Include="FakeEmitter.h" />
<ClInclude Include="Serialize\SerializeDeque.h" />
<ClInclude Include="Serialize\SerializeFuncs.h" />
<ClInclude Include="ColorConvNEON.h" />
@ -407,7 +408,6 @@
<ClInclude Include="MemArena.h" />
<ClInclude Include="MemoryUtil.h" />
<ClInclude Include="MipsEmitter.h" />
<ClInclude Include="MsgHandler.h" />
<ClInclude Include="OSVersion.h" />
<ClInclude Include="Serialize\SerializeSet.h" />
<ClInclude Include="stdafx.h" />
@ -450,6 +450,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="Log.cpp" />
<ClCompile Include="Serialize\Serializer.cpp" />
<ClCompile Include="ColorConv.cpp" />
<ClCompile Include="ConsoleListener.cpp" />
@ -498,7 +499,6 @@
<ClCompile Include="MemoryUtil.cpp" />
<ClCompile Include="MipsEmitter.cpp" />
<ClCompile Include="Misc.cpp" />
<ClCompile Include="MsgHandler.cpp" />
<ClCompile Include="OSVersion.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

View file

@ -14,7 +14,6 @@
<ClInclude Include="LogManager.h" />
<ClInclude Include="MemArena.h" />
<ClInclude Include="MemoryUtil.h" />
<ClInclude Include="MsgHandler.h" />
<ClInclude Include="StringUtils.h" />
<ClInclude Include="Thunk.h" />
<ClInclude Include="Timer.h" />
@ -93,6 +92,8 @@
<ClInclude Include="Serialize\SerializeSet.h">
<Filter>Serialize</Filter>
</ClInclude>
<ClInclude Include="TimeUtil.h" />
<ClInclude Include="FakeEmitter.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp" />
@ -103,7 +104,6 @@
<ClCompile Include="LogManager.cpp" />
<ClCompile Include="MemoryUtil.cpp" />
<ClCompile Include="Misc.cpp" />
<ClCompile Include="MsgHandler.cpp" />
<ClCompile Include="StringUtils.cpp" />
<ClCompile Include="Thunk.cpp" />
<ClCompile Include="Timer.cpp" />
@ -159,6 +159,8 @@
<ClCompile Include="Serialize\Serializer.cpp">
<Filter>Serialize</Filter>
</ClCompile>
<ClCompile Include="TimeUtil.cpp" />
<ClCompile Include="Log.cpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="Crypto">

View file

@ -24,7 +24,6 @@
#include <stdint.h>
#include "Common.h"
#include "MsgHandler.h"
// VCVT flags
#define TO_FLOAT 0

View file

@ -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

View file

@ -20,7 +20,6 @@
#include <cstdio>
#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

View file

@ -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"

View file

@ -414,7 +414,6 @@
<ClInclude Include="..\..\Common\MemArena.h" />
<ClInclude Include="..\..\Common\MemoryUtil.h" />
<ClInclude Include="..\..\Common\MipsEmitter.h" />
<ClInclude Include="..\..\Common\MsgHandler.h" />
<ClInclude Include="..\..\Common\OSVersion.h" />
<ClInclude Include="..\..\Common\stdafx.h" />
<ClInclude Include="..\..\Common\StringUtils.h" />
@ -445,6 +444,7 @@
<ClCompile Include="..\..\Common\ExceptionHandlerSetup.cpp" />
<ClCompile Include="..\..\Common\FileUtil.cpp" />
<ClCompile Include="..\..\Common\KeyMap.cpp" />
<ClCompile Include="..\..\Common\Log.cpp" />
<ClCompile Include="..\..\Common\LogManager.cpp" />
<ClCompile Include="..\..\Common\MemArenaAndroid.cpp" />
<ClCompile Include="..\..\Common\MemArenaDarwin.cpp" />
@ -454,7 +454,6 @@
<ClCompile Include="..\..\Common\MipsCPUDetect.cpp" />
<ClCompile Include="..\..\Common\MipsEmitter.cpp" />
<ClCompile Include="..\..\Common\Misc.cpp" />
<ClCompile Include="..\..\Common\MsgHandler.cpp" />
<ClCompile Include="..\..\Common\OSVersion.cpp" />
<ClCompile Include="..\..\Common\stdafx.cpp" />
<ClCompile Include="..\..\Common\StringUtils.cpp" />

View file

@ -19,6 +19,7 @@
<ClCompile Include="..\..\Common\ExceptionHandlerSetup.cpp" />
<ClCompile Include="..\..\Common\FileUtil.cpp" />
<ClCompile Include="..\..\Common\KeyMap.cpp" />
<ClCompile Include="..\..\Common\Log.cpp" />
<ClCompile Include="..\..\Common\LogManager.cpp" />
<ClCompile Include="..\..\Common\MemArenaAndroid.cpp" />
<ClCompile Include="..\..\Common\MemArenaDarwin.cpp" />
@ -28,7 +29,6 @@
<ClCompile Include="..\..\Common\MipsCPUDetect.cpp" />
<ClCompile Include="..\..\Common\MipsEmitter.cpp" />
<ClCompile Include="..\..\Common\Misc.cpp" />
<ClCompile Include="..\..\Common\MsgHandler.cpp" />
<ClCompile Include="..\..\Common\OSVersion.cpp" />
<ClCompile Include="..\..\Common\stdafx.cpp" />
<ClCompile Include="..\..\Common\StringUtils.cpp" />
@ -83,7 +83,6 @@
<ClInclude Include="..\..\Common\MemArena.h" />
<ClInclude Include="..\..\Common\MemoryUtil.h" />
<ClInclude Include="..\..\Common\MipsEmitter.h" />
<ClInclude Include="..\..\Common\MsgHandler.h" />
<ClInclude Include="..\..\Common\OSVersion.h" />
<ClInclude Include="..\..\Common\stdafx.h" />
<ClInclude Include="..\..\Common\StringUtils.h" />

View file

@ -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 \

View file

@ -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 \