Log level/type: Use enum class instead of the awkward namespace trick.

Just a small cleanup I've wanted to do for a long time.
This commit is contained in:
Henrik Rydgård 2023-08-25 11:33:48 +02:00
parent 308e983a99
commit 1025bbcf89
19 changed files with 162 additions and 170 deletions

View file

@ -188,18 +188,18 @@ public:
void Log(const LogMessage &message) override {
// Log with simplified headers as Android already provides timestamp etc.
switch (message.level) {
case LogTypes::LVERBOSE:
case LogTypes::LDEBUG:
case LogTypes::LINFO:
case LogLevel::LVERBOSE:
case LogLevel::LDEBUG:
case LogLevel::LINFO:
printf("INFO [%s] %s", message.log, message.msg.c_str());
break;
case LogTypes::LERROR:
case LogLevel::LERROR:
printf("ERR [%s] %s", message.log, message.msg.c_str());
break;
case LogTypes::LWARNING:
case LogLevel::LWARNING:
printf("WARN [%s] %s", message.log, message.msg.c_str());
break;
case LogTypes::LNOTICE:
case LogLevel::LNOTICE:
default:
printf("NOTE [%s] !!! %s", message.log, message.msg.c_str());
break;
@ -567,9 +567,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
boot_filename.clear();
// Parse command line
LogTypes::LOG_LEVELS logLevel = LogTypes::LINFO;
LogLevel logLevel = LogLevel::LINFO;
bool forceLogLevel = false;
const auto setLogLevel = [&logLevel, &forceLogLevel](LogTypes::LOG_LEVELS level) {
const auto setLogLevel = [&logLevel, &forceLogLevel](LogLevel level) {
logLevel = level;
forceLogLevel = true;
};
@ -587,12 +587,12 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
case 'd':
// Enable debug logging
// Note that you must also change the max log level in Log.h.
setLogLevel(LogTypes::LDEBUG);
setLogLevel(LogLevel::LDEBUG);
break;
case 'v':
// Enable verbose logging
// Note that you must also change the max log level in Log.h.
setLogLevel(LogTypes::LVERBOSE);
setLogLevel(LogLevel::LVERBOSE);
break;
case 'j':
g_Config.iCpuCore = (int)CPUCore::JIT;
@ -612,7 +612,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
break;
case '-':
if (!strncmp(argv[i], "--loglevel=", strlen("--loglevel=")) && strlen(argv[i]) > strlen("--loglevel="))
setLogLevel(static_cast<LogTypes::LOG_LEVELS>(std::atoi(argv[i] + strlen("--loglevel="))));
setLogLevel(static_cast<LogLevel>(std::atoi(argv[i] + strlen("--loglevel="))));
if (!strncmp(argv[i], "--log=", strlen("--log=")) && strlen(argv[i]) > strlen("--log="))
fileToLog = argv[i] + strlen("--log=");
if (!strncmp(argv[i], "--state=", strlen("--state=")) && strlen(argv[i]) > strlen("--state="))