From 363e003dffe76f6aaa085231a1b57c6e11936775 Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Sat, 20 May 2023 21:27:00 +0300 Subject: [PATCH] add LogLevel parsing --- StartWave/Classes/OptionsParser.uc | 32 ++++++++++++------ StartWave/Classes/_Logger.uc | 54 ++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/StartWave/Classes/OptionsParser.uc b/StartWave/Classes/OptionsParser.uc index 404cbf7..9569850 100644 --- a/StartWave/Classes/OptionsParser.uc +++ b/StartWave/Classes/OptionsParser.uc @@ -10,7 +10,7 @@ const GameInfo = class'GameInfo'; *** @param CurrentValue - the current value of the variable *** @return int value of the option we are looking for ***/ -static function int GetIntOption( string Options, string ParseString, int CurrentValue) +static function int GetIntOption( String Options, String ParseString, int CurrentValue) { return GameInfo.static.GetIntOption(Options, ParseString, CurrentValue); } @@ -23,14 +23,14 @@ static function int GetIntOption( string Options, string ParseString, int Curren *** @param CurrentValue - the current value of the variable *** @return bool value of the option we are looking for ***/ -static public function bool GetBoolOption(string Options, string ParseString, bool CurrentValue) +static public function bool GetBoolOption(String Options, String ParseString, bool CurrentValue) { - local string InOpt; + local String InOpt; //Find the value associated with this variable in the launch command. InOpt = GameInfo.static.ParseOption(Options, ParseString); - if(InOpt != "") + if (InOpt != "") { return bool(InOpt); } @@ -40,21 +40,21 @@ static public function bool GetBoolOption(string Options, string ParseString, bo } /** -*** @brief Gets a string from the launch command if available. +*** @brief Gets a String from the launch command if available. *** *** @param Options - options passed in via the launch command *** @param ParseString - the variable we are looking for *** @param CurrentValue - the current value of the variable -*** @return string value of the option we are looking for +*** @return String value of the option we are looking for ***/ -static public function string GetStringOption(string Options, string ParseString, string CurrentValue) +static public function String GetStringOption(String Options, String ParseString, String CurrentValue) { - local string InOpt; + local String InOpt; //Find the value associated with this variable in the launch command. InOpt = GameInfo.static.ParseOption(Options, ParseString); - if(InOpt != "") + if (InOpt != "") { return InOpt; } @@ -71,7 +71,17 @@ static public function string GetStringOption(string Options, string ParseString *** @param CurrentValue - the current value of the variable *** @return E_LogLevel value of the option we are looking for ***/ -static public function E_LogLevel GetLogLevelOption(string Options, string ParseString, E_LogLevel CurrentValue) +static public function E_LogLevel GetLogLevelOption(String Options, String ParseString, E_LogLevel CurrentValue) { - return CurrentValue; // TODO: impl + local String InOpt; + + //Find the value associated with this variable in the launch command. + InOpt = GameInfo.static.ParseOption(Options, ParseString); + + if (InOpt != "") + { + return class'_Logger'.static.LogLevelFromString(InOpt, CurrentValue); + } + + return CurrentValue; } \ No newline at end of file diff --git a/StartWave/Classes/_Logger.uc b/StartWave/Classes/_Logger.uc index bf77f4e..065505f 100644 --- a/StartWave/Classes/_Logger.uc +++ b/StartWave/Classes/_Logger.uc @@ -14,6 +14,60 @@ enum E_LogLevel LL_All }; +public static function E_LogLevel LogLevelFromString(String LogLevel, optional E_LogLevel DefaultLogLevel) +{ + switch (LogLevel) + { + case "0": + case "WrongLevel": + case "LL_WrongLevel": + return LL_WrongLevel; + + case "1": + case "None": + case "LL_None": + return LL_None; + + case "2": + case "Fatal": + case "LL_Fatal": + return LL_Fatal; + + case "3": + case "Error": + case "LL_Error": + return LL_Error; + + case "4": + case "Warning": + case "LL_Warning": + return LL_Warning; + + case "5": + case "Info": + case "LL_Info": + return LL_Info; + + case "6": + case "Debug": + case "LL_Debug": + return LL_Debug; + + case "7": + case "Trace": + case "LL_Trace": + return LL_Trace; + + case "8": + case "All": + case "LL_All": + return LL_All; + + default: + return DefaultLogLevel; + } +} + defaultproperties {