Logging API change (refactor) (#19324)

* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2024-07-14 14:42:59 +02:00
1 parent ae3ff686f0
commit e01ca5b057
393 files changed
+6198 -6193

No files matched your search

+38 -38
View File
@@ -284,7 +284,7 @@ void PostLoadConfig() {
static void CheckFailedGPUBackends() {
#ifdef _DEBUG
// If you're in debug mode, you probably don't want a fallback. If you're in release mode, use IGNORE below.
NOTICE_LOG(LOADER, "Not checking for failed graphics backends in debug mode");
NOTICE_LOG(Log::Loader, "Not checking for failed graphics backends in debug mode");
return;
#endif
@@ -317,14 +317,14 @@ static void CheckFailedGPUBackends() {
if (g_Config.sFailedGPUBackends == "IGNORE")
return;
else if (!g_Config.sFailedGPUBackends.empty())
ERROR_LOG(LOADER, "Failed graphics backends: %s", g_Config.sFailedGPUBackends.c_str());
ERROR_LOG(Log::Loader, "Failed graphics backends: %s", g_Config.sFailedGPUBackends.c_str());
// Okay, let's not try a backend in the failed list.
g_Config.iGPUBackend = g_Config.NextValidBackend();
if (lastBackend != g_Config.iGPUBackend) {
std::string param = GPUBackendToString((GPUBackend)lastBackend) + " -> " + GPUBackendToString((GPUBackend)g_Config.iGPUBackend);
System_GraphicsBackendFailedAlert(param);
WARN_LOG(LOADER, "Failed graphics backend switched from %s (%d to %d)", param.c_str(), lastBackend, g_Config.iGPUBackend);
WARN_LOG(Log::Loader, "Failed graphics backend switched from %s (%d to %d)", param.c_str(), lastBackend, g_Config.iGPUBackend);
}
// And then let's - for now - add the current to the failed list.
if (g_Config.sFailedGPUBackends.empty()) {
@@ -431,24 +431,24 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
Path memstickDirFile = g_Config.internalDataDirectory / "memstick_dir.txt";
if (File::Exists(memstickDirFile)) {
INFO_LOG(SYSTEM, "Reading '%s' to find memstick dir.", memstickDirFile.c_str());
INFO_LOG(Log::System, "Reading '%s' to find memstick dir.", memstickDirFile.c_str());
std::string memstickDir;
if (File::ReadTextFileToString(memstickDirFile, &memstickDir)) {
Path memstickPath(memstickDir);
if (!memstickPath.empty() && File::Exists(memstickPath)) {
g_Config.memStickDirectory = memstickPath;
INFO_LOG(SYSTEM, "Memstick Directory from memstick_dir.txt: '%s'", g_Config.memStickDirectory.c_str());
INFO_LOG(Log::System, "Memstick Directory from memstick_dir.txt: '%s'", g_Config.memStickDirectory.c_str());
} else {
ERROR_LOG(SYSTEM, "Couldn't read directory '%s' specified by memstick_dir.txt.", memstickDir.c_str());
ERROR_LOG(Log::System, "Couldn't read directory '%s' specified by memstick_dir.txt.", memstickDir.c_str());
if (System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) {
// Ask the user to configure a memstick directory.
INFO_LOG(SYSTEM, "Asking the user.");
INFO_LOG(Log::System, "Asking the user.");
g_Config.memStickDirectory.clear();
}
}
}
} else {
INFO_LOG(SYSTEM, "No memstick directory file found (tried to open '%s')", memstickDirFile.c_str());
INFO_LOG(Log::System, "No memstick directory file found (tried to open '%s')", memstickDirFile.c_str());
}
// Attempt to create directories after reading the path.
@@ -458,7 +458,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
#elif PPSSPP_PLATFORM(UWP) && !defined(__LIBRETRO__)
Path memstickDirFile = g_Config.internalDataDirectory / "memstick_dir.txt";
if (File::Exists(memstickDirFile)) {
INFO_LOG(SYSTEM, "Reading '%s' to find memstick dir.", memstickDirFile.c_str());
INFO_LOG(Log::System, "Reading '%s' to find memstick dir.", memstickDirFile.c_str());
std::string memstickDir;
if (File::ReadTextFileToString(memstickDirFile, &memstickDir)) {
Path memstickPath(memstickDir);
@@ -466,15 +466,15 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
g_Config.memStickDirectory = memstickPath;
g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.Reload();
INFO_LOG(SYSTEM, "Memstick Directory from memstick_dir.txt: '%s'", g_Config.memStickDirectory.c_str());
INFO_LOG(Log::System, "Memstick Directory from memstick_dir.txt: '%s'", g_Config.memStickDirectory.c_str());
} else {
ERROR_LOG(SYSTEM, "Couldn't read directory '%s' specified by memstick_dir.txt.", memstickDir.c_str());
ERROR_LOG(Log::System, "Couldn't read directory '%s' specified by memstick_dir.txt.", memstickDir.c_str());
g_Config.memStickDirectory.clear();
}
}
}
else {
INFO_LOG(SYSTEM, "No memstick directory file found (tried to open '%s')", memstickDirFile.c_str());
INFO_LOG(Log::System, "No memstick directory file found (tried to open '%s')", memstickDirFile.c_str());
}
#elif PPSSPP_PLATFORM(IOS)
g_Config.defaultCurrentDirectory = g_Config.internalDataDirectory;
@@ -618,21 +618,21 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
// don't already have one.
if (!gotBootFilename) {
gotBootFilename = true;
INFO_LOG(SYSTEM, "Boot filename found in args: '%s'", argv[i]);
INFO_LOG(Log::System, "Boot filename found in args: '%s'", argv[i]);
bool okToLoad = true;
bool okToCheck = true;
if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) {
PermissionStatus status = System_GetPermissionStatus(SYSTEM_PERMISSION_STORAGE);
if (status == PERMISSION_STATUS_DENIED) {
ERROR_LOG(IO, "Storage permission denied. Launching without argument.");
ERROR_LOG(Log::IO, "Storage permission denied. Launching without argument.");
okToLoad = false;
okToCheck = false;
} else if (status != PERMISSION_STATUS_GRANTED) {
ERROR_LOG(IO, "Storage permission not granted. Launching without argument check.");
ERROR_LOG(Log::IO, "Storage permission not granted. Launching without argument check.");
okToCheck = false;
} else {
INFO_LOG(IO, "Storage permission granted.");
INFO_LOG(Log::IO, "Storage permission granted.");
}
}
if (okToLoad) {
@@ -640,7 +640,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
// Handle file:/// URIs, since you get those when creating shortcuts on some Android systems.
if (startsWith(str, "file:///")) {
str = UriDecode(str.substr(7));
INFO_LOG(IO, "Decoding '%s' to '%s'", argv[i], str.c_str());
INFO_LOG(Log::IO, "Decoding '%s' to '%s'", argv[i], str.c_str());
}
boot_filename = Path(str);
@@ -749,10 +749,10 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
}
}
DEBUG_LOG(SYSTEM, "ScreenManager!");
DEBUG_LOG(Log::System, "ScreenManager!");
g_screenManager = new ScreenManager();
if (g_Config.memStickDirectory.empty()) {
INFO_LOG(SYSTEM, "No memstick directory! Asking for one to be configured.");
INFO_LOG(Log::System, "No memstick directory! Asking for one to be configured.");
g_screenManager->switchScreen(new LogoScreen(AfterLogoScreen::MEMSTICK_SCREEN_INITIAL_SETUP));
} else if (gotoGameSettings) {
g_screenManager->switchScreen(new LogoScreen(AfterLogoScreen::TO_GAME_SETTINGS));
@@ -800,7 +800,7 @@ void CallbackPostRender(UIContext *dc, void *userdata);
bool CreateGlobalPipelines();
bool NativeInitGraphics(GraphicsContext *graphicsContext) {
INFO_LOG(SYSTEM, "NativeInitGraphics");
INFO_LOG(Log::System, "NativeInitGraphics");
_assert_msg_(g_screenManager, "No screenmanager, bad init order. Backend = %d", g_Config.iGPUBackend);
@@ -813,7 +813,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
_assert_(g_draw);
if (!CreateGlobalPipelines()) {
ERROR_LOG(G3D, "Failed to create global pipelines");
ERROR_LOG(Log::G3D, "Failed to create global pipelines");
return false;
}
@@ -848,7 +848,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
if (IsWin7OrHigher()) {
winCamera = new WindowsCaptureDevice(CAPTUREDEVIDE_TYPE::VIDEO);
winCamera->sendMessage({ CAPTUREDEVIDE_COMMAND::INITIALIZE, nullptr });
winMic = new WindowsCaptureDevice(CAPTUREDEVIDE_TYPE::AUDIO);
winMic = new WindowsCaptureDevice(CAPTUREDEVIDE_TYPE::Audio);
winMic->sendMessage({ CAPTUREDEVIDE_COMMAND::INITIALIZE, nullptr });
}
#endif
@@ -861,7 +861,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
gpu->DeviceRestore(g_draw);
}
INFO_LOG(SYSTEM, "NativeInitGraphics completed");
INFO_LOG(Log::System, "NativeInitGraphics completed");
return true;
}
@@ -875,7 +875,7 @@ bool CreateGlobalPipelines() {
ShaderModule *fs_texture_color_2d = g_draw->GetFshaderPreset(FS_TEXTURE_COLOR_2D);
if (!vs_color_2d || !fs_color_2d || !vs_texture_color_2d || !fs_texture_color_2d) {
ERROR_LOG(G3D, "Failed to get shader preset");
ERROR_LOG(Log::G3D, "Failed to get shader preset");
return false;
}
@@ -917,7 +917,7 @@ bool CreateGlobalPipelines() {
}
void NativeShutdownGraphics() {
INFO_LOG(SYSTEM, "NativeShutdownGraphics");
INFO_LOG(Log::System, "NativeShutdownGraphics");
if (g_screenManager) {
g_screenManager->deviceLost();
@@ -965,7 +965,7 @@ void NativeShutdownGraphics() {
texColorPipeline = nullptr;
}
INFO_LOG(SYSTEM, "NativeShutdownGraphics done");
INFO_LOG(Log::System, "NativeShutdownGraphics done");
}
static void TakeScreenshot(Draw::DrawContext *draw) {
@@ -1108,7 +1108,7 @@ void NativeFrame(GraphicsContext *graphicsContext) {
for (const auto &item : toProcess) {
if (HandleGlobalMessage(item.message, item.value)) {
// TODO: Add a to-string thingy.
INFO_LOG(SYSTEM, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
INFO_LOG(Log::System, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
}
g_screenManager->sendMessage(item.message, item.value.c_str());
}
@@ -1157,7 +1157,7 @@ void NativeFrame(GraphicsContext *graphicsContext) {
g_draw->Present(presentMode, interval);
if (resized) {
INFO_LOG(G3D, "Resized flag set - recalculating bounds");
INFO_LOG(Log::G3D, "Resized flag set - recalculating bounds");
resized = false;
if (uiContext) {
@@ -1184,7 +1184,7 @@ void NativeFrame(GraphicsContext *graphicsContext) {
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
#endif
} else {
// INFO_LOG(G3D, "Polling graphics context");
// INFO_LOG(Log::G3D, "Polling graphics context");
graphicsContext->Poll();
}
@@ -1254,7 +1254,7 @@ bool HandleGlobalMessage(UIMessage message, const std::string &value) {
// and then getting permission), it will get out of sync. So we save and restore g_Config.iGPUBackend.
// Ideally we should simply reinitialize graphics to the mode from the config, but there are potential issues.
int gpuBackend = g_Config.iGPUBackend;
INFO_LOG(IO, "Reloading config after storage permission grant.");
INFO_LOG(Log::IO, "Reloading config after storage permission grant.");
g_Config.Reload();
PostLoadConfig();
g_Config.iGPUBackend = gpuBackend;
@@ -1271,16 +1271,16 @@ bool HandleGlobalMessage(UIMessage message, const std::string &value) {
bool NativeIsAtTopLevel() {
// This might need some synchronization?
if (!g_screenManager) {
ERROR_LOG(SYSTEM, "No screen manager active");
ERROR_LOG(Log::System, "No screen manager active");
return false;
}
Screen *currentScreen = g_screenManager->topScreen();
if (currentScreen) {
bool top = currentScreen->isTopLevel();
INFO_LOG(SYSTEM, "Screen toplevel: %i", (int)top);
INFO_LOG(Log::System, "Screen toplevel: %i", (int)top);
return currentScreen->isTopLevel();
} else {
ERROR_LOG(SYSTEM, "No current screen");
ERROR_LOG(Log::System, "No current screen");
return false;
}
}
@@ -1334,7 +1334,7 @@ bool NativeKey(const KeyInput &key) {
}
#endif
// INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags);
// INFO_LOG(Log::System, "Key code: %i flags: %i", key.keyCode, key.flags);
#if !defined(MOBILE_DEVICE)
if (g_Config.bPauseExitsEmulator) {
std::vector<int> pspKeys;
@@ -1405,7 +1405,7 @@ static void SendMouseDeltaAxis() {
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = mx;
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = my;
//NOTICE_LOG(SYSTEM, "delta: %0.2f %0.2f mx/my: %0.2f %0.2f dpi: %f sens: %f ",
//NOTICE_LOG(Log::System, "delta: %0.2f %0.2f mx/my: %0.2f %0.2f dpi: %f sens: %f ",
// g_mouseDeltaX, g_mouseDeltaY, mx, my, g_display.dpi_scale_x, g_Config.fMouseSensitivity);
if (GetUIState() == UISTATE_INGAME || g_Config.bMapMouse) {
@@ -1465,7 +1465,7 @@ void System_PostUIMessage(UIMessage message, const std::string &value) {
void NativeResized() {
// NativeResized can come from any thread so we just set a flag, then process it later.
VERBOSE_LOG(G3D, "NativeResized - setting flag");
VERBOSE_LOG(Log::G3D, "NativeResized - setting flag");
resized = true;
}
@@ -1496,7 +1496,7 @@ void NativeShutdown() {
g_Config.Save("NativeShutdown");
INFO_LOG(SYSTEM, "NativeShutdown called");
INFO_LOG(Log::System, "NativeShutdown called");
g_i18nrepo.LogMissingKeys();
@@ -1544,7 +1544,7 @@ static Path GetSecretPath(const char *nameOfSecret) {
bool NativeSaveSecret(const char *nameOfSecret, const std::string &data) {
Path path = GetSecretPath(nameOfSecret);
if (!File::WriteDataToFile(false, data.data(), data.size(), path)) {
WARN_LOG(SYSTEM, "Failed to write secret '%s' to path '%s'", nameOfSecret, path.c_str());
WARN_LOG(Log::System, "Failed to write secret '%s' to path '%s'", nameOfSecret, path.c_str());
return false;
}
return true;