Read log file on console load
This commit is contained in:
parent
0887626955
commit
29ae9157ca
3 changed files with 29 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
@using NLog;
|
@using NLog;
|
||||||
@using XtermBlazor
|
@using XtermBlazor
|
||||||
@inject ServerService ServerService
|
@inject ServerService ServerService
|
||||||
|
@inject ServerLogService ServerLogService
|
||||||
@inject ServerProcessService ServerProcessService
|
@inject ServerProcessService ServerProcessService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@implements IAsyncDisposable
|
@implements IAsyncDisposable
|
||||||
|
@ -49,6 +50,13 @@
|
||||||
|
|
||||||
if (Terminal != null)
|
if (Terminal != null)
|
||||||
await Terminal.InvokeAddonFunctionVoidAsync("xterm-addon-fit", "fit");
|
await Terminal.InvokeAddonFunctionVoidAsync("xterm-addon-fit", "fit");
|
||||||
|
|
||||||
|
var log = await ServerLogService.ReadLog(ServerLogId);
|
||||||
|
|
||||||
|
foreach (var line in log)
|
||||||
|
{
|
||||||
|
await Terminal.WriteLine(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ builder.Services.AddScoped<TagService>();
|
||||||
builder.Services.AddScoped<CompanyService>();
|
builder.Services.AddScoped<CompanyService>();
|
||||||
builder.Services.AddScoped<IGDBService>();
|
builder.Services.AddScoped<IGDBService>();
|
||||||
builder.Services.AddScoped<ServerService>();
|
builder.Services.AddScoped<ServerService>();
|
||||||
|
builder.Services.AddScoped<ServerLogService>();
|
||||||
builder.Services.AddScoped<GameSaveService>();
|
builder.Services.AddScoped<GameSaveService>();
|
||||||
|
|
||||||
builder.Services.AddSingleton<ServerProcessService>();
|
builder.Services.AddSingleton<ServerProcessService>();
|
||||||
|
|
20
LANCommander/Services/ServerLogService.cs
Normal file
20
LANCommander/Services/ServerLogService.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using LANCommander.Data;
|
||||||
|
using LANCommander.Data.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace LANCommander.Services
|
||||||
|
{
|
||||||
|
public class ServerLogService : BaseDatabaseService<ServerLog>
|
||||||
|
{
|
||||||
|
public ServerLogService(DatabaseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor) { }
|
||||||
|
|
||||||
|
public async Task<string[]> ReadLog(Guid logId)
|
||||||
|
{
|
||||||
|
var log = await Get(logId);
|
||||||
|
|
||||||
|
var logPath = Path.Combine(log.Server.WorkingDirectory, log.Path);
|
||||||
|
|
||||||
|
return await File.ReadAllLinesAsync(logPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue