Implemented restorer, runtime and dummy statistics. Added service registering and fixed server factory. Moved logger to server context

This commit is contained in:
2025-09-07 23:15:48 +02:00
parent 282096595d
commit b90100d250
18 changed files with 385 additions and 65 deletions

View File

@@ -1,11 +1,11 @@
using MoonlightServers.Daemon.ServerSystem.Interfaces;
using MoonlightServers.Daemon.ServerSystem.Models;
namespace MoonlightServers.Daemon.ServerSystem.Implementations;
public class ServerReporter : IReporter
{
private readonly IConsole Console;
private readonly ILogger Logger;
private readonly ServerContext Context;
private const string StatusTemplate =
"\x1b[1;38;2;200;90;200mM\x1b[1;38;2;204;110;230mo\x1b[1;38;2;170;130;245mo\x1b[1;38;2;140;150;255mn\x1b[1;38;2;110;180;255ml\x1b[1;38;2;100;200;255mi\x1b[1;38;2;100;220;255mg\x1b[1;38;2;120;235;255mh\x1b[1;38;2;140;250;255mt\x1b[0m \x1b[3;38;2;200;200;200m{0}\x1b[0m\n\r";
@@ -13,10 +13,9 @@ public class ServerReporter : IReporter
private const string ErrorTemplate =
"\x1b[1;38;2;200;90;200mM\x1b[1;38;2;204;110;230mo\x1b[1;38;2;170;130;245mo\x1b[1;38;2;140;150;255mn\x1b[1;38;2;110;180;255ml\x1b[1;38;2;100;200;255mi\x1b[1;38;2;100;220;255mg\x1b[1;38;2;120;235;255mh\x1b[1;38;2;140;250;255mt\x1b[0m \x1b[1;38;2;255;0;0m{0}\x1b[0m\n\r";
public ServerReporter(IConsole console, ILogger logger)
public ServerReporter(ServerContext context)
{
Console = console;
Logger = logger;
Context = context;
}
public Task InitializeAsync()
@@ -24,18 +23,18 @@ public class ServerReporter : IReporter
public async Task StatusAsync(string message)
{
Logger.LogInformation("Status: {message}", message);
Context.Logger.LogInformation("Status: {message}", message);
await Console.WriteStdOutAsync(
await Context.Server.Console.WriteStdOutAsync(
string.Format(StatusTemplate, message)
);
}
public async Task ErrorAsync(string message)
{
Logger.LogError("Error: {message}", message);
Context.Logger.LogError("Error: {message}", message);
await Console.WriteStdOutAsync(
await Context.Server.Console.WriteStdOutAsync(
string.Format(ErrorTemplate, message)
);
}