From 10dc1fbaa8afb8dfe93526cd54fa3c7b4687f5a5 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Mon, 23 May 2022 14:57:33 +0200 Subject: [PATCH] Fix Linux distro being mistakenly logged, log values read from config --- AM2RLauncher/AM2RLauncher.Gtk/Program.cs | 4 ++-- AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs index f07b948..dab4da6 100644 --- a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs +++ b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs @@ -53,8 +53,8 @@ internal static class MainClass string osRelease = File.ReadAllText("/etc/os-release"); Regex lineRegex = new Regex(".*=.*"); List results = lineRegex.Matches(osRelease).ToList(); - Match version = results.FirstOrDefault(x => x.Value.Contains("VERSION")); - string distroName = results.FirstOrDefault(x => x.Value.Contains("NAME"))?.Value[5..].Replace("\"", ""); + Match version = results.FirstOrDefault(x => x.Value.StartsWith("VERSION")); + string distroName = results.FirstOrDefault(x => x.Value.StartsWith("NAME"))?.Value[5..].Replace("\"", ""); string versionName = version == null ? "" : version.Value[8..].Replace("\"", ""); log.Info($"Current Distro: {distroName} {versionName}"); } diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs index 4213f1d..0ceaab4 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs @@ -123,13 +123,14 @@ public partial class MainForm : Form /// The value from as a string public static string ReadFromConfig(string property) { - log.Info($"Reading {property} from config."); if (OS.IsWindows) { // We use the configuration manager in order to read `property` from the app.config and then return it ConnectionStringSettings appConfig = ConfigurationManager.ConnectionStrings[property]; if (appConfig == null) throw new ArgumentException("The property " + property + " could not be found."); - return appConfig.ConnectionString; + string value = appConfig.ConnectionString; + log.Info($"Reading {property} from config with value {value}."); + return value; } if (OS.IsUnix) { @@ -148,7 +149,9 @@ public partial class MainForm : Form launcherConfig = Serializer.Deserialize(File.ReadAllText(launcherConfigFilePath)); // This uses the indexer, which means, we can use the variable in order to get the property. Look at LauncherConfigXML for more info - return launcherConfig[property]?.ToString(); + string value = launcherConfig[property]?.ToString(); + log.Info($"Reading {property} from config with value {value}."); + return value; } log.Error(OS.Name + " has no config to read from!");