Rework the log manager to be more robust

This commit is contained in:
Henrik Rydgård committed 2024-12-16 12:33:58 +01:00
1 parent 4a861dfdbe
commit 96cab3f267
17 files changed
+341 -403

No files matched your search

+3 -35
View File
@@ -193,32 +193,7 @@ WindowsAudioBackend *winAudioBackend;
std::thread *graphicsLoadThread;
class PrintfLogger : public LogListener {
public:
void Log(const LogMessage &message) override {
// Log with simplified headers as Android already provides timestamp etc.
switch (message.level) {
case LogLevel::LVERBOSE:
case LogLevel::LDEBUG:
case LogLevel::LINFO:
printf("INFO [%s] %s", message.log, message.msg.c_str());
break;
case LogLevel::LERROR:
printf("ERR [%s] %s", message.log, message.msg.c_str());
break;
case LogLevel::LWARNING:
printf("WARN [%s] %s", message.log, message.msg.c_str());
break;
case LogLevel::LNOTICE:
default:
printf("NOTE [%s] !!! %s", message.log, message.msg.c_str());
break;
}
}
};
// globals
static LogListener *logger = nullptr;
Path boot_filename;
int NativeMix(short *audio, int numSamples, int sampleRateHz) {
@@ -670,7 +645,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
}
if (fileToLog)
g_logManager.ChangeFileLog(fileToLog);
g_logManager.ChangeFileLog(Path(fileToLog));
if (forceLogLevel)
g_logManager.SetAllLogLevels(logLevel);
@@ -678,13 +653,11 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
PostLoadConfig();
#if PPSSPP_PLATFORM(ANDROID)
logger = new AndroidLogger();
g_logManager.AddListener(logger);
g_logManager.EnableOutput(LogOutput::Android);
#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 PrintfLogger();
g_logManager.AddListener(logger);
g_logManager.EnableOutput(LogOutput::Printf);
#endif
if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) {
@@ -1489,11 +1462,6 @@ void NativeShutdown() {
if (!restarting)
g_logManager.Shutdown();
if (logger) {
delete logger;
logger = nullptr;
}
g_threadManager.Teardown();
#if !(PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS))