LOG: def + include fixes
Some checks failed
Build ES-DE / Building_RetroDECK-ES-DE (push) Has been cancelled

This commit is contained in:
XargonWan 2024-11-29 21:56:12 +09:00
parent 1a1d70ce9f
commit 330dd1d647
2 changed files with 12 additions and 4 deletions

View file

@ -11,6 +11,10 @@
#include "Settings.h" #include "Settings.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#if defined(RETRODECK)
#include <algorithm>
#endif
LogLevel Log::getReportingLevel() LogLevel Log::getReportingLevel()
{ {
std::unique_lock<std::mutex> lock {sLogMutex}; std::unique_lock<std::mutex> lock {sLogMutex};
@ -25,7 +29,7 @@ void Log::setReportingLevel(LogLevel level)
void Log::init() void Log::init()
{ {
#if defined(RetroDECK) #if defined(RETRODECK)
// Check for the rd_logs_folder environment variable // Check for the rd_logs_folder environment variable
const char* logFolder = std::getenv("rd_logs_folder"); const char* logFolder = std::getenv("rd_logs_folder");
if (logFolder && std::strlen(logFolder) > 0) if (logFolder && std::strlen(logFolder) > 0)
@ -86,7 +90,7 @@ std::ostringstream& Log::get(LogLevel level)
#endif #endif
std::unique_lock<std::mutex> lock {sLogMutex}; std::unique_lock<std::mutex> lock {sLogMutex};
#if defined(RetroDECK) #if defined(RETRODECK)
// Convert log level to uppercase for RetroDECK // Convert log level to uppercase for RetroDECK
std::string levelUpper = mLogLevelMap[level]; std::string levelUpper = mLogLevelMap[level];
std::transform(levelUpper.begin(), levelUpper.end(), levelUpper.begin(), ::toupper); std::transform(levelUpper.begin(), levelUpper.end(), levelUpper.begin(), ::toupper);
@ -149,14 +153,14 @@ Log::~Log()
std::cerr << mOutStringStream.str(); std::cerr << mOutStringStream.str();
#endif #endif
#if defined(RetroDECK) #if defined(RETRODECK)
// Always write logs to the terminal as well when RetroDECK is defined // Always write logs to the terminal as well when RetroDECK is defined
std::cout << mOutStringStream.str(); std::cout << mOutStringStream.str();
#endif #endif
} }
// RetroDECK specific function // RetroDECK specific function
#if defined(RetroDECK) #if defined(RETRODECK)
void Log::setReportingLevelFromEnv() void Log::setReportingLevelFromEnv()
{ {
// Check for the logging_level environment variable // Check for the logging_level environment variable

View file

@ -53,6 +53,10 @@ public:
static void flush(); static void flush();
static void close(); static void close();
#if defined(RETRODECK)
static void setReportingLevelFromEnv();
#endif
protected: protected:
std::ostringstream mOutStringStream; std::ostringstream mOutStringStream;