diff --git a/.appveyor.yml b/.appveyor.yml index 5ad60262..8bb23f8d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,12 +1,9 @@ version: '{build}' clone_depth: 5 -image: Visual Studio 2015 +image: Visual Studio 2017 configuration: ReleaseWindows platform: Any CPU -install: - - cinst wixtoolset --version 3.10.3.3007 --checksumtype=sha256 --checksum=3C125E3551C035F69ED24ACD8FB4EF7B74C1311ECACF1F8FC1EB7E0DD47D9C75 - before_build: - nuget restore diff --git a/Core/NbfcCli/App.config b/Core/NbfcCli/App.Windows.config similarity index 100% rename from Core/NbfcCli/App.config rename to Core/NbfcCli/App.Windows.config diff --git a/Core/NbfcCli/NbfcCli.csproj b/Core/NbfcCli/NbfcCli.csproj index dc848466..071f1ab9 100644 --- a/Core/NbfcCli/NbfcCli.csproj +++ b/Core/NbfcCli/NbfcCli.csproj @@ -13,42 +13,29 @@ 512 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - + AnyCPU true full false - bin\Debug\ + bin\DebugWindows\ DEBUG;TRACE prompt 4 false + App.Windows.config - + AnyCPU pdbonly true - bin\Release\ + bin\ReleaseWindows\ TRACE prompt 4 false + App.Windows.config NbfcCli.Program @@ -60,7 +47,6 @@ pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset App.Linux.config false @@ -74,13 +60,11 @@ full AnyCPU prompt - MinimumRecommendedRules.ruleset - App.Linux.config + App.Linux.config - - ..\..\packages\clipr.1.5.1\lib\net35\clipr.dll - True + + ..\..\packages\clipr.1.6.0\lib\net35\clipr.dll @@ -112,7 +96,7 @@ Designer - + Designer @@ -152,23 +136,12 @@ Reference.cs - - - False - Microsoft .NET Framework 4.5 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - - + + + - - \ No newline at end of file + diff --git a/Core/NbfcService/packages.config b/Core/NbfcService/packages.config new file mode 100644 index 00000000..53e92546 --- /dev/null +++ b/Core/NbfcService/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Core/Plugins/OpenHardwareMonitor/OpenHardwareMonitorLib.csproj b/Core/Plugins/OpenHardwareMonitor/OpenHardwareMonitorLib.csproj index 1e551005..d24410e8 100644 --- a/Core/Plugins/OpenHardwareMonitor/OpenHardwareMonitorLib.csproj +++ b/Core/Plugins/OpenHardwareMonitor/OpenHardwareMonitorLib.csproj @@ -3,8 +3,6 @@ Debug AnyCPU - 9.0.30729 - 2.0 {B0397530-545A-471D-BB74-027AE456DF1A} Library Properties @@ -12,25 +10,6 @@ OpenHardwareMonitorLib v4.5 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true @@ -42,7 +21,6 @@ TRACE;DEBUG prompt 4 - AllRules.ruleset false @@ -52,7 +30,6 @@ TRACE prompt 4 - AllRules.ruleset false @@ -149,23 +126,6 @@ - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - diff --git a/Core/Plugins/StagWare.Plugins.CpuTemperatureMonitor/StagWare.Plugins.CpuTemperatureMonitor.csproj b/Core/Plugins/StagWare.Plugins.CpuTemperatureMonitor/StagWare.Plugins.CpuTemperatureMonitor.csproj index 8d77075a..b2ee7545 100644 --- a/Core/Plugins/StagWare.Plugins.CpuTemperatureMonitor/StagWare.Plugins.CpuTemperatureMonitor.csproj +++ b/Core/Plugins/StagWare.Plugins.CpuTemperatureMonitor/StagWare.Plugins.CpuTemperatureMonitor.csproj @@ -14,7 +14,7 @@ - + true full false @@ -24,7 +24,7 @@ 4 false - + pdbonly true bin\Release\ @@ -34,13 +34,20 @@ false - bin\ReleaseLinux\ + bin\Release\ TRACE true pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset + + + true + bin\Debug\ + DEBUG;TRACE + full + AnyCPU + prompt @@ -67,17 +74,30 @@ - + + - + - + + + + - - \ No newline at end of file + diff --git a/Core/Plugins/StagWare.Plugins.ECLinux/StagWare.Plugins.ECLinux.csproj b/Core/Plugins/StagWare.Plugins.ECLinux/StagWare.Plugins.ECLinux.csproj index d30b917e..47182b23 100644 --- a/Core/Plugins/StagWare.Plugins.ECLinux/StagWare.Plugins.ECLinux.csproj +++ b/Core/Plugins/StagWare.Plugins.ECLinux/StagWare.Plugins.ECLinux.csproj @@ -12,41 +12,23 @@ 512 v4.5 - - v4.5 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - true - false - - bin\ReleaseLinux\ + bin\Release\ TRACE true true pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset + + + true + bin\Debug\ + DEBUG;TRACE + true + full + AnyCPU + prompt @@ -74,17 +56,30 @@ - + + - + - + + + + - - \ No newline at end of file + diff --git a/Core/Plugins/StagWare.Plugins.ECSysLinux/StagWare.Plugins.ECSysLinux.csproj b/Core/Plugins/StagWare.Plugins.ECSysLinux/StagWare.Plugins.ECSysLinux.csproj index 6e0aab01..b57dedb0 100644 --- a/Core/Plugins/StagWare.Plugins.ECSysLinux/StagWare.Plugins.ECSysLinux.csproj +++ b/Core/Plugins/StagWare.Plugins.ECSysLinux/StagWare.Plugins.ECSysLinux.csproj @@ -12,38 +12,21 @@ 512 v4.5 - - v4.5 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - bin\ReleaseLinux\ + bin\Release\ TRACE true pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset + + + true + bin\Debug\ + DEBUG;TRACE + full + AnyCPU + prompt @@ -66,17 +49,30 @@ - + + - + - + + + + - - \ No newline at end of file + diff --git a/Core/Plugins/StagWare.Plugins.ECWindows/StagWare.Plugins.ECWindows.csproj b/Core/Plugins/StagWare.Plugins.ECWindows/StagWare.Plugins.ECWindows.csproj index f0923621..279bad23 100644 --- a/Core/Plugins/StagWare.Plugins.ECWindows/StagWare.Plugins.ECWindows.csproj +++ b/Core/Plugins/StagWare.Plugins.ECWindows/StagWare.Plugins.ECWindows.csproj @@ -14,7 +14,7 @@ - + true full false @@ -24,7 +24,7 @@ 4 false - + pdbonly true bin\Release\ diff --git a/Core/Plugins/StagWare.Plugins.FSTemperatureMonitor/StagWare.Plugins.FSTemperatureMonitor.csproj b/Core/Plugins/StagWare.Plugins.FSTemperatureMonitor/StagWare.Plugins.FSTemperatureMonitor.csproj index 955513ea..bd6b909d 100644 --- a/Core/Plugins/StagWare.Plugins.FSTemperatureMonitor/StagWare.Plugins.FSTemperatureMonitor.csproj +++ b/Core/Plugins/StagWare.Plugins.FSTemperatureMonitor/StagWare.Plugins.FSTemperatureMonitor.csproj @@ -14,7 +14,7 @@ - + true full false @@ -24,7 +24,7 @@ 4 false - + pdbonly true bin\Release\ @@ -34,13 +34,20 @@ false - bin\ReleaseLinux\ + bin\Release\ TRACE true pdbonly AnyCPU prompt - MinimumRecommendedRules.ruleset + + + true + bin\Debug\ + DEBUG;TRACE + full + AnyCPU + prompt @@ -64,17 +71,30 @@ - + + - + - + + + + - - \ No newline at end of file + diff --git a/Core/StagWare.BiosInfo/Properties/AssemblyInfo.cs b/Core/StagWare.BiosInfo/Properties/AssemblyInfo.cs index 161b98d8..d202730b 100644 --- a/Core/StagWare.BiosInfo/Properties/AssemblyInfo.cs +++ b/Core/StagWare.BiosInfo/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("StagWare")] [assembly: AssemblyProduct("StagWare.BiosInfo")] -[assembly: AssemblyCopyright("Copyright © 2016 Stefan Hirschcmann")] +[assembly: AssemblyCopyright("Copyright © 2016 Stefan Hirschmann")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Core/StagWare.FanControl.Service/App.config b/Core/StagWare.FanControl.Service/App.config index 2efb030f..24a0b340 100644 --- a/Core/StagWare.FanControl.Service/App.config +++ b/Core/StagWare.FanControl.Service/App.config @@ -1,12 +1,6 @@ - - -
- - - @@ -47,28 +41,5 @@ - - - - - - True - - - - - - - - False - - - - - - - - - - + diff --git a/Core/StagWare.FanControl.Service/FanControlService.cs b/Core/StagWare.FanControl.Service/FanControlService.cs index 90566fef..52eab44c 100644 --- a/Core/StagWare.FanControl.Service/FanControlService.cs +++ b/Core/StagWare.FanControl.Service/FanControlService.cs @@ -1,12 +1,13 @@ using StagWare.FanControl.Configurations; -using StagWare.Settings; using System; using System.Collections.ObjectModel; using System.IO; +using System.Linq; using System.Reflection; using System.ServiceModel; -using System.Linq; using System.Threading; +using NLog; +using SettingsService = StagWare.Settings.SettingsService; namespace StagWare.FanControl.Service { @@ -23,6 +24,7 @@ public class FanControlService : IFanControlService, IDisposable #region Private Fields + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly string ConfigsDirectory = Path.Combine( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ConfigsDirectoryName); @@ -38,27 +40,13 @@ public class FanControlService : IFanControlService, IDisposable public FanControlService() { - string dir = ""; - - if (Environment.OSVersion.Platform == PlatformID.Unix) - { - dir = "/etc/"; - } - else - { - dir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); - } - - string settingsFile = Path.Combine( - dir, - SettingsFolderName, - SettingsFileName); - - ServiceSettings.SettingsFileName = settingsFile; + SettingsService.BaseDirectory = Environment.OSVersion.Platform == PlatformID.Unix + ? "/etc/" + : Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); - if (ServiceSettings.Default.Autostart) + if (SettingsService.Settings.Autostart) { - Start(ServiceSettings.Default.ReadOnly); + Start(SettingsService.Settings.ReadOnly); } } @@ -78,8 +66,8 @@ public void SetTargetFanSpeed(float value, int fanIndex) { this.fanControl.SetTargetFanSpeed(value, fanIndex); - ServiceSettings.Default.TargetFanSpeeds[fanIndex] = value; - ServiceSettings.Save(); + SettingsService.Settings.TargetFanSpeeds[fanIndex] = value; + SettingsService.Save(); } } } @@ -146,8 +134,8 @@ public void Start(bool readOnly = true) if (TryInitializeFanControl(cfg, out this.fanControl)) { this.fansCount = this.fanControl.FanInformation.Count; - ServiceSettings.Default.Autostart = this.fanControl.Enabled; - ServiceSettings.Save(); + SettingsService.Settings.Autostart = this.fanControl.Enabled; + SettingsService.Save(); } } } @@ -156,9 +144,9 @@ public void Start(bool readOnly = true) { this.fanControl.Start(readOnly); - ServiceSettings.Default.Autostart = this.fanControl.Enabled; - ServiceSettings.Default.ReadOnly = this.fanControl.ReadOnly; - ServiceSettings.Save(); + SettingsService.Settings.Autostart = this.fanControl.Enabled; + SettingsService.Settings.ReadOnly = this.fanControl.ReadOnly; + SettingsService.Save(); } } @@ -168,11 +156,12 @@ public void Stop() { try { - ServiceSettings.Default.Autostart = false; - ServiceSettings.Save(); + SettingsService.Settings.Autostart = false; + SettingsService.Save(); } - catch + catch(Exception e) { + logger.Error(e, "Failed to save settings"); } fanControl.Stop(); @@ -191,8 +180,8 @@ public void SetConfig(string configUniqueId) } else { - ServiceSettings.Default.SelectedConfigId = configUniqueId; - ServiceSettings.Save(); + SettingsService.Settings.SelectedConfigId = configUniqueId; + SettingsService.Save(); if (this.fanControl != null) { @@ -255,12 +244,13 @@ public void Continue() { try { - this.fanControl.Start(ServiceSettings.Default.ReadOnly); + this.fanControl.Start(SettingsService.Settings.ReadOnly); } - catch (TimeoutException) + catch (TimeoutException e) { + logger.Warn(e, "Trying to start the service timed out. Retrying"); Thread.Sleep(3000); - this.fanControl.Start(ServiceSettings.Default.ReadOnly); + this.fanControl.Start(SettingsService.Settings.ReadOnly); } } } @@ -276,7 +266,7 @@ private static bool TryInitializeFanControl(FanControlConfigV2 cfg, out FanContr try { - float[] speeds = ServiceSettings.Default.TargetFanSpeeds; + float[] speeds = SettingsService.Settings.TargetFanSpeeds; if (speeds == null || speeds.Length != cfg.FanConfigurations.Count) { @@ -287,8 +277,8 @@ private static bool TryInitializeFanControl(FanControlConfigV2 cfg, out FanContr speeds[i] = FanControl.AutoFanSpeedPercentage; } - ServiceSettings.Default.TargetFanSpeeds = speeds; - ServiceSettings.Save(); + SettingsService.Settings.TargetFanSpeeds = speeds; + SettingsService.Save(); } fanControl = new FanControl(cfg); @@ -329,7 +319,7 @@ private bool TryLoadConfig(out FanControlConfigV2 config) { bool result = false; var configManager = new FanControlConfigManager(FanControlService.ConfigsDirectory); - string id = ServiceSettings.Default.SelectedConfigId; + string id = SettingsService.Settings.SelectedConfigId; if (!string.IsNullOrWhiteSpace(id) && configManager.SelectConfig(id)) { diff --git a/Core/StagWare.FanControl.Service/Properties/AssemblyInfo.cs b/Core/StagWare.FanControl.Service/Properties/AssemblyInfo.cs index 84596f61..e4df3698 100644 --- a/Core/StagWare.FanControl.Service/Properties/AssemblyInfo.cs +++ b/Core/StagWare.FanControl.Service/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("StagWare")] [assembly: AssemblyProduct("StagWare.FanControl.Service")] -[assembly: AssemblyCopyright("Copyright © 2013-2016 Stefan Hirschmann")] +[assembly: AssemblyCopyright("Copyright © 2013-2017 Stefan Hirschmann")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.2.0")] -[assembly: AssemblyFileVersion("1.4.2.0")] +[assembly: AssemblyVersion("1.4.3.0")] +[assembly: AssemblyFileVersion("1.4.3.0")] diff --git a/Core/StagWare.FanControl.Service/Settings/ServiceSettingsProperties.cs b/Core/StagWare.FanControl.Service/ServiceSettings.cs similarity index 53% rename from Core/StagWare.FanControl.Service/Settings/ServiceSettingsProperties.cs rename to Core/StagWare.FanControl.Service/ServiceSettings.cs index f1f47b6a..cf9ac3e5 100644 --- a/Core/StagWare.FanControl.Service/Settings/ServiceSettingsProperties.cs +++ b/Core/StagWare.FanControl.Service/ServiceSettings.cs @@ -1,7 +1,14 @@ -namespace StagWare.Settings +using StagWare.Settings; + +namespace StagWare { - public sealed partial class ServiceSettings + public class ServiceSettings : SettingsBase { + public ServiceSettings() + { + SettingsVersion = 0; + } + public string SelectedConfigId { get; set; } public bool Autostart { get; set; } public bool ReadOnly { get; set; } diff --git a/Core/StagWare.FanControl.Service/Settings/ServiceSettings.cs b/Core/StagWare.FanControl.Service/Settings/ServiceSettings.cs deleted file mode 100644 index 237228b6..00000000 --- a/Core/StagWare.FanControl.Service/Settings/ServiceSettings.cs +++ /dev/null @@ -1,244 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Reflection; -using System.Xml.Serialization; -using System.Globalization; -using System.Linq; -using System.Diagnostics; - -namespace StagWare.Settings -{ - public sealed partial class ServiceSettings - { - #region Nested Types - - private class Properties - { - #region Private Fields - - internal static readonly ServiceSettings instance; - - #endregion - - #region Constructors - - private Properties() - { } - - // Explicit static constructor to tell C# compiler - // not to mark type as 'beforefieldinit'. - static Properties() - { - instance = new ServiceSettings(); - - if (ServiceSettings.SettingsFileExists) - { - try - { - using (FileStream fs = new FileStream(SettingsFileName, FileMode.Open)) - { - var serializer = new XmlSerializer(typeof(ServiceSettings)); - Properties.instance = (ServiceSettings)serializer.Deserialize(fs); - } - } - catch (Exception e) - { - OnLoadSettingsFailed(e); - RestoreDefaults(); - } - } - } - - #endregion - } - - #endregion - - #region Constants - - private const string DefaultSettingsFolderName = "AppSettings"; - private const string DefaultSettingsFileName = "settings.xml"; - - #endregion - - #region Private Fields - - Dictionary storedValues; - - #endregion - - #region Events - - public static event EventHandler LoadSettingsFailed; - - #endregion - - #region Properties - - // Singleton instance. - public static ServiceSettings Default - { - get { return Properties.instance; } - } - - public static string SettingsFileName { get; set; } - - public static bool SettingsFileExists - { - get - { - return File.Exists(SettingsFileName); - } - } - - #endregion - - #region Constructors - - static ServiceSettings() - { - string folderName = GetProductName(); - - if (string.IsNullOrWhiteSpace(folderName)) - { - folderName = DefaultSettingsFolderName; - } - - SettingsFileName = Path.Combine(Environment.GetFolderPath( - Environment.SpecialFolder.ApplicationData), folderName, DefaultSettingsFileName); - - foreach (char c in Path.GetInvalidPathChars()) - { - SettingsFileName = SettingsFileName.Replace(c, '_'); - } - } - - // Hide constructor (Singleton) - private ServiceSettings() - { - this.storedValues = new Dictionary(); - RestoreDefaults(this, true); - } - - #endregion - - #region Public Methods - - public static void RestoreDefaults() - { - RestoreDefaults(ServiceSettings.Default, false); - } - - public static void Save() - { - string dir = Path.GetDirectoryName(SettingsFileName); - - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - - using (FileStream fs = new FileStream(SettingsFileName, FileMode.Create)) - { - var serializer = new XmlSerializer(typeof(ServiceSettings)); - serializer.Serialize(fs, ServiceSettings.Default); - } - } - - public static void StoreCurrentSettings() - { - Properties.instance.storedValues.Clear(); - - foreach (PropertyInfo info in GetNonStaticProperties(typeof(ServiceSettings))) - { - object value = info.GetValue(Default, null); - ServiceSettings.Default.storedValues.Add(info.Name, value); - } - } - - public static void LoadStoredSettings() - { - foreach (PropertyInfo info in GetNonStaticProperties(typeof(ServiceSettings))) - { - if (ServiceSettings.Default.storedValues.ContainsKey(info.Name)) - { - object value = ServiceSettings.Default.storedValues[info.Name]; - info.SetValue(Default, value, null); - } - } - } - - public static void DeleteSettingsFile() - { - if (ServiceSettings.SettingsFileExists) - { - File.Delete(SettingsFileName); - } - - string dir = Path.GetDirectoryName(SettingsFileName); - - if (Directory.Exists(dir)) - { - Directory.Delete(dir, true); - } - } - - #endregion - - #region Private Methods - - private static void RestoreDefaults(ServiceSettings settings, bool force) - { - foreach (PropertyInfo pInfo in GetNonStaticProperties(typeof(ServiceSettings))) - { - if (force || !HasRestoreDefaultsIgnoreAttribute(pInfo)) - { - var defaultAttrib = pInfo.GetCustomAttributes(typeof(DefaultValueAttribute), false) - .FirstOrDefault() as DefaultValueAttribute; - - if (defaultAttrib != null) - { - pInfo.SetValue(settings, defaultAttrib.Value, null); - } - } - } - } - - private static IEnumerable GetNonStaticProperties(Type type) - { - foreach (PropertyInfo propInfo in type.GetProperties()) - { - MethodInfo methInfo = propInfo.GetGetMethod(false); - - if ((methInfo != null) && (!methInfo.IsStatic)) - { - yield return propInfo; - } - } - } - - private static bool HasRestoreDefaultsIgnoreAttribute(PropertyInfo info) - { - return info.GetCustomAttributes(typeof(RestoreDefaultsIgnoreAttribute), false).Length > 0; - } - - private static string GetProductName() - { - var info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); - return info.ProductName; - } - - private static void OnLoadSettingsFailed(Exception e) - { - if (ServiceSettings.LoadSettingsFailed != null) - { - ServiceSettings.LoadSettingsFailed(null, new LoadSettingsFailedEventArgs(e)); - } - } - - #endregion - } -} - diff --git a/Core/StagWare.FanControl.Service/StagWare.FanControl.Service.csproj b/Core/StagWare.FanControl.Service/StagWare.FanControl.Service.csproj index 1a9bcb61..c8cc6238 100644 --- a/Core/StagWare.FanControl.Service/StagWare.FanControl.Service.csproj +++ b/Core/StagWare.FanControl.Service/StagWare.FanControl.Service.csproj @@ -49,6 +49,9 @@ + + ..\..\packages\NLog.4.4.9\lib\net45\NLog.dll + @@ -58,20 +61,18 @@ - - - - + Designer + @@ -82,6 +83,10 @@ {12084b38-c1a2-414c-80a7-b8d02d6f5b84} StagWare.FanControl + + {44c3959a-3565-4fb6-9bf6-694b146cd032} + StagWare.Settings + diff --git a/Core/StagWare.FanControl.Service/packages.config b/Core/StagWare.FanControl.Service/packages.config new file mode 100644 index 00000000..53e92546 --- /dev/null +++ b/Core/StagWare.FanControl.Service/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Core/StagWare.FanControl/FanControl.cs b/Core/StagWare.FanControl/FanControl.cs index c7b3b61a..9fec7fb3 100644 --- a/Core/StagWare.FanControl/FanControl.cs +++ b/Core/StagWare.FanControl/FanControl.cs @@ -1,4 +1,5 @@ -using StagWare.FanControl.Configurations; +using NLog; +using StagWare.FanControl.Configurations; using StagWare.FanControl.Plugins; using System; using System.Collections.ObjectModel; @@ -35,6 +36,7 @@ public class FanControl : IDisposable #region Private Fields private readonly object syncRoot = new object(); + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private Timer timer; private AsyncOperation asyncOp; @@ -379,6 +381,10 @@ private void TimerCallback(object state) { UpdateEc(this.temperature); } + catch(Exception e) + { + logger.Error(e, "Could not update the EC"); + } finally { this.ec.ReleaseLock(); @@ -577,6 +583,10 @@ private void ResetEc(bool force = false) ResetFans(); } } + catch(Exception e) + { + logger.Error(e, "EC reset failed"); + } finally { if (ecLockAcquired) diff --git a/Core/StagWare.FanControl/Plugins/FanControlPluginLoader.cs b/Core/StagWare.FanControl/Plugins/FanControlPluginLoader.cs index 2aab69c7..6ff7daef 100644 --- a/Core/StagWare.FanControl/Plugins/FanControlPluginLoader.cs +++ b/Core/StagWare.FanControl/Plugins/FanControlPluginLoader.cs @@ -1,4 +1,5 @@ -using System; +using NLog; +using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; @@ -8,6 +9,8 @@ namespace StagWare.FanControl.Plugins { public class FanControlPluginLoader where T : IFanControlPlugin { + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); + T fanControlPlugin; string fanControlPluginId; @@ -109,8 +112,9 @@ private static bool TryInitPlugin(T plugin) plugin.Initialize(); isPluginInitialized = plugin.IsInitialized; } - catch + catch (Exception e) { + logger.Warn(e, "Plugin initialization failed"); } if (!isPluginInitialized) @@ -119,7 +123,10 @@ private static bool TryInitPlugin(T plugin) { plugin.Dispose(); } - catch { } + catch (Exception e) + { + logger.Warn(e, "Plugin disposal failed"); + } } return isPluginInitialized; diff --git a/Core/StagWare.FanControl/StagWare.FanControl.csproj b/Core/StagWare.FanControl/StagWare.FanControl.csproj index c2836591..67cee9b6 100644 --- a/Core/StagWare.FanControl/StagWare.FanControl.csproj +++ b/Core/StagWare.FanControl/StagWare.FanControl.csproj @@ -23,7 +23,6 @@ DEBUG;TRACE prompt 4 - MinimumRecommendedRules.ruleset false @@ -33,10 +32,12 @@ TRACE prompt 4 - BasicCorrectnessRules.ruleset false + + ..\..\packages\NLog.4.4.9\lib\net45\NLog.dll + @@ -69,7 +70,9 @@ StagWare.FanControl.Configurations - + + +