2024-08-28 20:33:59 -05:00
|
|
|
|
/*
|
|
|
|
|
|
* using NLog;
|
2023-04-13 17:43:26 -05:00
|
|
|
|
using NLog.Config;
|
|
|
|
|
|
using NLog.Targets;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.Logging
|
|
|
|
|
|
{
|
2023-04-14 01:31:04 -05:00
|
|
|
|
[Target("GameServerHub")]
|
|
|
|
|
|
public class GameServerHubTarget : AsyncTaskTarget
|
2023-04-13 17:43:26 -05:00
|
|
|
|
{
|
2023-04-14 01:31:04 -05:00
|
|
|
|
private GameServerHubConnection? Connection;
|
2023-04-13 17:43:26 -05:00
|
|
|
|
|
|
|
|
|
|
[RequiredParameter]
|
|
|
|
|
|
public string HubUrl { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void InitializeTarget()
|
|
|
|
|
|
{
|
2023-04-14 01:31:04 -05:00
|
|
|
|
Connection = new GameServerHubConnection(HubUrl);
|
2023-04-13 17:43:26 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task WriteAsyncTask(LogEventInfo logEvent, CancellationToken token)
|
|
|
|
|
|
{
|
2023-04-14 01:31:04 -05:00
|
|
|
|
if (Connection != null && logEvent.Properties.ContainsKey("ServerId"))
|
|
|
|
|
|
await Connection.Log((Guid)logEvent.Properties["ServerId"], logEvent.FormattedMessage);
|
2023-04-13 17:43:26 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override async void CloseTarget()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Connection != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
await Connection.DisposeAsync();
|
|
|
|
|
|
Connection = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-28 20:33:59 -05:00
|
|
|
|
*/
|