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

+27 -27
View File
@@ -66,7 +66,7 @@ void PortManager::Shutdown() {
}
void PortManager::Terminate() {
VERBOSE_LOG(SCENET, "PortManager::Terminate()");
VERBOSE_LOG(Log::sceNet, "PortManager::Terminate()");
if (urls) {
#ifdef WITH_UPNP
FreeUPNPUrls(urls);
@@ -100,9 +100,9 @@ bool PortManager::Initialize(const unsigned int timeout) {
unsigned char ttl = 2; // defaulting to 2
int error = 0;
VERBOSE_LOG(SCENET, "PortManager::Initialize(%d)", timeout);
VERBOSE_LOG(Log::sceNet, "PortManager::Initialize(%d)", timeout);
if (!g_Config.bEnableUPnP) {
ERROR_LOG(SCENET, "PortManager::Initialize - UPnP is Disabled on Networking Settings");
ERROR_LOG(Log::sceNet, "PortManager::Initialize - UPnP is Disabled on Networking Settings");
return false;
}
@@ -110,12 +110,12 @@ bool PortManager::Initialize(const unsigned int timeout) {
switch (m_InitState)
{
case UPNP_INITSTATE_BUSY: {
WARN_LOG(SCENET, "PortManager - Initialization already in progress");
WARN_LOG(Log::sceNet, "PortManager - Initialization already in progress");
return false;
}
// Should we redetect UPnP? just in case the player switched to a different network in the middle
case UPNP_INITSTATE_DONE: {
WARN_LOG(SCENET, "PortManager - Already Initialized");
WARN_LOG(Log::sceNet, "PortManager - Already Initialized");
return true;
}
default:
@@ -149,7 +149,7 @@ bool PortManager::Initialize(const unsigned int timeout) {
if (!dev)
dev = devlist; // defaulting to first device
INFO_LOG(SCENET, "PortManager - UPnP device: [desc: %s] [st: %s]", dev->descURL, dev->st);
INFO_LOG(Log::sceNet, "PortManager - UPnP device: [desc: %s] [st: %s]", dev->descURL, dev->st);
descXML = (char*)miniwget(dev->descURL, &descXMLsize, dev->scope_id, &descXMLstatus);
if (descXML)
@@ -163,15 +163,15 @@ bool PortManager::Initialize(const unsigned int timeout) {
char lanaddr[64] = "unset";
int status = UPNP_GetValidIGD(devlist, urls, datas, lanaddr, sizeof(lanaddr), nullptr, 0); //possible "status" values, 0 = NO IGD found, 1 = A valid connected IGD has been found, 2 = A valid IGD has been found but it reported as not connected, 3 = an UPnP device has been found but was not recognized as an IGD
m_lanip = std::string(lanaddr);
INFO_LOG(SCENET, "PortManager - Detected LAN IP: %s", m_lanip.c_str());
INFO_LOG(Log::sceNet, "PortManager - Detected LAN IP: %s", m_lanip.c_str());
// Additional Info
char connectionType[64] = "";
if (UPNP_GetConnectionTypeInfo(urls->controlURL, datas->first.servicetype, connectionType) != UPNPCOMMAND_SUCCESS) {
WARN_LOG(SCENET, "PortManager - GetConnectionTypeInfo failed");
WARN_LOG(Log::sceNet, "PortManager - GetConnectionTypeInfo failed");
}
else {
INFO_LOG(SCENET, "PortManager - Connection Type: %s", connectionType);
INFO_LOG(Log::sceNet, "PortManager - Connection Type: %s", connectionType);
}
// Using Game ID & Player Name as default description for mapping
@@ -186,7 +186,7 @@ bool PortManager::Initialize(const unsigned int timeout) {
return true;
}
ERROR_LOG(SCENET, "PortManager - upnpDiscover failed (error: %i) or No UPnP device detected", error);
ERROR_LOG(Log::sceNet, "PortManager - upnpDiscover failed (error: %i) or No UPnP device detected", error);
if (g_Config.bEnableUPnP) {
auto n = GetI18NCategory(I18NCat::NETWORKING);
g_OSD.Show(OSDType::MESSAGE_ERROR, n->T("Unable to find UPnP device"));
@@ -209,11 +209,11 @@ bool PortManager::Add(const char* protocol, unsigned short port, unsigned short
if (intport == 0)
intport = port;
INFO_LOG(SCENET, "PortManager::Add(%s, %d, %d)", protocol, port, intport);
INFO_LOG(Log::sceNet, "PortManager::Add(%s, %d, %d)", protocol, port, intport);
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
{
if (g_Config.bEnableUPnP) {
WARN_LOG(SCENET, "PortManager::Add - the init was not done !");
WARN_LOG(Log::sceNet, "PortManager::Add - the init was not done !");
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
}
Terminate();
@@ -241,7 +241,7 @@ bool PortManager::Add(const char* protocol, unsigned short port, unsigned short
}
if (r != 0)
{
ERROR_LOG(SCENET, "PortManager - AddPortMapping failed (error: %i)", r);
ERROR_LOG(Log::sceNet, "PortManager - AddPortMapping failed (error: %i)", r);
if (r == UPNPCOMMAND_HTTP_ERROR) {
if (g_Config.bEnableUPnP) {
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
@@ -265,11 +265,11 @@ bool PortManager::Remove(const char* protocol, unsigned short port) {
char port_str[16];
auto n = GetI18NCategory(I18NCat::NETWORKING);
INFO_LOG(SCENET, "PortManager::Remove(%s, %d)", protocol, port);
INFO_LOG(Log::sceNet, "PortManager::Remove(%s, %d)", protocol, port);
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
{
if (g_Config.bEnableUPnP) {
WARN_LOG(SCENET, "PortManager::Remove - the init was not done !");
WARN_LOG(Log::sceNet, "PortManager::Remove - the init was not done !");
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
}
Terminate();
@@ -279,7 +279,7 @@ bool PortManager::Remove(const char* protocol, unsigned short port) {
int r = UPNP_DeletePortMapping(urls->controlURL, datas->first.servicetype, port_str, protocol, NULL);
if (r != 0)
{
ERROR_LOG(SCENET, "PortManager - DeletePortMapping failed (error: %i)", r);
ERROR_LOG(Log::sceNet, "PortManager - DeletePortMapping failed (error: %i)", r);
if (r == UPNPCOMMAND_HTTP_ERROR) {
if (g_Config.bEnableUPnP) {
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("UPnP need to be reinitialized"));
@@ -300,10 +300,10 @@ bool PortManager::Remove(const char* protocol, unsigned short port) {
bool PortManager::Restore() {
#ifdef WITH_UPNP
int r;
VERBOSE_LOG(SCENET, "PortManager::Restore()");
VERBOSE_LOG(Log::sceNet, "PortManager::Restore()");
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
{
if (g_Config.bEnableUPnP) WARN_LOG(SCENET, "PortManager::Remove - the init was not done !");
if (g_Config.bEnableUPnP) WARN_LOG(Log::sceNet, "PortManager::Remove - the init was not done !");
return false;
}
for (auto it = m_otherPortList.begin(); it != m_otherPortList.end(); ++it) {
@@ -319,7 +319,7 @@ bool PortManager::Restore() {
m_portList.erase(el_it);
}
else {
ERROR_LOG(SCENET, "PortManager::Restore - DeletePortMapping failed (error: %i)", r);
ERROR_LOG(Log::sceNet, "PortManager::Restore - DeletePortMapping failed (error: %i)", r);
if (r == UPNPCOMMAND_HTTP_ERROR)
return false; // Might be better not to exit here, but exiting a loop will avoid long timeouts in the case the router is no longer reachable
}
@@ -331,7 +331,7 @@ bool PortManager::Restore() {
it->taken = false;
}
else {
ERROR_LOG(SCENET, "PortManager::Restore - AddPortMapping failed (error: %i)", r);
ERROR_LOG(Log::sceNet, "PortManager::Restore - AddPortMapping failed (error: %i)", r);
if (r == UPNPCOMMAND_HTTP_ERROR)
return false; // Might be better not to exit here, but exiting a loop will avoid long timeouts in the case the router is no longer reachable
}
@@ -357,10 +357,10 @@ bool PortManager::Clear() {
char rHost[64];
char duration[16];
VERBOSE_LOG(SCENET, "PortManager::Clear()");
VERBOSE_LOG(Log::sceNet, "PortManager::Clear()");
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
{
if (g_Config.bEnableUPnP) WARN_LOG(SCENET, "PortManager::Clear - the init was not done !");
if (g_Config.bEnableUPnP) WARN_LOG(Log::sceNet, "PortManager::Clear - the init was not done !");
return false;
}
//unsigned int num = 0;
@@ -382,7 +382,7 @@ bool PortManager::Clear() {
int r2 = UPNP_DeletePortMapping(urls->controlURL, datas->first.servicetype, extPort, protocol, rHost);
if (r2 != 0)
{
ERROR_LOG(SCENET, "PortManager::Clear - DeletePortMapping(%s, %s) failed (error: %i)", extPort, protocol, r2);
ERROR_LOG(Log::sceNet, "PortManager::Clear - DeletePortMapping(%s, %s) failed (error: %i)", extPort, protocol, r2);
if (r2 == UPNPCOMMAND_HTTP_ERROR)
return false;
}
@@ -415,10 +415,10 @@ bool PortManager::RefreshPortList() {
char rHost[64];
char duration[16];
INFO_LOG(SCENET, "PortManager::RefreshPortList()");
INFO_LOG(Log::sceNet, "PortManager::RefreshPortList()");
if (urls == NULL || urls->controlURL == NULL || urls->controlURL[0] == '\0')
{
if (g_Config.bEnableUPnP) WARN_LOG(SCENET, "PortManager::RefreshPortList - the init was not done !");
if (g_Config.bEnableUPnP) WARN_LOG(Log::sceNet, "PortManager::RefreshPortList - the init was not done !");
return false;
}
m_portList.clear();
@@ -461,7 +461,7 @@ bool PortManager::RefreshPortList() {
int upnpService(const unsigned int timeout)
{
SetCurrentThreadName("UPnPService");
INFO_LOG(SCENET, "UPnPService: Begin of UPnPService Thread");
INFO_LOG(Log::sceNet, "UPnPService: Begin of UPnPService Thread");
// Service Loop
while (upnpServiceRunning && coreState != CORE_POWERDOWN) {
@@ -509,7 +509,7 @@ int upnpService(const unsigned int timeout)
upnpReqs.clear();
upnpLock.unlock();
INFO_LOG(SCENET, "UPnPService: End of UPnPService Thread");
INFO_LOG(Log::sceNet, "UPnPService: End of UPnPService Thread");
return 0;
}