Class AuditLogStorage

java.lang.Object
io.jenkins.plugins.auditlogger.AuditLogStorage

public class AuditLogStorage extends Object
Production-grade audit log storage. Design for heavy load: - Lock-free ConcurrentLinkedQueue for incoming events (zero blocking on callers) - Single daemon writer thread drains queue and writes batches - Persistent BufferedWriter (no open/close per entry) - Bounded in-memory ring buffer (ArrayDeque + ReadWriteLock) for UI/API queries - Automatic file rotation on size threshold - Proper shutdown with flush guarantee - Data masking integrated before persistence
  • Method Details

    • getInstance

      public static AuditLogStorage getInstance()
    • initialize

      public void initialize()
      Initialize storage: ensure dirs, load recent logs, start writer thread. Called once during plugin startup.
    • addEntry

      public void addEntry(AuditLogEntry entry)
      Record an audit event. Non-blocking — entry is queued for async disk write. Returns immediately; typical latency < 1 microsecond.
    • getAllEntries

      public List<AuditLogEntry> getAllEntries()
      Get all entries in memory (most recent MAX_ENTRIES_IN_MEMORY). Returns a defensive copy.
    • hasEntries

      public boolean hasEntries()
      Fast existence check used by the UI to avoid loading every entry during page render.
    • getAnomalyDetector

      public AnomalyDetector getAnomalyDetector()
      Get the anomaly detector instance for querying alerts.
    • filterEntries

      public List<AuditLogEntry> filterEntries(String username, String action, Long startTime, Long endTime)
      Filter entries by criteria. Returns a defensive copy.
    • shutdown

      public void shutdown()
      Flush all pending writes and shut down the writer thread. Called on plugin stop.