Merge branch 'develop' of https://github.com/sp-tarkov/server-csharp into develop
This commit is contained in:
@@ -6,7 +6,7 @@ using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel;
|
||||
namespace SPTarkov.Server.Core.Utils.Logger;
|
||||
|
||||
[Injectable(TypePriority = int.MinValue)]
|
||||
public class SptLogger<T> : ISptLogger<T>, IDisposable
|
||||
public class SptLogger<T> : ISptLogger<T>
|
||||
{
|
||||
private string _category;
|
||||
private readonly SptLoggerQueueManager _loggerQueueManager;
|
||||
@@ -206,9 +206,4 @@ public class SptLogger<T> : ISptLogger<T>, IDisposable
|
||||
{
|
||||
_loggerQueueManager.DumpAndStop();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_loggerQueueManager.DumpAndStop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Concurrent;
|
||||
using SPTarkov.DI.Annotations;
|
||||
|
||||
namespace SPTarkov.Server.Core.Utils.Logger;
|
||||
@@ -10,8 +11,7 @@ public class SptLoggerQueueManager(IEnumerable<ILogHandler> logHandlers)
|
||||
private Thread? _loggerTask;
|
||||
private readonly Lock LoggerTaskLock = new();
|
||||
private readonly CancellationTokenSource _loggerCancellationTokens = new();
|
||||
private readonly Queue<SptLogMessage> _messageQueue = new();
|
||||
private readonly Lock _messageQueueLock = new();
|
||||
private readonly BlockingCollection<SptLogMessage> _messageQueue = new();
|
||||
private Dictionary<LoggerType, ILogHandler>? _logHandlers;
|
||||
private SptLoggerConfiguration _config;
|
||||
|
||||
@@ -35,30 +35,17 @@ public class SptLoggerQueueManager(IEnumerable<ILogHandler> logHandlers)
|
||||
{
|
||||
while (!_loggerCancellationTokens.IsCancellationRequested)
|
||||
{
|
||||
lock (_messageQueueLock)
|
||||
try
|
||||
{
|
||||
if (_messageQueue.Count != 0)
|
||||
{
|
||||
while (_messageQueue.TryDequeue(out var message))
|
||||
{
|
||||
LogMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep((int)_config.PoolingTimeMs);
|
||||
}
|
||||
|
||||
lock (_messageQueueLock)
|
||||
{
|
||||
// make sure after cancellation that no messages are outstanding
|
||||
if (_messageQueue.Count != 0)
|
||||
{
|
||||
while (_messageQueue.TryDequeue(out var message))
|
||||
foreach (var message in _messageQueue.GetConsumingEnumerable(_loggerCancellationTokens.Token))
|
||||
{
|
||||
LogMessage(message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Logger queue caught exception: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +93,7 @@ public class SptLoggerQueueManager(IEnumerable<ILogHandler> logHandlers)
|
||||
|
||||
public void EnqueueMessage(SptLogMessage message)
|
||||
{
|
||||
lock (_messageQueueLock)
|
||||
{
|
||||
_messageQueue.Enqueue(message);
|
||||
}
|
||||
_messageQueue.TryAdd(message);
|
||||
}
|
||||
|
||||
public void DumpAndStop()
|
||||
|
||||
@@ -6,14 +6,26 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<ImportMap />
|
||||
<HeadOutlet />
|
||||
<HeadOutlet @rendermode="PageRenderMode" />
|
||||
</head>
|
||||
<body>
|
||||
<Routes/>
|
||||
<Routes @rendermode="PageRenderMode" />
|
||||
<script src="/_framework/blazor.web.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@code {
|
||||
|
||||
[CascadingParameter]
|
||||
private HttpContext HttpContext { get; set; } = default!;
|
||||
|
||||
private IComponentRenderMode? PageRenderMode
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return HttpContext.AcceptsInteractiveRouting() ? InteractiveServer : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@using System.Reflection
|
||||
@using SPTarkov.Server.Web.Components.Layout
|
||||
|
||||
<Router AppAssembly="@typeof(SPTWeb).Assembly">
|
||||
<Router AppAssembly="@typeof(SPTWeb).Assembly" AdditionalAssemblies="SPTWeb.SptWebModsAssemblies">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(BaseMainLayout)" />
|
||||
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using MudBlazor.Services;
|
||||
using SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
using SPTarkov.Server.Web.Components;
|
||||
@@ -8,6 +9,7 @@ namespace SPTarkov.Server.Web;
|
||||
public static class SPTWeb
|
||||
{
|
||||
internal static IEnumerable<SptMod> SptWebMods = [];
|
||||
internal static List<Assembly> SptWebModsAssemblies = [];
|
||||
|
||||
public static void InitializeSptBlazor(this WebApplicationBuilder builder, IReadOnlyList<SptMod> sptMods)
|
||||
{
|
||||
@@ -39,6 +41,7 @@ public static class SPTWeb
|
||||
foreach (var assembly in mod.Assemblies)
|
||||
{
|
||||
razorBuilder.AddAdditionalAssemblies(assembly);
|
||||
SptWebModsAssemblies.Add(assembly);
|
||||
}
|
||||
|
||||
var modAssembly = mod.ModMetadata.GetType().Assembly;
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
@page "/test/page"
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@rendermode InteractiveServer
|
||||
@page "/test/page"
|
||||
|
||||
<h3>TestModPage</h3>
|
||||
|
||||
<img src="/TestMod/chomp.jpg" alt="Chomp!" />
|
||||
|
||||
@code {
|
||||
<h3>Counter Test</h3>
|
||||
|
||||
<p>Current count: @count</p>
|
||||
|
||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
||||
|
||||
@code {
|
||||
private int count = 0;
|
||||
|
||||
private void IncrementCount()
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user