Files
se-launcher/PluginLoader/LogFile.cs
zznty 9fb29d2011
All checks were successful
Build / Build Launcher (push) Successful in 2m31s
update logging and add pl splash as the main one
2024-05-31 17:12:08 +07:00

37 lines
1.2 KiB
C#

using System.Runtime.CompilerServices;
using NLog;
using NLog.Layouts;
using NLog.Targets;
using NLog.Targets.Wrappers;
namespace PluginLoader;
public static class LogFile
{
private const string FileName = "loader.log";
private const string LoggerName = "PluginLoader";
public static readonly Logger Log = LogManager.GetLogger(LoggerName);
public static void Init(string mainPath)
{
RuntimeHelpers.RunClassConstructor(
Type.GetType("GameAnalyticsSDK.Net.Logging.GALogger, GameAnalytics.Mono", true)!.TypeHandle);
var target = new AsyncTargetWrapper(new FileTarget
{
Name = "pluginLog",
Layout = Layout.FromString("${longdate:universaltime=true} ${level} ${message:withexception=true}"),
FileName = Layout.FromString(Path.Combine(mainPath, FileName)),
FileNameKind = FilePathKind.Absolute,
EnableFileDelete = true,
DeleteOldFileOnStartup = true,
});
LogManager.Configuration.AddTarget(target);
LogManager.Configuration.LoggingRules.Insert(0, new(LoggerName, LogLevel.Trace, target)
{
FinalMinLevel = LogLevel.Info
});
LogManager.ReconfigExistingLoggers();
}
}