fixed game analytics logger crash
This commit is contained in:
@@ -63,7 +63,8 @@ namespace Torch.Server
|
|||||||
File.Move(oldTorchCfg, torchCfg, true);
|
File.Move(oldTorchCfg, torchCfg, true);
|
||||||
|
|
||||||
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
||||||
LogManager.Configuration = new XmlLoggingConfiguration(newNlog);
|
TorchLogManager.Configuration = new XmlLoggingConfiguration(newNlog);
|
||||||
|
LogManager.Configuration = TorchLogManager.Configuration;
|
||||||
LogManager.ReconfigExistingLoggers();
|
LogManager.ReconfigExistingLoggers();
|
||||||
|
|
||||||
var config = Persistent<TorchConfig>.Load(torchCfg);
|
var config = Persistent<TorchConfig>.Load(torchCfg);
|
||||||
|
@@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
using Torch.Managers.PatchManager;
|
using Torch.Managers.PatchManager;
|
||||||
|
using Torch.Utils;
|
||||||
|
|
||||||
namespace Torch.Patches
|
namespace Torch.Patches
|
||||||
{
|
{
|
||||||
@@ -36,16 +37,14 @@ namespace Torch.Patches
|
|||||||
_log.Warn("GALogger constructor is unknown. Logging may not function.");
|
_log.Warn("GALogger constructor is unknown. Logging may not function.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctx.GetPattern(ctor).Prefixes.Add(typeof(GameAnalyticsPatch).GetMethod(nameof(PatchLogger),
|
ctx.GetPattern(ctor).AddPrefix(nameof(PatchLogger));
|
||||||
BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FixLogging()
|
private static void FixLogging()
|
||||||
{
|
{
|
||||||
_setLogger(null, LogManager.GetLogger("GameAnalytics"));
|
_setLogger(null, LogManager.GetLogger("GameAnalytics"));
|
||||||
if (!(LogManager.Configuration is XmlLoggingConfiguration))
|
if (LogManager.Configuration is not XmlLoggingConfiguration)
|
||||||
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(
|
LogManager.Configuration = TorchLogManager.Configuration;
|
||||||
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? Environment.CurrentDirectory, "NLog.config"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool PatchLogger()
|
private static bool PatchLogger()
|
||||||
|
8
Torch/Utils/TorchLogManager.cs
Normal file
8
Torch/Utils/TorchLogManager.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using NLog.Config;
|
||||||
|
|
||||||
|
namespace Torch.Utils;
|
||||||
|
|
||||||
|
public static class TorchLogManager
|
||||||
|
{
|
||||||
|
public static LoggingConfiguration Configuration { get; set; }
|
||||||
|
}
|
Reference in New Issue
Block a user