Skip to content

Commit f61f917

Browse files
committed
Add option to pass logging level as command line parameter.
1 parent a0b2c65 commit f61f917

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ProxiFyre/Program.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ private class AppSettings
3434
}
3535

3636
// Entry point of the application
37-
private static void Main()
37+
private static void Main(string[] args)
3838
{
39-
// Setting the level of logging for the application
40-
const LogLevel logLevel = LogLevel.None;
39+
LogLevel logLevel;
40+
41+
// Parse the log level from the command line arguments
42+
if (args.Length > 0 && Enum.TryParse<LogLevel>(args[0], true, out var parsedLogLevel))
43+
{
44+
logLevel = parsedLogLevel;
45+
}
46+
else
47+
{
48+
// If no valid log level provided, default to LogLevel.None
49+
logLevel = LogLevel.None;
50+
}
4151

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

96+
8697
// Method to handle logging events
8798
private static void LogPrinter(object sender, LogEventArgs e)
8899
{

0 commit comments

Comments
 (0)