Skip to content

Commit

Permalink
Add -nologs arg
Browse files Browse the repository at this point in the history
  • Loading branch information
neatodev committed Sep 7, 2024
1 parent e05ed22 commit fb4dfae
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ internal static class Program
[STAThread]
static void Main(string[] args)
{
bool logs = true;
bool IsNewWindow = true;
using (Mutex mtx = new(true, "{BD4C408D-EF15-4C98-B792-C30D089E19D1}", out IsNewWindow))
{
if (args.Contains("-nologs"))
{
logs = false;
}
if (args.Contains("-nolauncher"))
{
SetupCulture();
SetupLogger();
SetupLogger(logs);
LauncherBypass();
}
else if (IsNewWindow)
{
SetupCulture();
SetupLogger();
SetupLogger(logs);
InitializeProgram();
Application.Run(MainWindow);
}
Expand Down Expand Up @@ -93,7 +98,7 @@ private static void InitializeProgram()
new InputWriter().WriteBmInput();
}

private static void SetupLogger()
private static void SetupLogger(bool logs)
{
LoggingConfiguration config = new();
ConsoleTarget logconsole = new("logconsole");
Expand All @@ -102,10 +107,14 @@ private static void SetupLogger()
Directory.CreateDirectory("logs");
}

FileTarget logfile = new("logfile")
if (logs)
{
FileName = Directory.GetCurrentDirectory() + "\\logs\\citylauncher_report__" + CurrentTime + ".log"
};
FileTarget logfile = new("logfile")
{
FileName = Directory.GetCurrentDirectory() + "\\logs\\citylauncher_report__" + CurrentTime + ".log"
};
config.AddRule(LogLevel.Debug, LogLevel.Error, logfile);
}
DirectoryInfo LogDirectory = new(Directory.GetCurrentDirectory() + "\\logs");
DateTime OldestAllowedArchive = DateTime.Now - new TimeSpan(3, 0, 0, 0);
foreach (FileInfo file in LogDirectory.GetFiles())
Expand All @@ -117,7 +126,6 @@ private static void SetupLogger()
}

config.AddRule(LogLevel.Debug, LogLevel.Error, logconsole);
config.AddRule(LogLevel.Debug, LogLevel.Error, logfile);
LogManager.Configuration = config;
}

Expand Down

0 comments on commit fb4dfae

Please sign in to comment.