From d768552f7aa42140208e6ac9c5a29cf5b56cbf00 Mon Sep 17 00:00:00 2001 From: Miepee Date: Tue, 8 Feb 2022 21:53:32 +0100 Subject: [PATCH] Linux: Only log env vars when on debug + set default log level to info --- AM2RLauncher/AM2RLauncher.Gtk/Program.cs | 7 ++- .../Properties/Resources.Designer.cs | 61 +++++-------------- .../Properties/Resources.resx | 2 +- AM2RLauncher/AM2RLauncher.Mac/Program.cs | 6 ++ .../Properties/Resources.Designer.cs | 2 - .../Properties/Resources.resx | 2 +- AM2RLauncher/AM2RLauncher.Wpf/Program.cs | 6 ++ .../Properties/Resources.Designer.cs | 61 +++++-------------- .../Properties/Resources.resx | 2 +- AM2RLauncher/AM2RLauncherCore/Profile.cs | 10 +-- 10 files changed, 56 insertions(+), 103 deletions(-) diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs index a63620e..814b558 100644 --- a/AM2RLauncher/AM2RLauncher.Gtk/Program.cs +++ b/AM2RLauncher/AM2RLauncher.Gtk/Program.cs @@ -5,7 +5,7 @@ using System; using System.IO; using System.Linq; using System.Text.RegularExpressions; -using GLib; +using log4net.Repository.Hierarchy; using Application = Eto.Forms.Application; using FileInfo = System.IO.FileInfo; @@ -39,6 +39,11 @@ internal static class MainClass // Configure logger XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config")); + // if we're on debug, always set loglevel to debug + #if DEBUG + ((Logger)log.Logger).Level = log4net.Core.Level.Debug; + #endif + // Log distro and version (if it exists) if (File.Exists("/etc/os-release")) { diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.Designer.cs b/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.Designer.cs index 1b88f02..4710aee 100644 --- a/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.Designer.cs +++ b/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.Designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 +// This code was generated by a tool. // -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,46 +11,32 @@ namespace AM2RLauncher.Gtk.Properties { using System; - /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. - /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert - // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AM2RLauncher.Gtk.Properties.Resources", typeof(Resources).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("AM2RLauncher.Gtk.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,22 +45,6 @@ namespace AM2RLauncher.Gtk.Properties { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die <log4net> - /// <root> - /// <level value="ALL" /> - /// <appender-ref ref="file" /> - /// </root> - /// <appender name="file" type="log4net.Appender.RollingFileAppender"> - /// <file value="${DATADIR}/Logs/AM2RLauncher.log" /> - /// <appendToFile value="true" /> - /// <rollingStyle value="Once" /> - /// <maxSizeRollBackups value="7" /> - /// <maximumFileSize value="3MB" /> - /// <staticLogFileName value="true" /> - /// <layout type="log4net.Layout.PatternLayout"> - /// <conversionPattern value="%date [%thread] %level %logg [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt. - /// internal static string log4netContents { get { return ResourceManager.GetString("log4netContents", resourceCulture); diff --git a/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.resx b/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.resx index a2cff8e..ac17795 100644 --- a/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.resx +++ b/AM2RLauncher/AM2RLauncher.Gtk/Properties/Resources.resx @@ -120,7 +120,7 @@ <log4net> <root> - <level value="ALL" /> + <level value="INFO" /> <appender-ref ref="file" /> </root> <appender name="file" type="log4net.Appender.RollingFileAppender"> diff --git a/AM2RLauncher/AM2RLauncher.Mac/Program.cs b/AM2RLauncher/AM2RLauncher.Mac/Program.cs index f25560f..56cfdb4 100644 --- a/AM2RLauncher/AM2RLauncher.Mac/Program.cs +++ b/AM2RLauncher/AM2RLauncher.Mac/Program.cs @@ -4,6 +4,7 @@ using log4net.Config; using System; using System.Diagnostics.CodeAnalysis; using System.IO; +using log4net.Repository.Hierarchy; namespace AM2RLauncher.Mac; @@ -36,6 +37,11 @@ internal static class MainClass // Configure logger XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config")); + // if we're on debug, always set loglevel to debug + #if DEBUG + ((Logger)log.Logger).Level = log4net.Core.Level.Debug; + #endif + try { Application macLauncher = new Application(Eto.Platforms.Mac64); diff --git a/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.Designer.cs b/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.Designer.cs index 641e315..47418bc 100644 --- a/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.Designer.cs +++ b/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -10,7 +9,6 @@ namespace AM2RLauncher.Mac.Properties { using System; - using System.Reflection; [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] diff --git a/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.resx b/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.resx index a2cff8e..ac17795 100644 --- a/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.resx +++ b/AM2RLauncher/AM2RLauncher.Mac/Properties/Resources.resx @@ -120,7 +120,7 @@ <log4net> <root> - <level value="ALL" /> + <level value="INFO" /> <appender-ref ref="file" /> </root> <appender name="file" type="log4net.Appender.RollingFileAppender"> diff --git a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs index 3c5172e..930cd56 100644 --- a/AM2RLauncher/AM2RLauncher.Wpf/Program.cs +++ b/AM2RLauncher/AM2RLauncher.Wpf/Program.cs @@ -4,6 +4,7 @@ using log4net.Config; using System; using System.IO; using System.Reflection; +using log4net.Repository.Hierarchy; namespace AM2RLauncher.Wpf; @@ -35,6 +36,11 @@ internal static class MainClass // Configure logger XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config")); + // if we're on debug, always set loglevel to debug + #if DEBUG + ((Logger)log.Logger).Level = log4net.Core.Level.Debug; + #endif + //Log Wine if (Core.Core.IsThisRunningFromWine) log.Info("Currently running from WINE!"); diff --git a/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.Designer.cs b/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.Designer.cs index ce32519..7de58d0 100644 --- a/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.Designer.cs +++ b/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.Designer.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ // -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 +// This code was generated by a tool. // -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. // //------------------------------------------------------------------------------ @@ -12,46 +11,32 @@ namespace AM2RLauncher.Wpf.Properties { using System; - /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. - /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert - // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [System.Diagnostics.DebuggerNonUserCodeAttribute()] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { - private static global::System.Resources.ResourceManager resourceMan; + private static System.Resources.ResourceManager resourceMan; - private static global::System.Globalization.CultureInfo resourceCulture; + private static System.Globalization.CultureInfo resourceCulture; - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Resources.ResourceManager ResourceManager { get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AM2RLauncher.Wpf.Properties.Resources", typeof(Resources).Assembly); + if (object.Equals(null, resourceMan)) { + System.Resources.ResourceManager temp = new System.Resources.ResourceManager("AM2RLauncher.Wpf.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + internal static System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -60,22 +45,6 @@ namespace AM2RLauncher.Wpf.Properties { } } - /// - /// Sucht eine lokalisierte Zeichenfolge, die <log4net> - /// <root> - /// <level value="ALL" /> - /// <appender-ref ref="file" /> - /// </root> - /// <appender name="file" type="log4net.Appender.RollingFileAppender"> - /// <file value="${DATADIR}/Logs/AM2RLauncher.log" /> - /// <appendToFile value="true" /> - /// <rollingStyle value="Once" /> - /// <maxSizeRollBackups value="7" /> - /// <maximumFileSize value="3MB" /> - /// <staticLogFileName value="true" /> - /// <layout type="log4net.Layout.PatternLayout"> - /// <conversionPattern value="%date [%thread] %level %logg [Rest der Zeichenfolge wurde abgeschnitten]"; ähnelt. - /// internal static string log4netContents { get { return ResourceManager.GetString("log4netContents", resourceCulture); diff --git a/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.resx b/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.resx index a2cff8e..ac17795 100644 --- a/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.resx +++ b/AM2RLauncher/AM2RLauncher.Wpf/Properties/Resources.resx @@ -120,7 +120,7 @@ <log4net> <root> - <level value="ALL" /> + <level value="INFO" /> <appender-ref ref="file" /> </root> <appender name="file" type="log4net.Appender.RollingFileAppender"> diff --git a/AM2RLauncher/AM2RLauncherCore/Profile.cs b/AM2RLauncher/AM2RLauncherCore/Profile.cs index 9118f42..3fe3212 100644 --- a/AM2RLauncher/AM2RLauncherCore/Profile.cs +++ b/AM2RLauncher/AM2RLauncherCore/Profile.cs @@ -492,7 +492,7 @@ public static class Profile { ProcessStartInfo startInfo = new ProcessStartInfo(); - log.Info("Is the environment textbox null or whitespace = " + String.IsNullOrWhiteSpace(envVars)); + log.Info("User does " + (String.IsNullOrWhiteSpace(envVars) ? "not" : "") + " have custom environment variables set."); //TODO: make this more readable at one day if (!String.IsNullOrWhiteSpace(envVars)) @@ -524,7 +524,7 @@ public static class Profile string value = envVars.Substring(0, valueSubstringLength); envVars = envVars.Substring(value.Length); - log.Info("Adding variable \"" + variable + "\" with value \"" + value + "\""); + log.Info("Adding user variable \"" + variable + "\" with value \"" + value + "\""); startInfo.EnvironmentVariables[variable] = value; } } @@ -538,10 +538,10 @@ public static class Profile log.Info("CWD of Profile is " + startInfo.WorkingDirectory); - log.Info("Launching game with following variables: "); + log.Debug("Launching game with following variables: "); foreach (System.Collections.DictionaryEntry item in startInfo.EnvironmentVariables) { - log.Info("Key: \"" + item.Key + "\" Value: \"" + item.Value + "\""); + log.Debug("Key: \"" + item.Key + "\" Value: \"" + item.Value + "\""); } using (Process p = new Process()) @@ -702,4 +702,4 @@ public static class Profile log.Info("AM2R_11 check successful!"); return IsZipAM2R11ReturnCodes.Successful; } -} +} \ No newline at end of file