mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 15:41:00 -05:00
Add --loglevel argument for command line log level control
Introduce support for setting the application's log level via a new --loglevel command line argument. Log level is parsed early in initialization and can be set to DISABLED, ERROR, WARNING, INFO, or DEBUG (case-insensitive). The RILogLevel enum now includes a DISABLED value. Logger initialization in both console and GUI applications now respects the command line log level if provided, otherwise defaults to preference-based settings. Fixes by clang-format
This commit is contained in:
1 parent
fde113259a
commit
30793beef2
7 files changed
+81
-7
No files matched your search
@@ -242,6 +242,26 @@ RILogLevel RiaLogging::logLevelBasedOnPreferences()
|
||||
return RILogLevel::RI_LL_INFO;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Parse a log level string and return the corresponding enum value
|
||||
/// @param logLevelString The string to parse (case-insensitive, whitespace is trimmed)
|
||||
/// @return The corresponding RILogLevel enum value, or std::nullopt if the string is invalid
|
||||
/// Valid values are: DISABLED, ERROR, WARNING, INFO, DEBUG
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::optional<RILogLevel> RiaLogging::parseLogLevelString( const QString& logLevelString )
|
||||
{
|
||||
QString upperString = logLevelString.toUpper().trimmed();
|
||||
|
||||
if ( upperString == "DISABLED" ) return RILogLevel::RI_LL_DISABLED;
|
||||
if ( upperString == "ERROR" ) return RILogLevel::RI_LL_ERROR;
|
||||
if ( upperString == "WARNING" ) return RILogLevel::RI_LL_WARNING;
|
||||
if ( upperString == "INFO" ) return RILogLevel::RI_LL_INFO;
|
||||
if ( upperString == "DEBUG" ) return RILogLevel::RI_LL_DEBUG;
|
||||
|
||||
// Return nullopt for invalid input
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user