add SDL logger implementation
This commit is contained in:
parent
42db6d83ae
commit
e766bbf7bc
|
@ -47,6 +47,7 @@
|
||||||
<Compile Include="Input\SDLKeyboard.cs" />
|
<Compile Include="Input\SDLKeyboard.cs" />
|
||||||
<Compile Include="Input\SDLMouse.cs" />
|
<Compile Include="Input\SDLMouse.cs" />
|
||||||
<Compile Include="IO\SDLFileSystem.cs" />
|
<Compile Include="IO\SDLFileSystem.cs" />
|
||||||
|
<Compile Include="SDLLogger.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
50
Blarg.GameFramework.SDL2/SDLLogger.cs
Normal file
50
Blarg.GameFramework.SDL2/SDLLogger.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Blarg.GameFramework
|
||||||
|
{
|
||||||
|
public class SDLLogger : IPlatformLogger
|
||||||
|
{
|
||||||
|
StringBuilder _sb;
|
||||||
|
|
||||||
|
public SDLLogger()
|
||||||
|
{
|
||||||
|
_sb = new StringBuilder(8192);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Info(string category, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteLine("INFO", category, format, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Warn(string category, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteLine("WARN", category, format, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Error(string category, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteLine("ERROR", category, format, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Debug(string category, string format, params object[] args)
|
||||||
|
{
|
||||||
|
WriteLine("DEBUG", category, format, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WriteLine(string tag, string category, string format, params object[] args)
|
||||||
|
{
|
||||||
|
_sb.Clear();
|
||||||
|
|
||||||
|
var date = DateTime.Now;
|
||||||
|
|
||||||
|
_sb.AppendFormat("[{0:00}:{1:00}:{2:00},{3:000}] ", date.Hour, date.Minute, date.Second, date.Millisecond);
|
||||||
|
_sb.AppendFormat("[{0}] [{1}] ", tag, category);
|
||||||
|
_sb.AppendFormat(format, args);
|
||||||
|
_sb.Append(Environment.NewLine);
|
||||||
|
|
||||||
|
Console.Write(_sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue