diff --git a/RetailCoder.VBE/App.cs b/RetailCoder.VBE/App.cs index 874ee8c790..5126b3f56c 100644 --- a/RetailCoder.VBE/App.cs +++ b/RetailCoder.VBE/App.cs @@ -4,6 +4,7 @@ using Rubberduck.Common; using Rubberduck.Common.Dispatch; using Rubberduck.Parsing; +using Rubberduck.Parsing.Symbols; using Rubberduck.Parsing.VBA; using Rubberduck.Settings; using Rubberduck.SmartIndenter; @@ -11,13 +12,11 @@ using Rubberduck.UI.Command.MenuItems; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Linq; using System.Runtime.InteropServices.ComTypes; using System.Threading.Tasks; using System.Windows.Forms; -using Rubberduck.Parsing.Symbols; namespace Rubberduck { @@ -65,9 +64,6 @@ public App(VBE vbe, IMessageBox messageBox, _indenter = indenter; _hooks = hooks; _logger = LogManager.GetCurrentClassLogger(); - // Anyone else could be starting a parse task before we get to disable logging (if the user has configured it so) - // that is why we are conservative and disable logging by default. - LogManager.DisableLogging(); _hooks.MessageReceived += _hooks_MessageReceived; _configService.SettingsChanged += _configService_SettingsChanged; @@ -143,12 +139,7 @@ private void _configService_SettingsChanged(object sender, EventArgs e) private void UpdateLoggingLevel() { - var fileRule = LogManager.Configuration.LoggingRules.Where(rule => rule.Targets.Any(t => t.Name == FILE_TARGET_NAME)).FirstOrDefault(); - if (fileRule == null) - { - return; - } - LogLevelHelper.SetMinimumLogLevel(fileRule, LogLevel.FromOrdinal(_config.UserSettings.GeneralSettings.MinimumLogLevel)); + LogLevelHelper.SetMinimumLogLevel(LogLevel.FromOrdinal(_config.UserSettings.GeneralSettings.MinimumLogLevel)); } public void Startup() diff --git a/RetailCoder.VBE/Common/ApplicationConstants.cs b/RetailCoder.VBE/Common/ApplicationConstants.cs new file mode 100644 index 0000000000..57527ac43c --- /dev/null +++ b/RetailCoder.VBE/Common/ApplicationConstants.cs @@ -0,0 +1,10 @@ +using System; +using System.IO; + +namespace Rubberduck.Common +{ + public static class ApplicationConstants + { + public static readonly string LOG_FOLDER_PATH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Rubberduck", "Logs"); + } +} diff --git a/RetailCoder.VBE/Common/IOperatingSystem.cs b/RetailCoder.VBE/Common/IOperatingSystem.cs new file mode 100644 index 0000000000..da8adb9ee1 --- /dev/null +++ b/RetailCoder.VBE/Common/IOperatingSystem.cs @@ -0,0 +1,7 @@ +namespace Rubberduck.Common +{ + public interface IOperatingSystem + { + void ShowFolder(string folderPath); + } +} diff --git a/RetailCoder.VBE/Common/LogLevelHelper.cs b/RetailCoder.VBE/Common/LogLevelHelper.cs index 803cf60d9a..d60497aaa7 100644 --- a/RetailCoder.VBE/Common/LogLevelHelper.cs +++ b/RetailCoder.VBE/Common/LogLevelHelper.cs @@ -2,10 +2,6 @@ using NLog.Config; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Rubberduck.Common { @@ -32,9 +28,13 @@ private static IEnumerable GetLogLevels() return logLevels; } - public static void SetMinimumLogLevel(LoggingRule loggingRule, LogLevel minimumLogLevel) + public static void SetMinimumLogLevel(LogLevel minimumLogLevel) { - ClearLogLevels(loggingRule); + var loggingRules = LogManager.Configuration.LoggingRules; + foreach (var loggingRule in loggingRules) + { + ClearLogLevels(loggingRule); + } if (minimumLogLevel == LogLevel.Off) { LogManager.DisableLogging(); @@ -42,11 +42,14 @@ public static void SetMinimumLogLevel(LoggingRule loggingRule, LogLevel minimumL return; } LogManager.EnableLogging(); - foreach (var logLevel in LogLevels) + foreach (var loggingRule in loggingRules) { - if (logLevel != LogLevel.Off && logLevel >= minimumLogLevel) + foreach (var logLevel in LogLevels) { - loggingRule.EnableLoggingForLevel(logLevel); + if (logLevel != LogLevel.Off && logLevel >= minimumLogLevel) + { + loggingRule.EnableLoggingForLevel(logLevel); + } } } LogManager.ReconfigExistingLoggers(); diff --git a/RetailCoder.VBE/Common/WindowsOperatingSystem.cs b/RetailCoder.VBE/Common/WindowsOperatingSystem.cs new file mode 100644 index 0000000000..4d1fe1e0be --- /dev/null +++ b/RetailCoder.VBE/Common/WindowsOperatingSystem.cs @@ -0,0 +1,13 @@ +using System; +using System.Diagnostics; + +namespace Rubberduck.Common +{ + public sealed class WindowsOperatingSystem : IOperatingSystem + { + public void ShowFolder(string folderPath) + { + Process.Start(folderPath); + } + } +} diff --git a/RetailCoder.VBE/Root/RubberduckModule.cs b/RetailCoder.VBE/Root/RubberduckModule.cs index b1a3b6b37b..6f82ddb91d 100644 --- a/RetailCoder.VBE/Root/RubberduckModule.cs +++ b/RetailCoder.VBE/Root/RubberduckModule.cs @@ -73,6 +73,7 @@ public override void Load() _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); _kernel.Bind().ToSelf().InSingletonScope(); + _kernel.Bind().To().InSingletonScope(); BindCodeInspectionTypes(); diff --git a/RetailCoder.VBE/Rubberduck.csproj b/RetailCoder.VBE/Rubberduck.csproj index 8906a03f6a..754c501ba2 100644 --- a/RetailCoder.VBE/Rubberduck.csproj +++ b/RetailCoder.VBE/Rubberduck.csproj @@ -288,6 +288,7 @@ + @@ -302,6 +303,7 @@ + @@ -346,6 +348,7 @@ + InspectionsUI.de.resx True diff --git a/RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs b/RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs index 7c91bfb8fa..15847c83f0 100644 --- a/RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs +++ b/RetailCoder.VBE/UI/CodeInspections/InspectionResultsViewModel.cs @@ -30,10 +30,11 @@ public sealed class InspectionResultsViewModel : ViewModelBase, INavigateSelecti private readonly VBE _vbe; private readonly IClipboardWriter _clipboard; private readonly IGeneralConfigService _configService; + private readonly IOperatingSystem _operatingSystem; private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); public InspectionResultsViewModel(RubberduckParserState state, IInspector inspector, VBE vbe, INavigateCommand navigateCommand, IClipboardWriter clipboard, - IGeneralConfigService configService) + IGeneralConfigService configService, IOperatingSystem operatingSystem) { _state = state; _inspector = inspector; @@ -41,6 +42,7 @@ public InspectionResultsViewModel(RubberduckParserState state, IInspector inspec _navigateCommand = navigateCommand; _clipboard = clipboard; _configService = configService; + _operatingSystem = operatingSystem; _refreshCommand = new DelegateCommand(async param => await Task.Run(() => ExecuteRefreshCommandAsync(param)), CanExecuteRefreshCommand); _disableInspectionCommand = new DelegateCommand(ExecuteDisableInspectionCommand); _quickFixCommand = new DelegateCommand(ExecuteQuickFixCommand, CanExecuteQuickFixCommand); @@ -174,7 +176,7 @@ public bool GroupByLocation private void OpenSettings(object param) { - using (var window = new SettingsForm(_configService, SettingsViews.InspectionSettings)) + using (var window = new SettingsForm(_configService, _operatingSystem, SettingsViews.InspectionSettings)) { window.ShowDialog(); } diff --git a/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs b/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs index 9cfd4976c2..bbbe2918bf 100644 --- a/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs +++ b/RetailCoder.VBE/UI/Command/MenuItems/UiDispatcher.cs @@ -8,7 +8,7 @@ public static class UiDispatcher // thanks to Pellared on http://stackoverflow.com/a/12909070/1188513 private static SynchronizationContext UiContext { get; set; } - + public static void Initialize() { if (UiContext == null) diff --git a/RetailCoder.VBE/UI/Command/SettingsCommand.cs b/RetailCoder.VBE/UI/Command/SettingsCommand.cs index 9eb7b84e7d..036c4b3a67 100644 --- a/RetailCoder.VBE/UI/Command/SettingsCommand.cs +++ b/RetailCoder.VBE/UI/Command/SettingsCommand.cs @@ -1,6 +1,7 @@ using System.Runtime.InteropServices; using Rubberduck.Settings; using Rubberduck.UI.Settings; +using Rubberduck.Common; namespace Rubberduck.UI.Command { @@ -11,14 +12,16 @@ namespace Rubberduck.UI.Command public class SettingsCommand : CommandBase { private readonly IGeneralConfigService _service; - public SettingsCommand(IGeneralConfigService service) + private readonly IOperatingSystem _operatingSystem; + public SettingsCommand(IGeneralConfigService service, IOperatingSystem operatingSystem) { _service = service; + _operatingSystem = operatingSystem; } public override void Execute(object parameter) { - using (var window = new SettingsForm(_service)) + using (var window = new SettingsForm(_service, _operatingSystem)) { window.ShowDialog(); } diff --git a/RetailCoder.VBE/UI/RubberduckUI.Designer.cs b/RetailCoder.VBE/UI/RubberduckUI.Designer.cs index 119ddd82cc..b9ae7d4f52 100644 --- a/RetailCoder.VBE/UI/RubberduckUI.Designer.cs +++ b/RetailCoder.VBE/UI/RubberduckUI.Designer.cs @@ -1426,6 +1426,15 @@ public static string GeneralSettings_PeriodDelimiter { } } + /// + /// Looks up a localized string similar to Show Log Folder. + /// + public static string GeneralSettings_ShowLogFolder { + get { + return ResourceManager.GetString("GeneralSettings_ShowLogFolder", resourceCulture); + } + } + /// /// Looks up a localized string similar to Slash (/). /// diff --git a/RetailCoder.VBE/UI/RubberduckUI.de.resx b/RetailCoder.VBE/UI/RubberduckUI.de.resx index 7af0b242a3..9fefbdd9f0 100644 --- a/RetailCoder.VBE/UI/RubberduckUI.de.resx +++ b/RetailCoder.VBE/UI/RubberduckUI.de.resx @@ -1591,4 +1591,7 @@ Allen Sternguckern, Likern & Followern, für das warme Kribbeln Warnung + + Logging-Ordner anzeigen + \ No newline at end of file diff --git a/RetailCoder.VBE/UI/RubberduckUI.ja.resx b/RetailCoder.VBE/UI/RubberduckUI.ja.resx index e650067aa8..4d102a7523 100644 --- a/RetailCoder.VBE/UI/RubberduckUI.ja.resx +++ b/RetailCoder.VBE/UI/RubberduckUI.ja.resx @@ -1508,4 +1508,7 @@ スラッシュ「 / 」 + + ロギングフォルダを開く + \ No newline at end of file diff --git a/RetailCoder.VBE/UI/RubberduckUI.resx b/RetailCoder.VBE/UI/RubberduckUI.resx index 99e5b9b0f6..a6a117cc3c 100644 --- a/RetailCoder.VBE/UI/RubberduckUI.resx +++ b/RetailCoder.VBE/UI/RubberduckUI.resx @@ -1617,4 +1617,7 @@ All our stargazers, likers & followers, for the warm fuzzies Warn + + Show Log Folder + \ No newline at end of file diff --git a/RetailCoder.VBE/UI/Settings/GeneralSettings.xaml b/RetailCoder.VBE/UI/Settings/GeneralSettings.xaml index 528d0effa2..0e7f8355bd 100644 --- a/RetailCoder.VBE/UI/Settings/GeneralSettings.xaml +++ b/RetailCoder.VBE/UI/Settings/GeneralSettings.xaml @@ -120,14 +120,20 @@