Added NLog logging
This commit is contained in:
parent
aadd56c473
commit
aae014b6e0
|
@ -54,6 +54,9 @@
|
||||||
<Reference Include="Microsoft.Practices.ServiceLocation">
|
<Reference Include="Microsoft.Practices.ServiceLocation">
|
||||||
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NLog">
|
||||||
|
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Windows.Media.Imaging;
|
||||||
using Filtration.Common.ViewModels;
|
using Filtration.Common.ViewModels;
|
||||||
using Filtration.Interface;
|
using Filtration.Interface;
|
||||||
using Filtration.ThemeEditor.Providers;
|
using Filtration.ThemeEditor.Providers;
|
||||||
|
using NLog;
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
|
||||||
namespace Filtration.ThemeEditor.ViewModels
|
namespace Filtration.ThemeEditor.ViewModels
|
||||||
|
@ -23,6 +24,8 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||||
|
|
||||||
public class ThemeViewModel : PaneViewModel, IThemeViewModel
|
public class ThemeViewModel : PaneViewModel, IThemeViewModel
|
||||||
{
|
{
|
||||||
|
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly IThemeProvider _themeProvider;
|
private readonly IThemeProvider _themeProvider;
|
||||||
private bool _filenameIsFake;
|
private bool _filenameIsFake;
|
||||||
private string _filePath;
|
private string _filePath;
|
||||||
|
@ -85,6 +88,11 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsErrorEnabled)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
|
}
|
||||||
|
|
||||||
MessageBox.Show(@"Error saving filter theme - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
MessageBox.Show(@"Error saving filter theme - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
||||||
MessageBoxImage.Error);
|
MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
@ -103,19 +111,24 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||||
if (result != DialogResult.OK) return;
|
if (result != DialogResult.OK) return;
|
||||||
|
|
||||||
var previousFilePath = FilePath;
|
var previousFilePath = FilePath;
|
||||||
//try
|
try
|
||||||
//{
|
{
|
||||||
FilePath = saveDialog.FileName;
|
FilePath = saveDialog.FileName;
|
||||||
_themeProvider.SaveTheme(this, FilePath);
|
_themeProvider.SaveTheme(this, FilePath);
|
||||||
_filenameIsFake = false;
|
_filenameIsFake = false;
|
||||||
//RemoveDirtyFlag();
|
//RemoveDirtyFlag();
|
||||||
//}
|
}
|
||||||
//catch (Exception e)
|
catch (Exception e)
|
||||||
//{
|
{
|
||||||
// MessageBox.Show(@"Error saving theme file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
if (_logger.IsErrorEnabled)
|
||||||
// MessageBoxImage.Error);
|
{
|
||||||
// FilePath = previousFilePath;
|
_logger.Error(e);
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
MessageBox.Show(@"Error saving theme file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
FilePath = previousFilePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
|
|
@ -6,4 +6,5 @@
|
||||||
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
|
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
|
||||||
<package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" />
|
<package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" />
|
||||||
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
|
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
|
||||||
|
<package id="NLog" version="4.0.1" targetFramework="net451" />
|
||||||
</packages>
|
</packages>
|
|
@ -14,12 +14,14 @@ using Filtration.Properties;
|
||||||
using Filtration.ThemeEditor.ViewModels;
|
using Filtration.ThemeEditor.ViewModels;
|
||||||
using Filtration.ViewModels;
|
using Filtration.ViewModels;
|
||||||
using Filtration.Views;
|
using Filtration.Views;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
namespace Filtration
|
namespace Filtration
|
||||||
{
|
{
|
||||||
public partial class App
|
public partial class App
|
||||||
{
|
{
|
||||||
private IWindsorContainer _container;
|
private IWindsorContainer _container;
|
||||||
|
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private void Application_Startup(object sender, StartupEventArgs e)
|
private void Application_Startup(object sender, StartupEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -67,6 +69,8 @@ namespace Filtration
|
||||||
|
|
||||||
public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
|
_logger.Fatal(e.Exception);
|
||||||
|
|
||||||
var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
|
var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
|
||||||
var innerException = e.Exception.InnerException != null
|
var innerException = e.Exception.InnerException != null
|
||||||
? e.Exception.InnerException.Message + Environment.NewLine +
|
? e.Exception.InnerException.Message + Environment.NewLine +
|
||||||
|
|
|
@ -64,6 +64,9 @@
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
|
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="NLog">
|
||||||
|
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.ObjectModel" />
|
<Reference Include="System.ObjectModel" />
|
||||||
|
@ -360,6 +363,12 @@
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<Content Include="NLog.config">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<None Include="NLog.xsd">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
|
||||||
|
autoReload="true"
|
||||||
|
throwExceptions="false"
|
||||||
|
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
|
||||||
|
|
||||||
|
<targets>
|
||||||
|
<target xsi:type="File" name="fErrors" fileName="${basedir}/Filtration_errors_${shortdate}.log"
|
||||||
|
layout="${longdate} ${uppercase:${level}} ${message}" />
|
||||||
|
<target xsi:type="File" name="fDebug" fileName="${basedir}/Filtration_debug_${shortdate}.log"
|
||||||
|
layout="${longdate} ${uppercase:${level}} ${message}" />
|
||||||
|
</targets>
|
||||||
|
|
||||||
|
<rules>
|
||||||
|
|
||||||
|
<!-- Uncomment the Debug line to enable Debug logging -->
|
||||||
|
<!--<logger name="*" minlevel="Debug" writeTo="fDebug" final="true" />-->
|
||||||
|
<logger name="*" minlevel="Error" writeTo="fErrors" />
|
||||||
|
|
||||||
|
</rules>
|
||||||
|
</nlog>
|
File diff suppressed because it is too large
Load Diff
|
@ -28,15 +28,7 @@ namespace Filtration.Repositories
|
||||||
|
|
||||||
public IItemFilterScriptViewModel LoadScriptFromFile(string path)
|
public IItemFilterScriptViewModel LoadScriptFromFile(string path)
|
||||||
{
|
{
|
||||||
ItemFilterScript loadedScript;
|
var loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path);
|
||||||
try
|
|
||||||
{
|
|
||||||
loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new IOException("Error loading filter script - " + e.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
var newViewModel = _itemFilterScriptViewModelFactory.Create();
|
var newViewModel = _itemFilterScriptViewModelFactory.Create();
|
||||||
newViewModel.Initialise(loadedScript, false);
|
newViewModel.Initialise(loadedScript, false);
|
||||||
|
|
|
@ -16,6 +16,7 @@ using Filtration.Services;
|
||||||
using Filtration.Translators;
|
using Filtration.Translators;
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
using GalaSoft.MvvmLight.Messaging;
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
|
using NLog;
|
||||||
using Clipboard = System.Windows.Clipboard;
|
using Clipboard = System.Windows.Clipboard;
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
|
||||||
|
@ -63,6 +64,8 @@ namespace Filtration.ViewModels
|
||||||
|
|
||||||
internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel
|
internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel
|
||||||
{
|
{
|
||||||
|
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory;
|
private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory;
|
||||||
private readonly IItemFilterBlockTranslator _blockTranslator;
|
private readonly IItemFilterBlockTranslator _blockTranslator;
|
||||||
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
||||||
|
@ -314,7 +317,7 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
Title = Filename;
|
Title = Filename;
|
||||||
ContentId = "testcontentid";
|
ContentId = "ScriptContentId";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
|
@ -334,6 +337,11 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsErrorEnabled)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
|
}
|
||||||
|
|
||||||
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
||||||
MessageBoxImage.Error);
|
MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
@ -365,6 +373,11 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsErrorEnabled)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
|
}
|
||||||
|
|
||||||
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK,
|
||||||
MessageBoxImage.Error);
|
MessageBoxImage.Error);
|
||||||
Script.FilePath = previousFilePath;
|
Script.FilePath = previousFilePath;
|
||||||
|
|
|
@ -3,13 +3,11 @@ using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Filtration.Common.ViewModels;
|
using Filtration.Common.ViewModels;
|
||||||
using Filtration.Interface;
|
using Filtration.Interface;
|
||||||
using Filtration.Models;
|
|
||||||
using Filtration.ObjectModel.ThemeEditor;
|
using Filtration.ObjectModel.ThemeEditor;
|
||||||
using Filtration.Properties;
|
using Filtration.Properties;
|
||||||
using Filtration.Repositories;
|
using Filtration.Repositories;
|
||||||
|
@ -21,6 +19,7 @@ using Filtration.Translators;
|
||||||
using Filtration.Views;
|
using Filtration.Views;
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
using GalaSoft.MvvmLight.Messaging;
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
|
using NLog;
|
||||||
using Clipboard = System.Windows.Clipboard;
|
using Clipboard = System.Windows.Clipboard;
|
||||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||||
|
|
||||||
|
@ -34,6 +33,8 @@ namespace Filtration.ViewModels
|
||||||
|
|
||||||
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
|
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
|
||||||
{
|
{
|
||||||
|
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
private readonly IItemFilterScriptRepository _itemFilterScriptRepository;
|
private readonly IItemFilterScriptRepository _itemFilterScriptRepository;
|
||||||
private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator;
|
private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator;
|
||||||
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
|
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
|
||||||
|
@ -198,8 +199,12 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsDebugEnabled)
|
||||||
|
{
|
||||||
|
_logger.Debug(e);
|
||||||
|
}
|
||||||
// We don't care if the update check fails, because it could fail for multiple reasons
|
// We don't care if the update check fails, because it could fail for multiple reasons
|
||||||
// including the user blocking Filtration in their firewall.
|
// including the user blocking Filtration in their firewall.
|
||||||
}
|
}
|
||||||
|
@ -302,6 +307,10 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsErrorEnabled)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
|
}
|
||||||
MessageBox.Show(@"Error loading filter script - " + e.Message, @"Script Load Error",
|
MessageBox.Show(@"Error loading filter script - " + e.Message, @"Script Load Error",
|
||||||
MessageBoxButtons.OK,
|
MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
|
@ -328,6 +337,10 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsErrorEnabled)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
|
}
|
||||||
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
|
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
|
||||||
MessageBoxButtons.OK,
|
MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
|
@ -353,6 +366,10 @@ namespace Filtration.ViewModels
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
if (_logger.IsErrorEnabled)
|
||||||
|
{
|
||||||
|
_logger.Error(e);
|
||||||
|
}
|
||||||
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
|
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error",
|
||||||
MessageBoxButtons.OK,
|
MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Filtration.Common.ViewModels;
|
using Filtration.Common.ViewModels;
|
||||||
using Filtration.Interface;
|
using Filtration.Interface;
|
||||||
using Filtration.ViewModels.ToolPanes;
|
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
using GalaSoft.MvvmLight.Messaging;
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ namespace Filtration.ViewModels
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void OnOpenScriptCommand()
|
private static void OnOpenScriptCommand()
|
||||||
{
|
{
|
||||||
Messenger.Default.Send(new NotificationMessage("OpenScript"));
|
Messenger.Default.Send(new NotificationMessage("OpenScript"));
|
||||||
|
|
|
@ -7,5 +7,8 @@
|
||||||
<package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" />
|
<package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" />
|
||||||
<package id="Fluent.Ribbon" version="3.4.0" targetFramework="net451" />
|
<package id="Fluent.Ribbon" version="3.4.0" targetFramework="net451" />
|
||||||
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
|
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
|
||||||
|
<package id="NLog" version="4.0.1" targetFramework="net451" />
|
||||||
|
<package id="NLog.Config" version="4.0.1" targetFramework="net451" />
|
||||||
|
<package id="NLog.Schema" version="4.0.1" targetFramework="net451" />
|
||||||
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" />
|
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue