Skip to content

Commit

Permalink
add LogLevel parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
GenZmeY committed May 20, 2023
1 parent 5f4b2ab commit 363e003
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 11 deletions.
32 changes: 21 additions & 11 deletions StartWave/Classes/OptionsParser.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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;
}
Expand All @@ -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;
}
54 changes: 54 additions & 0 deletions StartWave/Classes/_Logger.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down

0 comments on commit 363e003

Please sign in to comment.