Compare commits
2 Commits
v1.0.31-ma
...
v1.0.33-ma
Author | SHA1 | Date | |
---|---|---|---|
![]() |
879a373e6a | ||
![]() |
ec1b017946 |
@@ -63,9 +63,7 @@ namespace Torch.Server
|
|||||||
File.Move(oldTorchCfg, torchCfg, true);
|
File.Move(oldTorchCfg, torchCfg, true);
|
||||||
|
|
||||||
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
Target.Register<LogViewerTarget>(nameof(LogViewerTarget));
|
||||||
TorchLogManager.Configuration = new XmlLoggingConfiguration(newNlog);
|
TorchLogManager.SetConfiguration(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;
|
||||||
@@ -84,6 +82,9 @@ namespace Torch.Server
|
|||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
||||||
TorchLauncher.Launch(workingDir, binDir);
|
TorchLauncher.Launch(workingDir, binDir);
|
||||||
|
TorchLogManager.SetConfiguration(TorchLogManager.Configuration,
|
||||||
|
Environment.GetEnvironmentVariable("TORCH_LOG_EXTENSIONS_PATH") ??
|
||||||
|
Path.Combine(instancePath, "LoggingExtensions"));
|
||||||
|
|
||||||
CopyNative(binDir);
|
CopyNative(binDir);
|
||||||
initializer.Run(isService, instanceName, instancePath);
|
initializer.Run(isService, instanceName, instancePath);
|
||||||
|
@@ -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,47 @@
|
|||||||
using NLog.Config;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Loader;
|
||||||
|
using NLog;
|
||||||
|
using NLog.Config;
|
||||||
|
|
||||||
namespace Torch.Utils;
|
namespace Torch.Utils;
|
||||||
|
|
||||||
public static class TorchLogManager
|
public static class TorchLogManager
|
||||||
{
|
{
|
||||||
public static LoggingConfiguration Configuration { get; set; }
|
private static AssemblyLoadContext LoadContext;
|
||||||
|
|
||||||
|
public static LoggingConfiguration Configuration { get; private set; }
|
||||||
|
|
||||||
|
public static void SetConfiguration(LoggingConfiguration configuration, string extensionsDir = null)
|
||||||
|
{
|
||||||
|
Configuration = configuration;
|
||||||
|
LogManager.Setup()
|
||||||
|
.SetupExtensions(builder =>
|
||||||
|
{
|
||||||
|
if (extensionsDir is null || !Directory.Exists(extensionsDir))
|
||||||
|
return;
|
||||||
|
if (LoadContext is null)
|
||||||
|
{
|
||||||
|
LoadContext = new("TorchLog");
|
||||||
|
foreach (var file in Directory.EnumerateFiles(extensionsDir, "*.dll", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
builder.RegisterAssembly(LoadContext.LoadFromAssemblyPath(file));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (var assembly in LoadContext.Assemblies)
|
||||||
|
{
|
||||||
|
builder.RegisterAssembly(assembly);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.SetupLogFactory(builder => builder.SetThrowConfigExceptions(true))
|
||||||
|
.LoadConfiguration(configuration);
|
||||||
|
LogManager.ReconfigExistingLoggers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RestoreGlobalConfiguration()
|
||||||
|
{
|
||||||
|
LogManager.Configuration = Configuration;
|
||||||
|
LogManager.ReconfigExistingLoggers();
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user