Skip to content

Commit

Permalink
Add option to pass logging level as command line parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
wiresock committed Jun 4, 2023
1 parent a0b2c65 commit f61f917
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ProxiFyre/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,20 @@ private class AppSettings
}

// Entry point of the application
private static void Main()
private static void Main(string[] args)
{
// Setting the level of logging for the application
const LogLevel logLevel = LogLevel.None;
LogLevel logLevel;

// Parse the log level from the command line arguments
if (args.Length > 0 && Enum.TryParse<LogLevel>(args[0], true, out var parsedLogLevel))
{
logLevel = parsedLogLevel;
}
else
{
// If no valid log level provided, default to LogLevel.None
logLevel = LogLevel.None;
}

// Load the configuration from JSON
var appSettingsList = JsonConvert.DeserializeObject<List<AppSettings>>(File.ReadAllText("app-config.json"));
Expand Down Expand Up @@ -83,6 +93,7 @@ private static void Main()
wiresock.Dispose();
}


// Method to handle logging events
private static void LogPrinter(object sender, LogEventArgs e)
{
Expand Down

0 comments on commit f61f917

Please sign in to comment.