mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Expanded logging
This commit is contained in:
parent
2f4384ef06
commit
0e50978f98
@ -280,7 +280,7 @@
|
|||||||
</Artemis.Modules.Effects.Bubbles.Bubbles>
|
</Artemis.Modules.Effects.Bubbles.Bubbles>
|
||||||
<Artemis.Settings.General>
|
<Artemis.Settings.General>
|
||||||
<setting name="LastEffect" serializeAs="String">
|
<setting name="LastEffect" serializeAs="String">
|
||||||
<value>TypeWave</value>
|
<value>WindowsProfile</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="LastKeyboard" serializeAs="String">
|
<setting name="LastKeyboard" serializeAs="String">
|
||||||
<value />
|
<value />
|
||||||
@ -306,6 +306,9 @@
|
|||||||
<setting name="Theme" serializeAs="String">
|
<setting name="Theme" serializeAs="String">
|
||||||
<value>Light</value>
|
<value>Light</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="LogLevel" serializeAs="String">
|
||||||
|
<value>Info</value>
|
||||||
|
</setting>
|
||||||
</Artemis.Settings.General>
|
</Artemis.Settings.General>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
<runtime>
|
<runtime>
|
||||||
|
|||||||
@ -38,8 +38,8 @@
|
|||||||
<SupportUrl>https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-%28FAQ%29</SupportUrl>
|
<SupportUrl>https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-%28FAQ%29</SupportUrl>
|
||||||
<ProductName>Artemis</ProductName>
|
<ProductName>Artemis</ProductName>
|
||||||
<PublisherName>Artemis</PublisherName>
|
<PublisherName>Artemis</PublisherName>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>2</ApplicationRevision>
|
||||||
<ApplicationVersion>1.1.3.0</ApplicationVersion>
|
<ApplicationVersion>1.1.3.2</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
@ -452,6 +452,7 @@
|
|||||||
<Compile Include="Utilities\Keyboard\KeyboardHook.cs" />
|
<Compile Include="Utilities\Keyboard\KeyboardHook.cs" />
|
||||||
<Compile Include="Utilities\Layers\AnimationUpdater.cs" />
|
<Compile Include="Utilities\Layers\AnimationUpdater.cs" />
|
||||||
<Compile Include="Utilities\Layers\Drawer.cs" />
|
<Compile Include="Utilities\Layers\Drawer.cs" />
|
||||||
|
<Compile Include="Utilities\Logging.cs" />
|
||||||
<Compile Include="Utilities\LogitechDll\DllManager.cs" />
|
<Compile Include="Utilities\LogitechDll\DllManager.cs" />
|
||||||
<Compile Include="Utilities\LogitechDll\NamedPipeServer.cs" />
|
<Compile Include="Utilities\LogitechDll\NamedPipeServer.cs" />
|
||||||
<Compile Include="Utilities\LogitechDll\PipeServer.cs" />
|
<Compile Include="Utilities\LogitechDll\PipeServer.cs" />
|
||||||
@ -616,9 +617,6 @@
|
|||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
|
<LastGenOutput>VolumeDisplay.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
<Content Include="NLog.config">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<None Include="NLog.xsd">
|
<None Include="NLog.xsd">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System.Windows;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Artemis.InjectionModules;
|
using Artemis.InjectionModules;
|
||||||
|
using Artemis.Utilities;
|
||||||
using Artemis.ViewModels;
|
using Artemis.ViewModels;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
@ -20,6 +21,9 @@ namespace Artemis
|
|||||||
|
|
||||||
public ArtemisBootstrapper()
|
public ArtemisBootstrapper()
|
||||||
{
|
{
|
||||||
|
// Start logging before anything else
|
||||||
|
Logging.SetupLogging(Settings.General.Default.LogLevel);
|
||||||
|
|
||||||
CheckDuplicateInstances();
|
CheckDuplicateInstances();
|
||||||
Initialize();
|
Initialize();
|
||||||
BindSpecialValues();
|
BindSpecialValues();
|
||||||
|
|||||||
@ -25,8 +25,6 @@ namespace Artemis.Managers
|
|||||||
public DeviceManager(IEventAggregator events, ILogger logger, List<DeviceProvider> deviceProviders)
|
public DeviceManager(IEventAggregator events, ILogger logger, List<DeviceProvider> deviceProviders)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logger.Info("Intializing DeviceManager");
|
|
||||||
|
|
||||||
_events = events;
|
_events = events;
|
||||||
|
|
||||||
KeyboardProviders = deviceProviders.Where(d => d.Type == DeviceType.Keyboard)
|
KeyboardProviders = deviceProviders.Where(d => d.Type == DeviceType.Keyboard)
|
||||||
@ -34,7 +32,7 @@ namespace Artemis.Managers
|
|||||||
MiceProviders = deviceProviders.Where(d => d.Type == DeviceType.Mouse).ToList();
|
MiceProviders = deviceProviders.Where(d => d.Type == DeviceType.Mouse).ToList();
|
||||||
HeadsetProviders = deviceProviders.Where(d => d.Type == DeviceType.Headset).ToList();
|
HeadsetProviders = deviceProviders.Where(d => d.Type == DeviceType.Headset).ToList();
|
||||||
|
|
||||||
_logger.Info("Intialized DeviceManager");
|
_logger.Info("Intialized DeviceManager with {0} device providers", deviceProviders.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DeviceProvider> HeadsetProviders { get; set; }
|
public List<DeviceProvider> HeadsetProviders { get; set; }
|
||||||
|
|||||||
@ -23,8 +23,6 @@ namespace Artemis.Managers
|
|||||||
public EffectManager(ILogger logger, IEventAggregator events, DeviceManager deviceManager)
|
public EffectManager(ILogger logger, IEventAggregator events, DeviceManager deviceManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logger.Info("Intializing EffectManager");
|
|
||||||
|
|
||||||
_events = events;
|
_events = events;
|
||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,8 @@ namespace Artemis.Managers
|
|||||||
_loopTimer = new Timer(40);
|
_loopTimer = new Timer(40);
|
||||||
_loopTimer.Elapsed += Render;
|
_loopTimer.Elapsed += Render;
|
||||||
_loopTimer.Start();
|
_loopTimer.Start();
|
||||||
|
|
||||||
|
_logger.Info("Intialized LoopManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -23,22 +23,19 @@ namespace Artemis.Managers
|
|||||||
public delegate void PauseCallbackHandler();
|
public delegate void PauseCallbackHandler();
|
||||||
|
|
||||||
private readonly IEventAggregator _events;
|
private readonly IEventAggregator _events;
|
||||||
private readonly ILogger _logger;
|
|
||||||
private readonly Timer _processTimer;
|
private readonly Timer _processTimer;
|
||||||
|
|
||||||
public MainManager(IEventAggregator events, ILogger logger, LoopManager loopManager,
|
public MainManager(IEventAggregator events, ILogger logger, LoopManager loopManager,
|
||||||
DeviceManager deviceManager, EffectManager effectManager, ProfileManager profileManager)
|
DeviceManager deviceManager, EffectManager effectManager, ProfileManager profileManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_events = events;
|
||||||
|
|
||||||
|
Logger = logger;
|
||||||
LoopManager = loopManager;
|
LoopManager = loopManager;
|
||||||
DeviceManager = deviceManager;
|
DeviceManager = deviceManager;
|
||||||
EffectManager = effectManager;
|
EffectManager = effectManager;
|
||||||
ProfileManager = profileManager;
|
ProfileManager = profileManager;
|
||||||
|
|
||||||
_logger.Info("Intializing MainManager");
|
|
||||||
|
|
||||||
_events = events;
|
|
||||||
|
|
||||||
_processTimer = new Timer(1000);
|
_processTimer = new Timer(1000);
|
||||||
_processTimer.Elapsed += ScanProcesses;
|
_processTimer.Elapsed += ScanProcesses;
|
||||||
_processTimer.Start();
|
_processTimer.Start();
|
||||||
@ -57,12 +54,13 @@ namespace Artemis.Managers
|
|||||||
PipeServer = new PipeServer();
|
PipeServer = new PipeServer();
|
||||||
PipeServer.Start("artemis");
|
PipeServer.Start("artemis");
|
||||||
|
|
||||||
_logger.Info("Intialized MainManager");
|
Logger.Info("Intialized MainManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public Lazy<ShellViewModel> ShellViewModel { get; set; }
|
public Lazy<ShellViewModel> ShellViewModel { get; set; }
|
||||||
|
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
public LoopManager LoopManager { get; }
|
public LoopManager LoopManager { get; }
|
||||||
public DeviceManager DeviceManager { get; set; }
|
public DeviceManager DeviceManager { get; set; }
|
||||||
public EffectManager EffectManager { get; set; }
|
public EffectManager EffectManager { get; set; }
|
||||||
@ -76,7 +74,7 @@ namespace Artemis.Managers
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_logger.Debug("Shutting down MainManager");
|
Logger.Debug("Shutting down MainManager");
|
||||||
|
|
||||||
_processTimer?.Stop();
|
_processTimer?.Stop();
|
||||||
_processTimer?.Dispose();
|
_processTimer?.Dispose();
|
||||||
@ -91,7 +89,7 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnableProgram()
|
public void EnableProgram()
|
||||||
{
|
{
|
||||||
_logger.Debug("Enabling program");
|
Logger.Debug("Enabling program");
|
||||||
ProgramEnabled = true;
|
ProgramEnabled = true;
|
||||||
LoopManager.StartAsync();
|
LoopManager.StartAsync();
|
||||||
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||||
@ -102,7 +100,7 @@ namespace Artemis.Managers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void DisableProgram()
|
public void DisableProgram()
|
||||||
{
|
{
|
||||||
_logger.Debug("Disabling program");
|
Logger.Debug("Disabling program");
|
||||||
LoopManager.Stop();
|
LoopManager.Stop();
|
||||||
ProgramEnabled = false;
|
ProgramEnabled = false;
|
||||||
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
_events.PublishOnUIThread(new ToggleEnabled(ProgramEnabled));
|
||||||
@ -133,7 +131,7 @@ namespace Artemis.Managers
|
|||||||
{
|
{
|
||||||
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
|
if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
|
||||||
{
|
{
|
||||||
_logger.Info("Disabling game: {0}", activeGame.Name);
|
Logger.Info("Disabling game: {0}", activeGame.Name);
|
||||||
EffectManager.DisableGame(activeGame);
|
EffectManager.DisableGame(activeGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +144,7 @@ namespace Artemis.Managers
|
|||||||
if (newGame == null || EffectManager.ActiveEffect == newGame)
|
if (newGame == null || EffectManager.ActiveEffect == newGame)
|
||||||
return;
|
return;
|
||||||
// If it's not already enabled, do so.
|
// If it's not already enabled, do so.
|
||||||
_logger.Info("Detected and enabling game: {0}", newGame.Name);
|
Logger.Info("Detected and enabling game: {0}", newGame.Name);
|
||||||
EffectManager.ChangeEffect(newGame, LoopManager);
|
EffectManager.ChangeEffect(newGame, LoopManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,8 @@ namespace Artemis.Managers
|
|||||||
var profilePreviewTimer = new Timer(500);
|
var profilePreviewTimer = new Timer(500);
|
||||||
profilePreviewTimer.Elapsed += SetupProfilePreview;
|
profilePreviewTimer.Elapsed += SetupProfilePreview;
|
||||||
profilePreviewTimer.Start();
|
profilePreviewTimer.Start();
|
||||||
|
|
||||||
|
_logger.Info("Intialized ProfileManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfilePreviewModel ProfilePreviewModel { get; set; }
|
public ProfilePreviewModel ProfilePreviewModel { get; set; }
|
||||||
|
|||||||
@ -5,6 +5,8 @@ using System.Linq;
|
|||||||
using Artemis.Managers;
|
using Artemis.Managers;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Models.Profiles;
|
using Artemis.Models.Profiles;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NLog;
|
||||||
using Brush = System.Windows.Media.Brush;
|
using Brush = System.Windows.Media.Brush;
|
||||||
|
|
||||||
namespace Artemis.Models
|
namespace Artemis.Models
|
||||||
@ -16,6 +18,7 @@ namespace Artemis.Models
|
|||||||
public bool Initialized;
|
public bool Initialized;
|
||||||
public MainManager MainManager;
|
public MainManager MainManager;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
private DateTime _lastTrace;
|
||||||
|
|
||||||
protected EffectModel(MainManager mainManager, IDataModel dataModel)
|
protected EffectModel(MainManager mainManager, IDataModel dataModel)
|
||||||
{
|
{
|
||||||
@ -49,6 +52,18 @@ namespace Artemis.Models
|
|||||||
// Get all enabled layers who's conditions are met
|
// Get all enabled layers who's conditions are met
|
||||||
var renderLayers = GetRenderLayers(renderMice, renderHeadsets);
|
var renderLayers = GetRenderLayers(renderMice, renderHeadsets);
|
||||||
|
|
||||||
|
// Trace debugging
|
||||||
|
if (DateTime.Now.AddSeconds(-2) > _lastTrace)
|
||||||
|
{
|
||||||
|
_lastTrace = DateTime.Now;
|
||||||
|
MainManager.Logger.Trace("Effect datamodel as JSON: \r\n{0}",
|
||||||
|
JsonConvert.SerializeObject(DataModel, Formatting.Indented));
|
||||||
|
MainManager.Logger.Trace("Effect {0} has to render {1} layers", Name, renderLayers.Count);
|
||||||
|
foreach (var renderLayer in renderLayers)
|
||||||
|
MainManager.Logger.Trace(" Layer name: {0}, layer type: {1}", renderLayer.Name,
|
||||||
|
renderLayer.LayerType);
|
||||||
|
}
|
||||||
|
|
||||||
// Render the keyboard layer-by-layer
|
// Render the keyboard layer-by-layer
|
||||||
keyboard = Profile.GenerateBitmap(renderLayers, DataModel,
|
keyboard = Profile.GenerateBitmap(renderLayers, DataModel,
|
||||||
MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(4), false, true);
|
MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(4), false, true);
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
<?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 name="file"
|
|
||||||
xsi:type="File"
|
|
||||||
maxArchiveFiles="7"
|
|
||||||
fileName="${specialfolder:folder=MyDocuments}/Artemis/logs/${shortdate}.txt"
|
|
||||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}" />
|
|
||||||
|
|
||||||
<target name="debugger"
|
|
||||||
xsi:type="Debugger"
|
|
||||||
layout="${logger:shortName=True} - ${uppercase:${level}}: ${message}" />
|
|
||||||
</targets>
|
|
||||||
|
|
||||||
<rules>
|
|
||||||
<logger name="*" minlevel="Debug" writeTo="file" />
|
|
||||||
<logger name="*" minlevel="Debug" writeTo="debugger" />
|
|
||||||
</rules>
|
|
||||||
</nlog>
|
|
||||||
14
Artemis/Artemis/Settings/General.Designer.cs
generated
14
Artemis/Artemis/Settings/General.Designer.cs
generated
@ -25,7 +25,7 @@ namespace Artemis.Settings {
|
|||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("TypeWave")]
|
[global::System.Configuration.DefaultSettingValueAttribute("WindowsProfile")]
|
||||||
public string LastEffect {
|
public string LastEffect {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["LastEffect"]));
|
return ((string)(this["LastEffect"]));
|
||||||
@ -130,5 +130,17 @@ namespace Artemis.Settings {
|
|||||||
this["Theme"] = value;
|
this["Theme"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("Info")]
|
||||||
|
public string LogLevel {
|
||||||
|
get {
|
||||||
|
return ((string)(this["LogLevel"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["LogLevel"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
|
|
||||||
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
|
|
||||||
<Profiles />
|
<Profiles />
|
||||||
<Settings>
|
<Settings>
|
||||||
<Setting Name="LastEffect" Type="System.String" Scope="User">
|
<Setting Name="LastEffect" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)">TypeWave</Value>
|
<Value Profile="(Default)">WindowsProfile</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="LastKeyboard" Type="System.String" Scope="User">
|
<Setting Name="LastKeyboard" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)" />
|
<Value Profile="(Default)" />
|
||||||
@ -31,5 +29,8 @@
|
|||||||
<Setting Name="Theme" Type="System.String" Scope="User">
|
<Setting Name="Theme" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)">Light</Value>
|
<Value Profile="(Default)">Light</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="LogLevel" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)">Info</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@ -5,6 +5,7 @@ using System.Runtime.InteropServices.ComTypes;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using MahApps.Metro;
|
using MahApps.Metro;
|
||||||
|
using NLog;
|
||||||
|
|
||||||
namespace Artemis.Settings
|
namespace Artemis.Settings
|
||||||
{
|
{
|
||||||
@ -76,6 +77,16 @@ namespace Artemis.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string LogLevel
|
||||||
|
{
|
||||||
|
get { return General.Default.LogLevel; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (General.Default.LogLevel == value) return;
|
||||||
|
General.Default.LogLevel = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ApplyGamestatePort()
|
private void ApplyGamestatePort()
|
||||||
{
|
{
|
||||||
// TODO: Restart Gamestate server with new port
|
// TODO: Restart Gamestate server with new port
|
||||||
@ -103,6 +114,7 @@ namespace Artemis.Settings
|
|||||||
ApplyAutorun();
|
ApplyAutorun();
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
ApplyGamestatePort();
|
ApplyGamestatePort();
|
||||||
|
Logging.SetupLogging(LogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyTheme()
|
private void ApplyTheme()
|
||||||
@ -136,6 +148,7 @@ namespace Artemis.Settings
|
|||||||
CheckForUpdates = true;
|
CheckForUpdates = true;
|
||||||
ShowOnStartup = true;
|
ShowOnStartup = true;
|
||||||
Theme = "Light";
|
Theme = "Light";
|
||||||
|
LogLevel = "Info";
|
||||||
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
47
Artemis/Artemis/Utilities/Logging.cs
Normal file
47
Artemis/Artemis/Utilities/Logging.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.Targets;
|
||||||
|
|
||||||
|
namespace Artemis.Utilities
|
||||||
|
{
|
||||||
|
public static class Logging
|
||||||
|
{
|
||||||
|
public static void SetupLogging(string logLevel)
|
||||||
|
{
|
||||||
|
SetupLogging(LogLevel.FromString(logLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetupLogging(LogLevel logLevel)
|
||||||
|
{
|
||||||
|
// Step 1. Create configuration object
|
||||||
|
var config = new LoggingConfiguration();
|
||||||
|
|
||||||
|
// Step 2. Create targets and add them to the configuration
|
||||||
|
var debuggerTarget = new DebuggerTarget();
|
||||||
|
config.AddTarget("debugger", debuggerTarget);
|
||||||
|
|
||||||
|
var fileTarget = new FileTarget();
|
||||||
|
config.AddTarget("file", fileTarget);
|
||||||
|
|
||||||
|
// Step 3. Set target properties
|
||||||
|
debuggerTarget.Layout = @"${logger:shortName=True} - ${uppercase:${level}}: ${message}";
|
||||||
|
fileTarget.FileName = "${specialfolder:folder=MyDocuments}/Artemis/logs/${shortdate}.txt";
|
||||||
|
fileTarget.Layout = "${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}";
|
||||||
|
fileTarget.ArchiveEvery = FileArchivePeriod.Day;
|
||||||
|
fileTarget.MaxArchiveFiles = 7;
|
||||||
|
|
||||||
|
// Step 4. Define rules
|
||||||
|
var rule1 = new LoggingRule("*", logLevel, debuggerTarget);
|
||||||
|
config.LoggingRules.Add(rule1);
|
||||||
|
var rule2 = new LoggingRule("*", logLevel, fileTarget);
|
||||||
|
config.LoggingRules.Add(rule2);
|
||||||
|
|
||||||
|
// Step 5. Activate the configuration
|
||||||
|
LogManager.Configuration = config;
|
||||||
|
|
||||||
|
// Log as fatal so it always shows
|
||||||
|
var logger = LogManager.GetCurrentClassLogger();
|
||||||
|
logger.Fatal("INFO: Set log level to {0}", logLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,9 +7,7 @@ using Artemis.Settings;
|
|||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Targets;
|
|
||||||
using ILogger = Ninject.Extensions.Logging.ILogger;
|
using ILogger = Ninject.Extensions.Logging.ILogger;
|
||||||
using LogManager = NLog.LogManager;
|
|
||||||
|
|
||||||
namespace Artemis.ViewModels.Flyouts
|
namespace Artemis.ViewModels.Flyouts
|
||||||
{
|
{
|
||||||
@ -31,9 +29,11 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
Position = Position.Right;
|
Position = Position.Right;
|
||||||
GeneralSettings = new GeneralSettings();
|
GeneralSettings = new GeneralSettings();
|
||||||
|
|
||||||
|
LogLevels = new BindableCollection<string>();
|
||||||
|
LogLevels.AddRange(LogLevel.AllLoggingLevels.Select(l => l.Name));
|
||||||
|
|
||||||
PropertyChanged += KeyboardUpdater;
|
PropertyChanged += KeyboardUpdater;
|
||||||
events.Subscribe(this);
|
events.Subscribe(this);
|
||||||
ApplyLogging();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MainManager MainManager { get; set; }
|
public MainManager MainManager { get; set; }
|
||||||
@ -71,8 +71,15 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindableCollection<string> Themes
|
public BindableCollection<string> Themes => new BindableCollection<string>
|
||||||
=> new BindableCollection<string> {"Light", "Dark", "Corsair Light", "Corsair Dark"};
|
{
|
||||||
|
"Light",
|
||||||
|
"Dark",
|
||||||
|
"Corsair Light",
|
||||||
|
"Corsair Dark"
|
||||||
|
};
|
||||||
|
|
||||||
|
public BindableCollection<string> LogLevels { get; set; }
|
||||||
|
|
||||||
public string SelectedTheme
|
public string SelectedTheme
|
||||||
{
|
{
|
||||||
@ -85,6 +92,17 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string SelectedLogLevel
|
||||||
|
{
|
||||||
|
get { return GeneralSettings.LogLevel; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == GeneralSettings.LogLevel) return;
|
||||||
|
GeneralSettings.LogLevel = value;
|
||||||
|
NotifyOfPropertyChange(() => SelectedLogLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string SelectedKeyboardProvider
|
public string SelectedKeyboardProvider
|
||||||
{
|
{
|
||||||
get { return _selectedKeyboardProvider; }
|
get { return _selectedKeyboardProvider; }
|
||||||
@ -130,27 +148,6 @@ namespace Artemis.ViewModels.Flyouts
|
|||||||
NotifyOfPropertyChange(() => Enabled);
|
NotifyOfPropertyChange(() => Enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO https://github.com/ninject/Ninject.Extensions.Logging/issues/35
|
|
||||||
private void ApplyLogging()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
var c = LogManager.Configuration;
|
|
||||||
var file = c.FindTargetByName("file") as FileTarget;
|
|
||||||
if (file == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var rule = c.LoggingRules.FirstOrDefault(r => r.Targets.Contains(file));
|
|
||||||
if (rule == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (EnableDebug)
|
|
||||||
rule.EnableLoggingForLevel(LogLevel.Debug);
|
|
||||||
rule.DisableLoggingForLevel(LogLevel.Debug);
|
|
||||||
|
|
||||||
LogManager.ReconfigExistingLoggers();
|
|
||||||
_logger.Info("Set debug logging to: {0}", EnableDebug);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Takes proper action when the selected keyboard is changed in the UI
|
/// Takes proper action when the selected keyboard is changed in the UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -4,12 +4,22 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
xmlns:cal="http://www.caliburnproject.org"
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
|
xmlns:utilities="clr-namespace:Artemis.Utilities"
|
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
|
xmlns:profileEnumerations="clr-namespace:Artemis.Models.Profiles"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="600" d:DesignWidth="300"
|
d:DesignHeight="600" d:DesignWidth="300"
|
||||||
Width="300">
|
Width="300">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
|
<utilities:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
||||||
|
<ObjectDataProvider MethodName="GetValues"
|
||||||
|
ObjectType="{x:Type sys:Enum}"
|
||||||
|
x:Key="LayerEnumValues">
|
||||||
|
<ObjectDataProvider.MethodParameters>
|
||||||
|
<x:Type TypeName="profileEnumerations:LayerType" />
|
||||||
|
</ObjectDataProvider.MethodParameters>
|
||||||
|
</ObjectDataProvider>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
@ -27,6 +37,7 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
@ -86,16 +97,23 @@
|
|||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
|
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
|
||||||
IsChecked="{Binding Path=GeneralSettings.EnablePointersUpdate, Mode=TwoWay}" />
|
IsChecked="{Binding Path=GeneralSettings.EnablePointersUpdate, Mode=TwoWay}" />
|
||||||
|
|
||||||
|
<!-- Logging -->
|
||||||
|
<Label Grid.Row="8" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||||
|
Content="Log level:" />
|
||||||
|
<ComboBox Grid.Row="8" Grid.Column="1" x:Name="LogLevels" Margin="10" VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Width="140" />
|
||||||
|
|
||||||
<!-- Buttons -->
|
<!-- Buttons -->
|
||||||
<Button Grid.Row="8" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings"
|
<Button Grid.Row="9" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Left" Width="120"
|
VerticalAlignment="Center" HorizontalAlignment="Left" Width="120"
|
||||||
Style="{DynamicResource SquareButtonStyle}" />
|
Style="{DynamicResource SquareButtonStyle}" />
|
||||||
<Button Grid.Row="8" Grid.Column="1" Margin="10" x:Name="SaveSettings" Content="Save changes"
|
<Button Grid.Row="9" Grid.Column="1" Margin="10" x:Name="SaveSettings" Content="Save changes"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="120"
|
VerticalAlignment="Center" HorizontalAlignment="Right" Width="120"
|
||||||
Style="{DynamicResource SquareButtonStyle}" />
|
Style="{DynamicResource SquareButtonStyle}" />
|
||||||
|
|
||||||
<!-- Version -->
|
<!-- Version -->
|
||||||
<Grid Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" VerticalAlignment="Bottom">
|
<Grid Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" Margin="10" VerticalAlignment="Bottom">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user