diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0137d06d5a..1b8a4e8706 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -822,7 +822,6 @@ elseif(WIN32)
else()
link_directories(dx9sdk/Lib/x86)
endif()
- set(nativeExtra ${nativeExtra} ext/native/base/logging.cpp)
elseif(TARGET SDL2::SDL2)
set(TargetBin PPSSPPSDL)
# Require SDL
@@ -934,7 +933,6 @@ add_library(native STATIC
ext/native/base/display.cpp
ext/native/base/display.h
ext/native/base/linked_ptr.h
- ext/native/base/logging.h
ext/native/base/stringutil.cpp
ext/native/base/stringutil.h
ext/native/base/timeutil.cpp
diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp
index 00d37db957..db07804eb8 100644
--- a/UI/NativeApp.cpp
+++ b/UI/NativeApp.cpp
@@ -44,9 +44,6 @@
#endif
#include "base/display.h"
-
-#include "base/logging.h" // For "AndroidLogger". TODO: Remove.
-
#include "base/stringutil.h"
#include "base/timeutil.h"
#include "base/NativeApp.h"
@@ -70,12 +67,16 @@
#include "ui/view.h"
#include "util/text/utf8.h"
+#include "android/jni/app-android.h"
+
#include "Common/CPUDetect.h"
#include "Common/FileUtil.h"
+#include "Common/KeyMap.h"
#include "Common/LogManager.h"
#include "Common/MemArena.h"
#include "Common/GraphicsContext.h"
#include "Common/OSVersion.h"
+
#include "Core/Config.h"
#include "Core/ConfigValues.h"
#include "Core/Core.h"
@@ -93,8 +94,8 @@
#include "Core/Util/GameManager.h"
#include "Core/Util/AudioFormat.h"
#include "Core/WebServer.h"
-#include "GPU/GPUInterface.h"
+#include "GPU/GPUInterface.h"
#include "UI/BackgroundAudio.h"
#include "UI/ControlMappingScreen.h"
#include "UI/DiscordIntegration.h"
@@ -108,10 +109,6 @@
#include "UI/TiltEventProcessor.h"
#include "UI/TextureUtil.h"
-#if !defined(MOBILE_DEVICE)
-#include "Common/KeyMap.h"
-#endif
-
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
#include "Qt/QtHost.h"
#endif
@@ -183,7 +180,7 @@ WindowsAudioBackend *winAudioBackend;
std::thread *graphicsLoadThread;
-class AndroidLogger : public LogListener {
+class PrintfLogger : public LogListener {
public:
void Log(const LogMessage &message) override {
// Log with simplified headers as Android already provides timestamp etc.
@@ -191,17 +188,17 @@ public:
case LogTypes::LVERBOSE:
case LogTypes::LDEBUG:
case LogTypes::LINFO:
- ILOG("[%s] %s", message.log, message.msg.c_str());
+ printf("INFO [%s] %s", message.log, message.msg.c_str());
break;
case LogTypes::LERROR:
- ELOG("[%s] %s", message.log, message.msg.c_str());
+ printf("ERR [%s] %s", message.log, message.msg.c_str());
break;
case LogTypes::LWARNING:
- WLOG("[%s] %s", message.log, message.msg.c_str());
+ printf("WARN [%s] %s", message.log, message.msg.c_str());
break;
case LogTypes::LNOTICE:
default:
- ILOG("[%s] !!! %s", message.log, message.msg.c_str());
+ printf("NOTE [%s] !!! %s", message.log, message.msg.c_str());
break;
}
}
@@ -214,7 +211,7 @@ int Win32Mix(short *buffer, int numSamples, int bits, int rate, int channels) {
#endif
// globals
-static AndroidLogger *logger = nullptr;
+static LogListener *logger = nullptr;
std::string boot_filename = "";
void NativeHost::InitSound() {
@@ -661,10 +658,13 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
PostLoadConfig();
-#if defined(__ANDROID__) || (defined(MOBILE_DEVICE) && !defined(_DEBUG))
+#if PPSSPP_PLATFORM(ANDROID)
+ logger = new AndroidLogger();
+ logman->AddListener(logger);
+#elif (defined(MOBILE_DEVICE) && !defined(_DEBUG))
// Enable basic logging for any kind of mobile device, since LogManager doesn't.
// The MOBILE_DEVICE/_DEBUG condition matches LogManager.cpp.
- logger = new AndroidLogger();
+ logger = new PrintfLogger();
logman->AddListener(logger);
#endif
@@ -1408,9 +1408,6 @@ void NativeShutdown() {
g_Discord.Shutdown();
- delete logger;
- logger = nullptr;
-
// Previously we did exit() here on Android but that makes it hard to do things like restart on backend change.
// I think we handle most globals correctly or correct-enough now.
}
diff --git a/UWP/NativeUWP/NativeUWP.vcxproj b/UWP/NativeUWP/NativeUWP.vcxproj
index a25e4fbd1a..cce36088aa 100644
--- a/UWP/NativeUWP/NativeUWP.vcxproj
+++ b/UWP/NativeUWP/NativeUWP.vcxproj
@@ -385,7 +385,6 @@
-
@@ -479,7 +478,6 @@
-
diff --git a/Windows/main.cpp b/Windows/main.cpp
index 6193e9e96f..693d57c8db 100644
--- a/Windows/main.cpp
+++ b/Windows/main.cpp
@@ -610,8 +610,9 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
// - It should be possible to log to a file without showing the console.
LogManager::GetInstance()->GetConsoleListener()->Init(showLog, 150, 120, "PPSSPP Debug Console");
- if (debugLogLevel)
+ if (debugLogLevel) {
LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG);
+ }
timeBeginPeriod(1); // TODO: Evaluate if this makes sense to keep.
diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp
index aad11b14f1..a0c5c6a5af 100644
--- a/android/jni/app-android.cpp
+++ b/android/jni/app-android.cpp
@@ -16,6 +16,8 @@
#ifndef _MSC_VER
#include
#include
+#include
+
#elif !defined(JNIEXPORT)
// Just for better highlighting in MSVC if opening this file.
// Not having types makes it get confused and say everything is wrong.
@@ -173,6 +175,44 @@ static std::map permissions;
AndroidGraphicsContext *graphicsContext;
+#ifndef LOG_APP_NAME
+#define LOG_APP_NAME "PPSSPP"
+#endif
+
+#ifdef _DEBUG
+#define DLOG(...) __android_log_print(ANDROID_LOG_INFO, LOG_APP_NAME, __VA_ARGS__);
+#else
+#define DLOG(...)
+#endif
+
+#define ILOG(...) __android_log_print(ANDROID_LOG_INFO, LOG_APP_NAME, __VA_ARGS__);
+#define WLOG(...) __android_log_print(ANDROID_LOG_WARN, LOG_APP_NAME, __VA_ARGS__);
+#define ELOG(...) __android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, __VA_ARGS__);
+#define FLOG(...) __android_log_print(ANDROID_LOG_FATAL, LOG_APP_NAME, __VA_ARGS__);
+
+#define MessageBox(a, b, c, d) __android_log_print(ANDROID_LOG_INFO, APP_NAME, "%s %s", (b), (c));
+
+void AndroidLogger::Log(const LogMessage &message) {
+ // Log with simplified headers as Android already provides timestamp etc.
+ switch (message.level) {
+ case LogTypes::LVERBOSE:
+ case LogTypes::LDEBUG:
+ case LogTypes::LINFO:
+ ILOG("[%s] %s", message.log, message.msg.c_str());
+ break;
+ case LogTypes::LERROR:
+ ELOG("[%s] %s", message.log, message.msg.c_str());
+ break;
+ case LogTypes::LWARNING:
+ WLOG("[%s] %s", message.log, message.msg.c_str());
+ break;
+ case LogTypes::LNOTICE:
+ default:
+ ILOG("[%s] !!! %s", message.log, message.msg.c_str());
+ break;
+ }
+}
+
JNIEnv* getEnv() {
JNIEnv *env;
int status = gJvm->GetEnv((void**)&env, JNI_VERSION_1_6);
diff --git a/android/jni/app-android.h b/android/jni/app-android.h
index 49d0dab435..aa21dd9ade 100644
--- a/android/jni/app-android.h
+++ b/android/jni/app-android.h
@@ -2,6 +2,8 @@
#include "ppsspp_config.h"
+#include "Common/LogManager.h"
+
#if PPSSPP_PLATFORM(ANDROID)
#include
@@ -10,3 +12,8 @@ jclass findClass(const char* name);
JNIEnv* getEnv();
#endif
+
+class AndroidLogger : public LogListener {
+public:
+ void Log(const LogMessage &message) override;
+};
diff --git a/ext/native/base/logging.cpp b/ext/native/base/logging.cpp
deleted file mode 100644
index 812219d11f..0000000000
--- a/ext/native/base/logging.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include
-
-const char *GetFn(const char *fn) {
- const char *p = strrchr(fn, '\\');
- if (p)
- return p + 1;
- else
- return fn;
-}
diff --git a/ext/native/base/logging.h b/ext/native/base/logging.h
deleted file mode 100644
index 1ba560b602..0000000000
--- a/ext/native/base/logging.h
+++ /dev/null
@@ -1,124 +0,0 @@
-#pragma once
-
-#include
-
-#include "ppsspp_config.h"
-#include "base/backtrace.h"
-
-// Simple wrapper around Android's logging interface that also allows other
-// implementations, and also some misc utilities.
-
-#ifdef _MSC_VER
-// Disable annoying warnings in VS
-#pragma warning (disable:4996) //strcpy may be dangerous, etc.
-#endif
-
-#undef Crash
-
-#include
-// Logging
-#ifdef _WIN32
-
-#ifdef _M_X64
-inline void Crash() { int *x = (int *)1337; *x = 1; }
-#elif defined(_M_IX86)
-inline void Crash() { __asm { int 3 }; }
-#elif defined(_M_ARM)
-inline void Crash() { int *x = (int *)1337; *x = 1; }
-#elif defined(_M_ARM64)
-inline void Crash() { int* x = (int*)1337; *x = 1; }
-#endif
-
-#else
-
-#if defined(_M_IX86) || defined(_M_X64)
-inline void Crash() {
- PrintBacktraceToStderr();
- asm("int $0x3");
-}
-#else
-inline void Crash() {
- PrintBacktraceToStderr();
- char *p = (char *)1337;
- *p = 1;
-}
-#endif
-
-#endif
-
-#if defined(__ANDROID__)
-
-#include
-
-// Must only be used for logging
-#ifndef APP_NAME
-#define APP_NAME "PPSSPP"
-#endif
-
-#ifdef _DEBUG
-#define DLOG(...) __android_log_print(ANDROID_LOG_INFO, APP_NAME, __VA_ARGS__);
-#else
-#define DLOG(...)
-#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_FATAL, APP_NAME, __VA_ARGS__);
-
-#define MessageBox(a, b, c, d) __android_log_print(ANDROID_LOG_INFO, APP_NAME, "%s %s", (b), (c));
-
-#else
-
-#ifdef _WIN32
-
-const char *GetFn(const char *fn);
-
-#define XLOG_IMPL(type, ...) do {\
- char temp[512]; \
- char *p = temp; \
- int len = snprintf(p, sizeof(temp), type ": %s:%i: ", GetFn(__FILE__), __LINE__); \
- if (len < sizeof(temp)) { \
- p += len; \
- p += snprintf(p, sizeof(temp) - len - 3, type ": " __VA_ARGS__); \
- if (p > temp + sizeof(temp) - 3) \
- p = temp + sizeof(temp) - 3; \
- p += sprintf(p, "\n"); \
- OutputDebugStringUTF8(temp); \
- } \
-} while (false)
-
-#define DUMPLOG(x) OutputDebugStringUTF8(x)
-
-#ifdef _DEBUG
-#define DLOG(...) XLOG_IMPL("D", __VA_ARGS__)
-#else
-#define DLOG(...)
-#endif
-
-#define ILOG(...) XLOG_IMPL("I", __VA_ARGS__)
-#define WLOG(...) XLOG_IMPL("W", __VA_ARGS__)
-#define ELOG(...) XLOG_IMPL("E", __VA_ARGS__)
-#define FLOG(...) do {XLOG_IMPL("F", __VA_ARGS__); Crash();} while (false)
-
-#else
-
-#include
-
-inline const char *removePath(const char *str) {
- const char *slash = strrchr(str, '/');
- return slash ? (slash + 1) : str;
-}
-
-#ifdef _DEBUG
-#define DLOG(...) {printf("D: %s:%i: ", removePath(__FILE__), __LINE__); printf("D: " __VA_ARGS__); printf("\n");}
-#else
-#define DLOG(...)
-#endif
-#define ILOG(...) {printf("I: %s:%i: ", removePath(__FILE__), __LINE__); printf(__VA_ARGS__); printf("\n");}
-#define WLOG(...) {printf("W: %s:%i: ", removePath(__FILE__), __LINE__); printf(__VA_ARGS__); printf("\n");}
-#define ELOG(...) {printf("E: %s:%i: ", removePath(__FILE__), __LINE__); printf(__VA_ARGS__); printf("\n");}
-#define FLOG(...) {printf("F: %s:%i: ", removePath(__FILE__), __LINE__); printf(__VA_ARGS__); printf("\n"); Crash();}
-
-#endif
-#endif
diff --git a/ext/native/native.vcxproj b/ext/native/native.vcxproj
index d13049e3e9..afb7f0ffed 100644
--- a/ext/native/native.vcxproj
+++ b/ext/native/native.vcxproj
@@ -387,7 +387,6 @@
-
@@ -496,7 +495,6 @@
-
true
true
@@ -1217,4 +1215,4 @@
-
\ No newline at end of file
+
diff --git a/libretro/Makefile.common b/libretro/Makefile.common
index 1a347a8acb..c4ac5d2f4e 100644
--- a/libretro/Makefile.common
+++ b/libretro/Makefile.common
@@ -215,7 +215,6 @@ SOURCES_CXX += \
$(EXTDIR)/native/base/buffer.cpp \
$(EXTDIR)/native/base/colorutil.cpp \
$(EXTDIR)/native/base/display.cpp \
- $(EXTDIR)/native/base/logging.cpp \
$(EXTDIR)/native/base/stringutil.cpp \
$(EXTDIR)/native/base/timeutil.cpp \
$(EXTDIR)/native/data/compression.cpp \