added NLog to lib folder for logging
added log configuration to ANX.Framework assembly added debug logging to ANX.Inputsystem.Windows.XInput and ANX.Framework
This commit is contained in:
parent
dd640f61e2
commit
f931832502
@ -36,6 +36,10 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\lib\NLog\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@ -459,6 +463,11 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Content\MediaTypeReaders\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
@ -7,6 +7,7 @@ using System.Threading;
|
||||
using ANX.Framework.Content;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using NLog;
|
||||
|
||||
#endregion // Using Statements
|
||||
|
||||
@ -61,6 +62,8 @@ namespace ANX.Framework
|
||||
{
|
||||
public class Game : IDisposable
|
||||
{
|
||||
private static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IGraphicsDeviceManager graphicsDeviceManager;
|
||||
private IGraphicsDeviceService graphicsDeviceService;
|
||||
private GameServiceContainer gameServices;
|
||||
@ -98,15 +101,22 @@ namespace ANX.Framework
|
||||
|
||||
public Game(String renderSystemName = "DirectX10", String inputSystemName = "XInput", String soundSystemName = "XAudio")
|
||||
{
|
||||
logger.Info("created a new Game-Class");
|
||||
logger.Info("- asked for RenderSystem '{0}'", renderSystemName);
|
||||
logger.Info("- asked for InputSystem '{0}'", inputSystemName);
|
||||
logger.Info("- asked for SoundSystem '{0}'", soundSystemName);
|
||||
|
||||
this.gameServices = new GameServiceContainer();
|
||||
this.gameTime = new GameTime();
|
||||
|
||||
try
|
||||
{
|
||||
AddInSystemFactory.Instance.Initialize();
|
||||
logger.Info("initializing AddInSystemFactory");
|
||||
AddInSystemFactory.Instance.Initialize();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error while initializing AddInSystem.", ex);
|
||||
throw new AddInLoadingException("Error while initializing AddInSystem.", ex);
|
||||
}
|
||||
|
||||
@ -116,6 +126,7 @@ namespace ANX.Framework
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException(String.Format("Error during loading InputSystem {0}", inputSystemName), ex);
|
||||
throw new AddInLoadingException(String.Format("Error during loading InputSystem {0}", inputSystemName), ex);
|
||||
}
|
||||
IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>();
|
||||
@ -124,12 +135,14 @@ namespace ANX.Framework
|
||||
this.gameServices.AddService(typeof(IInputSystemCreator), inputSystemCreator);
|
||||
}
|
||||
|
||||
try{
|
||||
AddInSystemFactory.Instance.SetDefaultCreator(soundSystemName);
|
||||
try
|
||||
{
|
||||
AddInSystemFactory.Instance.SetDefaultCreator(soundSystemName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new AddInLoadingException(String.Format("Error during loading SoundSystem {0}", inputSystemName), ex);
|
||||
logger.ErrorException(String.Format("Error during loading SoundSystem {0}", soundSystemName), ex);
|
||||
throw new AddInLoadingException(String.Format("Error during loading SoundSystem {0}", soundSystemName), ex);
|
||||
}
|
||||
|
||||
ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
|
||||
@ -140,11 +153,12 @@ namespace ANX.Framework
|
||||
|
||||
try
|
||||
{
|
||||
AddInSystemFactory.Instance.SetDefaultCreator(renderSystemName);
|
||||
AddInSystemFactory.Instance.SetDefaultCreator(renderSystemName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new AddInLoadingException(String.Format("Error during loading RenderSystem {0}", inputSystemName), ex);
|
||||
logger.ErrorException(String.Format("Error during loading RenderSystem {0}", renderSystemName), ex);
|
||||
throw new AddInLoadingException(String.Format("Error during loading RenderSystem {0}", renderSystemName), ex);
|
||||
}
|
||||
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||
if (renderSystemCreator != null)
|
||||
@ -152,6 +166,8 @@ namespace ANX.Framework
|
||||
this.gameServices.AddService(typeof(IRenderSystemCreator), renderSystemCreator);
|
||||
}
|
||||
|
||||
logger.Info("creating GameHost");
|
||||
|
||||
//TODO: error handling if creator is null
|
||||
this.host = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateGameHost(this);
|
||||
|
||||
@ -162,13 +178,17 @@ namespace ANX.Framework
|
||||
this.host.Idle += new EventHandler<EventArgs>(this.HostIdle);
|
||||
this.host.Exiting += new EventHandler<EventArgs>(this.HostExiting);
|
||||
|
||||
logger.Info("creating ContentManager");
|
||||
this.content = new ContentManager(this.gameServices);
|
||||
|
||||
logger.Info("creating GameTimer");
|
||||
this.clock = new GameTimer();
|
||||
this.isFixedTimeStep = true;
|
||||
this.gameUpdateTime = new GameTime();
|
||||
this.inactiveSleepTime = TimeSpan.Zero;
|
||||
this.targetElapsedTime = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / 60L); // default is 1/60s
|
||||
|
||||
logger.Info("finished initializing new Game class");
|
||||
}
|
||||
|
||||
~Game()
|
||||
|
15
ANX.Framework/NLog.config
Normal file
15
ANX.Framework/NLog.config
Normal file
@ -0,0 +1,15 @@
|
||||
<?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">
|
||||
|
||||
<!-- make sure to set 'Copy To Output Directory' option for this file -->
|
||||
<!-- go to http://nlog-project.org/wiki/Configuration_file for more information -->
|
||||
|
||||
<targets>
|
||||
<target name="file" xsi:type="File" fileName="${basedir}/log.txt" deleteOldFileOnStartup="true" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="file" />
|
||||
</rules>
|
||||
</nlog>
|
@ -5,6 +5,7 @@ using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ANX.Framework.Input;
|
||||
using NLog;
|
||||
|
||||
#endregion // Using Statements
|
||||
|
||||
@ -64,6 +65,8 @@ namespace ANX.Framework.NonXNA
|
||||
private bool initialized;
|
||||
private Dictionary<Type, ICreator> defaultCreators = new Dictionary<Type, ICreator>();
|
||||
|
||||
private static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static AddInSystemFactory Instance
|
||||
{
|
||||
get
|
||||
@ -71,6 +74,7 @@ namespace ANX.Framework.NonXNA
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new AddInSystemFactory();
|
||||
logger.Debug("Created AddInSystemFactory instance");
|
||||
}
|
||||
|
||||
return instance;
|
||||
@ -86,12 +90,16 @@ namespace ANX.Framework.NonXNA
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
logger.Info("[ANX] Initializing ANX.Framework AddInSystemFactory...");
|
||||
|
||||
String executingAssembly = Assembly.GetExecutingAssembly().Location;
|
||||
|
||||
foreach (String file in Directory.EnumerateFiles(Path.GetDirectoryName(executingAssembly), "*.dll", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
if (!file.Equals(executingAssembly))
|
||||
{
|
||||
logger.Info("[ANX] trying to load '{0}'...", file);
|
||||
|
||||
Assembly part = null;
|
||||
|
||||
try
|
||||
@ -100,16 +108,20 @@ namespace ANX.Framework.NonXNA
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
logger.Debug("error calling Assembly.LoadFile({0}) Exception: {1}", file, ex.Message);
|
||||
}
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
logger.Info("[ANX] scanning for ANX interfaces...");
|
||||
|
||||
foreach (Type t in part.GetTypes().Where(p => typeof(IInputSystemCreator).IsAssignableFrom(p) ||
|
||||
typeof(IRenderSystemCreator).IsAssignableFrom(p) ||
|
||||
typeof(ISoundSystemCreator).IsAssignableFrom(p)
|
||||
))
|
||||
{
|
||||
logger.Info("[ANX] registering instance of '{0}'...", t.FullName);
|
||||
|
||||
var instance = part.CreateInstance(t.FullName);
|
||||
((ICreator)instance).RegisterCreator(this);
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
[assembly: AssemblyVersion("0.4.19.*")]
|
||||
[assembly: AssemblyFileVersion("0.4.19.0")]
|
||||
[assembly: AssemblyVersion("0.4.20.*")]
|
||||
[assembly: AssemblyFileVersion("0.4.20.0")]
|
||||
|
||||
[assembly:InternalsVisibleTo("ANX.Framework.Windows.DX10")]
|
||||
[assembly:InternalsVisibleTo("ANX.Framework.Windows.DX11.1")]
|
||||
|
@ -31,6 +31,10 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\NLog\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\SharpDX.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using NLog;
|
||||
|
||||
#endregion // Using Statements
|
||||
|
||||
@ -60,33 +61,47 @@ namespace ANX.InputSystem.Windows.XInput
|
||||
{
|
||||
public class Creator : IInputSystemCreator
|
||||
{
|
||||
|
||||
private static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "XInput"; }
|
||||
}
|
||||
|
||||
public IGamePad GamePad
|
||||
{
|
||||
get { return new GamePad(); }
|
||||
get
|
||||
{
|
||||
return "XInput";
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCreator(AddInSystemFactory factory)
|
||||
{
|
||||
logger.Debug("adding XInput creator to creator collection of AddInSystemFactory");
|
||||
factory.AddCreator(this);
|
||||
}
|
||||
|
||||
|
||||
public IGamePad GamePad
|
||||
{
|
||||
get
|
||||
{
|
||||
logger.Debug("returning a new XInput GamePad device");
|
||||
return new GamePad();
|
||||
}
|
||||
}
|
||||
|
||||
public IMouse Mouse
|
||||
{
|
||||
get { return new Mouse(); }
|
||||
get
|
||||
{
|
||||
logger.Debug("returning a new XInput Mouse device");
|
||||
return new Mouse();
|
||||
}
|
||||
}
|
||||
|
||||
public IKeyboard Keyboard
|
||||
{
|
||||
get { return new Keyboard(); }
|
||||
get
|
||||
{
|
||||
logger.Debug("returning a new XInput Keyboard device");
|
||||
return new Keyboard();
|
||||
}
|
||||
}
|
||||
|
||||
#if XNAEXT
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.6.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.6.0.0")]
|
||||
[assembly: AssemblyVersion("0.6.1.0")]
|
||||
[assembly: AssemblyFileVersion("0.6.1.0")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user