Tweaked Loggers
This commit is contained in:
@@ -6,10 +6,7 @@ namespace Diamond
|
||||
{
|
||||
public abstract class GLObject : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger for GLObject-related info
|
||||
/// </summary>
|
||||
protected internal static Logger Logger = LogManager.GetLogger(nameof(GLObject));
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// The OpenGL object name
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
throwExceptions="false"
|
||||
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>
|
||||
<target xsi:type="File" name="file" fileName="$Log/${shortdate}.log"
|
||||
layout="${Layout}"/>
|
||||
<target xsi:type="Debugger" name="debug" layout="${Layout}"/>
|
||||
<target name="logFile"
|
||||
xsi:type="File"
|
||||
fileName="${basedir}/logs/${date:format=yyyMMdd_HHmmss:cached=true}.log"
|
||||
layout="${fileHeader}: ${message}" />
|
||||
|
||||
<target xsi:type="Debugger" name="debug" layout="${debugHeader}: ${message}"/>
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Info" writeTo="file"/>
|
||||
<logger name="*" minlevel="Trace" writeTo="debug"/>
|
||||
<logger name="*" minlevel="Debug" writeTo="logFile"/>
|
||||
<logger name="*" minlevel="Debug" writeTo="debug"/>
|
||||
</rules>
|
||||
</nlog>
|
||||
</nlog>
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace Diamond.Shaders
|
||||
@@ -11,6 +12,8 @@ namespace Diamond.Shaders
|
||||
/// </summary>
|
||||
public class Program : GLObject
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#region Static
|
||||
|
||||
private static Program _current;
|
||||
@@ -23,13 +26,13 @@ namespace Diamond.Shaders
|
||||
get => _current;
|
||||
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;
|
||||
}
|
||||
|
||||
Logger.Debug("Using program {0}", value);
|
||||
Logger.Debug("Using {0}", (object) value ?? "default program");
|
||||
GL.UseProgram((_current = value)?.Id ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace Diamond.Shaders
|
||||
@@ -9,6 +10,8 @@ namespace Diamond.Shaders
|
||||
/// </summary>
|
||||
public sealed class Shader : GLObject
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#region Constructor, Delete()
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Diamond.Shaders;
|
||||
@@ -29,7 +30,7 @@ namespace hexworld
|
||||
{
|
||||
base.OnUnload(e);
|
||||
|
||||
_pgm.Dispose();
|
||||
_pgm?.Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -38,6 +39,9 @@ namespace hexworld
|
||||
base.OnLoad(e);
|
||||
|
||||
_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>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AD9ED057-FB47-44CB-8839-22924B409706}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>hexworld</RootNamespace>
|
||||
<AssemblyName>hexworld</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
@@ -33,6 +33,9 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user