mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Support max log level for Recast via env variable
Do not write to log if log message level is greater than one speficied in the OPENMW_RECAST_MAX_LOG_LEVEL env variable. Use Error by default.
This commit is contained in:
parent
057c85b710
commit
51258662b5
13 changed files with 68 additions and 35 deletions
|
@ -324,6 +324,22 @@ namespace Debug
|
|||
First mFirst;
|
||||
Second mSecond;
|
||||
};
|
||||
|
||||
Level toLevel(std::string_view value)
|
||||
{
|
||||
if (value == "ERROR")
|
||||
return Error;
|
||||
if (value == "WARNING")
|
||||
return Warning;
|
||||
if (value == "INFO")
|
||||
return Info;
|
||||
if (value == "VERBOSE")
|
||||
return Verbose;
|
||||
if (value == "DEBUG")
|
||||
return Debug;
|
||||
|
||||
return Verbose;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -359,23 +375,19 @@ namespace Debug
|
|||
Level getDebugLevel()
|
||||
{
|
||||
if (const char* env = getenv("OPENMW_DEBUG_LEVEL"))
|
||||
{
|
||||
const std::string_view value(env);
|
||||
if (value == "ERROR")
|
||||
return Error;
|
||||
if (value == "WARNING")
|
||||
return Warning;
|
||||
if (value == "INFO")
|
||||
return Info;
|
||||
if (value == "VERBOSE")
|
||||
return Verbose;
|
||||
if (value == "DEBUG")
|
||||
return Debug;
|
||||
}
|
||||
return toLevel(env);
|
||||
|
||||
return Verbose;
|
||||
}
|
||||
|
||||
Level getRecastMaxLogLevel()
|
||||
{
|
||||
if (const char* env = getenv("OPENMW_RECAST_MAX_LOG_LEVEL"))
|
||||
return toLevel(env);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
void setupLogging(const std::filesystem::path& logDir, std::string_view appName)
|
||||
{
|
||||
Log::sMinDebugLevel = getDebugLevel();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue