Skip to content

Commit

Permalink
added limit for number of returned log lines in API controller
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Oct 28, 2024
1 parent 1c124fd commit 82a5fbb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/com/erudika/scoold/api/ApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,9 @@ public Map<String, Object> stats(HttpServletRequest req) {
+ "/" + System.getProperty("para.logs_name", "scoold") + ".log";
Path path = Paths.get(logFile);
try (Stream<String> lines = Files.lines(path)) {
stats.put("log", lines.collect(Collectors.joining("\n")));
List<String> linez = lines.collect(Collectors.toList());
linez.subList(Math.max(0, linez.size() - 10000), linez.size());
stats.put("log", linez.stream().collect(Collectors.joining("\n")));
}
} catch (Exception e) {
logger.error("Failed to read log file. {}", e.getMessage());
Expand Down

0 comments on commit 82a5fbb

Please sign in to comment.