From a4a49d40f0b3af4151bf11b0eeac79ccd4cd208d Mon Sep 17 00:00:00 2001 From: glax Date: Wed, 13 Sep 2023 14:40:23 +0200 Subject: [PATCH] API GET LogMessages new optional parameter count --- Tranga/Server.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Tranga/Server.cs b/Tranga/Server.cs index 3e943f7..bd1cf20 100644 --- a/Tranga/Server.cs +++ b/Tranga/Server.cs @@ -419,7 +419,20 @@ public class Server : GlobalBase SendResponse(HttpStatusCode.NotFound, response); break; } - SendResponse(HttpStatusCode.OK, response, logger.GetLog()); + + if (requestVariables.TryGetValue("count", out string? count)) + { + try + { + uint messageCount = uint.Parse(count); + SendResponse(HttpStatusCode.OK, response, logger.Tail(messageCount)); + } + catch (FormatException f) + { + SendResponse(HttpStatusCode.InternalServerError, response, f); + } + }else + SendResponse(HttpStatusCode.OK, response, logger.GetLog()); break; case "LogFile": if (logger is null || !File.Exists(logger?.logFilePath))