From 49848db96f1385d2a80c188ce358830541533990 Mon Sep 17 00:00:00 2001 From: mxritzdev Date: Tue, 13 May 2025 14:26:29 +0200 Subject: [PATCH] added logs to the diagnose --- .../Diagnose/CoreDiagnoseProvider.cs | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Moonlight.ApiServer/Implementations/Diagnose/CoreDiagnoseProvider.cs b/Moonlight.ApiServer/Implementations/Diagnose/CoreDiagnoseProvider.cs index be89d2ee..aff19bfd 100644 --- a/Moonlight.ApiServer/Implementations/Diagnose/CoreDiagnoseProvider.cs +++ b/Moonlight.ApiServer/Implementations/Diagnose/CoreDiagnoseProvider.cs @@ -10,12 +10,14 @@ namespace Moonlight.ApiServer.Implementations.Diagnose; public class CoreDiagnoseProvider : IDiagnoseProvider { private readonly AppConfiguration Config; - + + public CoreDiagnoseProvider(AppConfiguration config) + { + Config = config; + } + public DiagnoseEntry[] GetFiles() { - // TODO: - // - read logs out from file for the diagnose below - return [ new DiagnoseDirectory() @@ -26,7 +28,15 @@ public class CoreDiagnoseProvider : IDiagnoseProvider new DiagnoseFile() { Name = "logs.txt", - GetContent = () => Encoding.UTF8.GetBytes("placeholder") + GetContent = () => + { + var logs = File.ReadAllText(PathBuilder.File("storage", "logs", "latest.log")); + + if (string.IsNullOrEmpty(logs)) + return Encoding.UTF8.GetBytes("Could not get the latest logs."); + + return Encoding.UTF8.GetBytes(logs); + } }, new DiagnoseFile()