Tweaked Loggers
This commit is contained in:
@@ -6,10 +6,7 @@ namespace Diamond
|
|||||||
{
|
{
|
||||||
public abstract class GLObject : IDisposable
|
public abstract class GLObject : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
/// The logger for GLObject-related info
|
|
||||||
/// </summary>
|
|
||||||
protected internal static Logger Logger = LogManager.GetLogger(nameof(GLObject));
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The OpenGL object name
|
/// The OpenGL object name
|
||||||
|
|||||||
@@ -6,16 +6,20 @@
|
|||||||
throwExceptions="false"
|
throwExceptions="false"
|
||||||
internalLoggerLevel="Off" internalLoggerFile="c:\temp\nlog-internal.log">
|
internalLoggerLevel="Off" internalLoggerFile="c:\temp\nlog-internal.log">
|
||||||
|
|
||||||
<variable name="Layout" value="[${level}] ${logger}: ${message}" />
|
<variable name="fileHeader" value="[${date:format=HH\:mm\:ss.ff}] [${level}] ${logger:shortName=false}"/>
|
||||||
|
<variable name="debugHeader" value="[${level}] ${logger:shortName=true}"/>
|
||||||
|
|
||||||
<targets>
|
<targets>
|
||||||
<target xsi:type="File" name="file" fileName="$Log/${shortdate}.log"
|
<target name="logFile"
|
||||||
layout="${Layout}"/>
|
xsi:type="File"
|
||||||
<target xsi:type="Debugger" name="debug" layout="${Layout}"/>
|
fileName="${basedir}/logs/${date:format=yyyMMdd_HHmmss:cached=true}.log"
|
||||||
|
layout="${fileHeader}: ${message}" />
|
||||||
|
|
||||||
|
<target xsi:type="Debugger" name="debug" layout="${debugHeader}: ${message}"/>
|
||||||
</targets>
|
</targets>
|
||||||
|
|
||||||
<rules>
|
<rules>
|
||||||
<logger name="*" minlevel="Info" writeTo="file"/>
|
<logger name="*" minlevel="Debug" writeTo="logFile"/>
|
||||||
<logger name="*" minlevel="Trace" writeTo="debug"/>
|
<logger name="*" minlevel="Debug" writeTo="debug"/>
|
||||||
</rules>
|
</rules>
|
||||||
</nlog>
|
</nlog>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using NLog;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
|
||||||
namespace Diamond.Shaders
|
namespace Diamond.Shaders
|
||||||
@@ -11,6 +12,8 @@ namespace Diamond.Shaders
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Program : GLObject
|
public class Program : GLObject
|
||||||
{
|
{
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
#region Static
|
#region Static
|
||||||
|
|
||||||
private static Program _current;
|
private static Program _current;
|
||||||
@@ -23,13 +26,13 @@ namespace Diamond.Shaders
|
|||||||
get => _current;
|
get => _current;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!value?.Linked ?? false)
|
if (value != null && !value.Linked)
|
||||||
{
|
{
|
||||||
Logger.Error("Cannot use program {0}", value);
|
Logger.Error("Cannot use {0} because it is not linked", value);
|
||||||
value = null;
|
value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Debug("Using program {0}", value);
|
Logger.Debug("Using {0}", (object) value ?? "default program");
|
||||||
GL.UseProgram((_current = value)?.Id ?? 0);
|
GL.UseProgram((_current = value)?.Id ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using NLog;
|
||||||
using OpenTK.Graphics.OpenGL4;
|
using OpenTK.Graphics.OpenGL4;
|
||||||
|
|
||||||
namespace Diamond.Shaders
|
namespace Diamond.Shaders
|
||||||
@@ -9,6 +10,8 @@ namespace Diamond.Shaders
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class Shader : GLObject
|
public sealed class Shader : GLObject
|
||||||
{
|
{
|
||||||
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
#region Constructor, Delete()
|
#region Constructor, Delete()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Diamond.Shaders;
|
using Diamond.Shaders;
|
||||||
@@ -29,7 +30,7 @@ namespace hexworld
|
|||||||
{
|
{
|
||||||
base.OnUnload(e);
|
base.OnUnload(e);
|
||||||
|
|
||||||
_pgm.Dispose();
|
_pgm?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -38,6 +39,9 @@ namespace hexworld
|
|||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
|
||||||
_pgm = Program.FromFiles("res/obj.fs.glsl", "res/obj.vs.glsl");
|
_pgm = Program.FromFiles("res/obj.fs.glsl", "res/obj.vs.glsl");
|
||||||
|
|
||||||
|
Program.Current = _pgm;
|
||||||
|
Program.Current = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{AD9ED057-FB47-44CB-8839-22924B409706}</ProjectGuid>
|
<ProjectGuid>{AD9ED057-FB47-44CB-8839-22924B409706}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>hexworld</RootNamespace>
|
<RootNamespace>hexworld</RootNamespace>
|
||||||
<AssemblyName>hexworld</AssemblyName>
|
<AssemblyName>hexworld</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
@@ -33,6 +33,9 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<StartupObject />
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
|||||||
Reference in New Issue
Block a user