Compare commits
3 Commits
v1.0.31-ma
...
v1.0.34-ma
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dd854a159a | ||
![]() |
879a373e6a | ||
![]() |
ec1b017946 |
@@ -61,11 +61,6 @@ namespace Torch.Server
|
|||||||
|
|
||||||
if (File.Exists(oldTorchCfg))
|
if (File.Exists(oldTorchCfg))
|
||||||
File.Move(oldTorchCfg, torchCfg, true);
|
File.Move(oldTorchCfg, torchCfg, true);
|
||||||
|
|
||||||
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
|
||||||
TorchLogManager.Configuration = new XmlLoggingConfiguration(newNlog);
|
|
||||||
LogManager.Configuration = TorchLogManager.Configuration;
|
|
||||||
LogManager.ReconfigExistingLoggers();
|
|
||||||
|
|
||||||
var config = Persistent<TorchConfig>.Load(torchCfg);
|
var config = Persistent<TorchConfig>.Load(torchCfg);
|
||||||
config.Data.InstanceName = instanceName;
|
config.Data.InstanceName = instanceName;
|
||||||
@@ -78,6 +73,12 @@ namespace Torch.Server
|
|||||||
|
|
||||||
var handler = new UnhandledExceptionHandler(config.Data, isService);
|
var handler = new UnhandledExceptionHandler(config.Data, isService);
|
||||||
AppDomain.CurrentDomain.UnhandledException += handler.OnUnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += handler.OnUnhandledException;
|
||||||
|
|
||||||
|
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
||||||
|
TorchLogManager.RegisterTargets(Environment.GetEnvironmentVariable("TORCH_LOG_EXTENSIONS_PATH") ??
|
||||||
|
Path.Combine(instancePath, "LoggingExtensions"));
|
||||||
|
|
||||||
|
TorchLogManager.SetConfiguration(new XmlLoggingConfiguration(newNlog));
|
||||||
|
|
||||||
var initializer = new Initializer(workingDir, config);
|
var initializer = new Initializer(workingDir, config);
|
||||||
if (!initializer.Initialize(args))
|
if (!initializer.Initialize(args))
|
||||||
|
@@ -42,9 +42,8 @@ namespace Torch.Patches
|
|||||||
|
|
||||||
private static void FixLogging()
|
private static void FixLogging()
|
||||||
{
|
{
|
||||||
|
TorchLogManager.RestoreGlobalConfiguration();
|
||||||
_setLogger(null, LogManager.GetLogger("GameAnalytics"));
|
_setLogger(null, LogManager.GetLogger("GameAnalytics"));
|
||||||
if (LogManager.Configuration is not XmlLoggingConfiguration)
|
|
||||||
LogManager.Configuration = TorchLogManager.Configuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool PatchLogger()
|
private static bool PatchLogger()
|
||||||
|
@@ -1,8 +1,41 @@
|
|||||||
using NLog.Config;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Loader;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
|
using NLog.Targets;
|
||||||
|
|
||||||
namespace Torch.Utils;
|
namespace Torch.Utils;
|
||||||
|
|
||||||
public static class TorchLogManager
|
public static class TorchLogManager
|
||||||
{
|
{
|
||||||
public static LoggingConfiguration Configuration { get; set; }
|
private static AssemblyLoadContext LoadContext = new("TorchLog");
|
||||||
|
|
||||||
|
public static LoggingConfiguration Configuration { get; private set; }
|
||||||
|
|
||||||
|
public static void SetConfiguration(LoggingConfiguration configuration)
|
||||||
|
{
|
||||||
|
Configuration = configuration;
|
||||||
|
LogManager.Configuration = configuration;
|
||||||
|
LogManager.ReconfigExistingLoggers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RegisterTargets(string dir)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(dir)) return;
|
||||||
|
|
||||||
|
foreach (var type in Directory.EnumerateFiles(dir, "*.dll").Select(LoadContext.LoadFromAssemblyPath)
|
||||||
|
.SelectMany(b => b.ExportedTypes)
|
||||||
|
.Where(b => b.GetCustomAttribute<TargetAttribute>() is { }))
|
||||||
|
{
|
||||||
|
Target.Register(type.GetCustomAttribute<TargetAttribute>()!.Name, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RestoreGlobalConfiguration()
|
||||||
|
{
|
||||||
|
SetConfiguration(Configuration);
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user