]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fetch all audit logging events 79/2779/1
authorjsimomaa <jani.simomaa@gmail.com>
Sat, 16 Mar 2019 14:44:10 +0000 (16:44 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Sat, 16 Mar 2019 14:44:10 +0000 (16:44 +0200)
gitlab #274

Change-Id: I50f7368d758a3bbac424506db65966062895a213

bundles/org.simantics.auditlogging/scl/Simantics/AuditLogging/Server.scl
bundles/org.simantics.auditlogging/src/org/simantics/audit/AuditLogging.java

index 9304294c094781e270f72cda58ab26f024acee23..b7278e9e26df3e053100d968005185193f17c26a 100644 (file)
@@ -7,6 +7,7 @@ importJava "org.simantics.audit.AuditLogging" where
     trace :: String -> Map.T String a -> <Proc, Exception> ()
     getLogEventsDays :: String -> String -> Integer -> <Proc, Exception> [String]
     getLogEvents :: String -> String -> String -> String -> <Proc, Exception> [String]
+    allLogEvents :: String -> Integer -> <Proc, Exception> Map.T String [String]
 
 importJava "org.simantics.audit.server.AuditLoggingServer" where
     start :: String -> Integer -> <Proc> ()
\ No newline at end of file
index 334e19c4762787ca579db78da236687ae6b53f79..3cd6ac3921ecfc9107166775ab3ee42ebeaf778b 100644 (file)
@@ -41,6 +41,24 @@ public class AuditLogging {
         }
     }
 
+    public static Map<String, List<String>> allLogEvents(String level, int days) throws AuditLoggingException {
+        Map<String, List<String>> results = new HashMap<>();
+        try {
+            Files.walk(Activator.getLogLocation()).forEach(uuid -> {
+                String fileName = uuid.getFileName().toString();
+                try {
+                    List<String> 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
      *