From 91efbfa3d0a6449e8bf183af733bce5aeb098821 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Sat, 16 Mar 2019 16:44:10 +0200 Subject: [PATCH] Fetch all audit logging events gitlab #274 Change-Id: I50f7368d758a3bbac424506db65966062895a213 --- .../scl/Simantics/AuditLogging/Server.scl | 1 + .../src/org/simantics/audit/AuditLogging.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/bundles/org.simantics.auditlogging/scl/Simantics/AuditLogging/Server.scl b/bundles/org.simantics.auditlogging/scl/Simantics/AuditLogging/Server.scl index 9304294c0..b7278e9e2 100644 --- a/bundles/org.simantics.auditlogging/scl/Simantics/AuditLogging/Server.scl +++ b/bundles/org.simantics.auditlogging/scl/Simantics/AuditLogging/Server.scl @@ -7,6 +7,7 @@ importJava "org.simantics.audit.AuditLogging" where trace :: String -> Map.T String a -> () getLogEventsDays :: String -> String -> Integer -> [String] getLogEvents :: String -> String -> String -> String -> [String] + allLogEvents :: String -> Integer -> Map.T String [String] importJava "org.simantics.audit.server.AuditLoggingServer" where start :: String -> Integer -> () \ No newline at end of file diff --git a/bundles/org.simantics.auditlogging/src/org/simantics/audit/AuditLogging.java b/bundles/org.simantics.auditlogging/src/org/simantics/audit/AuditLogging.java index 334e19c47..3cd6ac392 100644 --- a/bundles/org.simantics.auditlogging/src/org/simantics/audit/AuditLogging.java +++ b/bundles/org.simantics.auditlogging/src/org/simantics/audit/AuditLogging.java @@ -41,6 +41,24 @@ public class AuditLogging { } } + public static Map> allLogEvents(String level, int days) throws AuditLoggingException { + Map> results = new HashMap<>(); + try { + Files.walk(Activator.getLogLocation()).forEach(uuid -> { + String fileName = uuid.getFileName().toString(); + try { + List events = getLogEventsDays(fileName, level, days); + results.put(fileName, events); + } catch (AuditLoggingException e) { + LOGGER.error("Could not get audit log events for {}", fileName, e); + } + }); + } catch (IOException e) { + throw new AuditLoggingException(e); + } + return results; + } + /** * Gets audit events for the last 5 days * -- 2.47.1