net.i2p.router.util

## Class EventLog

- java.lang.Object
- - net.i2p.router.util.EventLog

-     public class EventLog
      extends Object

  Event logging utility with caching and file-based persistence.

  Provides simple event logging for occasional router events with efficient caching for read operations and file-based persistence. Does not maintain open file handles to avoid resource leaks.

  Supports event categorization and timestamp tracking with configurable caching behavior. Optimized for low-frequency logging scenarios where performance is more important than comprehensive event tracking.

  Includes predefined event types for router lifecycle events, network changes, and critical system events. Provides both append-only and read-write access patterns with proper synchronization for thread safety.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ABORTED` for convenience, not required
    `static String` | `BECAME_FLOODFILL`
    `static String` | `CHANGE_IP`
    `static String` | `CHANGE_PORT`
    `static String` | `CLOCK_SHIFT`
    `static String` | `CRASHED`
    `static String` | `CRITICAL`
    `static String` | `DEADLOCK`
    `static String` | `INSTALL_FAILED`
    `static String` | `INSTALLED`
    `static String` | `NETWORK`
    `static String` | `NEW_IDENT`
    `static String` | `NOT_FLOODFILL`
    `static String` | `OOM`
    `static String` | `REACHABILITY`
    `static String` | `REKEYED`
    `static String` | `RESEED`
    `static String` | `SOFT_RESTART`
    `static String` | `STARTED`
    `static String` | `STOPPED`
    `static String` | `UPDATED`
    `static String` | `WATCHDOG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EventLog(I2PAppContext ctx, File file)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEvent(String event)` Append an event.
    `void` | `addEvent(String event, String info)` Append an event.
    `SortedMap<Long,String>` | `getEvents(long since)` All events since a given time.
    `SortedMap<Long,String>` | `getEvents(String event, long since)` Caches.
    `long` | `getLastEvent(String event, long since)` Timestamp of last event.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ABORTED

          public static final String ABORTED

      for convenience, not required
      See Also:
        Constant Field Values

    - #### BECAME_FLOODFILL

          public static final String BECAME_FLOODFILL

      See Also:
        Constant Field Values

    - #### CHANGE_IP

          public static final String CHANGE_IP

      See Also:
        Constant Field Values

    - #### CHANGE_PORT

          public static final String CHANGE_PORT

      See Also:
        Constant Field Values

    - #### CLOCK_SHIFT

          public static final String CLOCK_SHIFT

      See Also:
        Constant Field Values

    - #### CRASHED

          public static final String CRASHED

      See Also:
        Constant Field Values

    - #### CRITICAL

          public static final String CRITICAL

      See Also:
        Constant Field Values

    - #### DEADLOCK

          public static final String DEADLOCK

      See Also:
        Constant Field Values

    - #### INSTALL_FAILED

          public static final String INSTALL_FAILED

      See Also:
        Constant Field Values

    - #### INSTALLED

          public static final String INSTALLED

      See Also:
        Constant Field Values

    - #### NETWORK

          public static final String NETWORK

      See Also:
        Constant Field Values

    - #### NEW_IDENT

          public static final String NEW_IDENT

      See Also:
        Constant Field Values

    - #### NOT_FLOODFILL

          public static final String NOT_FLOODFILL

      See Also:
        Constant Field Values

    - #### OOM

          public static final String OOM

      See Also:
        Constant Field Values

    - #### REACHABILITY

          public static final String REACHABILITY

      See Also:
        Constant Field Values

    - #### REKEYED

          public static final String REKEYED

      See Also:
        Constant Field Values

    - #### RESEED

          public static final String RESEED

      See Also:
        Constant Field Values

    - #### SOFT_RESTART

          public static final String SOFT_RESTART

      See Also:
        Constant Field Values

    - #### STARTED

          public static final String STARTED

      See Also:
        Constant Field Values

    - #### STOPPED

          public static final String STOPPED

      See Also:
        Constant Field Values

    - #### UPDATED

          public static final String UPDATED

      See Also:
        Constant Field Values

    - #### WATCHDOG

          public static final String WATCHDOG

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### EventLog

          public EventLog(I2PAppContext ctx,
                          File file)

      Parameters:
        `file` - should be absolute

  - ### Method Detail

    - #### addEvent

          public void addEvent(String event)

      Append an event. Fails silently.
      Parameters:
        `event` - no spaces, e.g. "started"
      Throws:
        `IllegalArgumentException` - if event contains a space or newline

    - #### addEvent

          public void addEvent(String event,
                               String info)

      Append an event. Fails silently.
      Parameters:
        `event` - no spaces or newlines, e.g. "started"
        `info` - no newlines, may be blank or null
      Throws:
        `IllegalArgumentException` - if event contains a space or either contains a newline

    - #### getEvents

          public SortedMap<Long,String> getEvents(long since)

      All events since a given time. Does not cache. Fails silently. Values in the returned map have the format "event[ info]". Events do not contain spaces.
      Parameters:
        `since` - since this time, 0 for all
      Returns:
        non-null, Map of times to info strings, sorted, earliest first, unmodifiable

    - #### getEvents

          public SortedMap<Long,String> getEvents(String event,
                                                  long since)

      Caches. Fails silently.
      Parameters:
        `event` - matching this event only, case sensitive
        `since` - since this time, 0 for all
      Returns:
        non-null, Map of times to (possibly empty) info strings, sorted, earliest first, unmodifiable

    - #### getLastEvent

          public long getLastEvent(String event,
                                   long since)

      Timestamp of last event.
      Parameters:
        `event` - matching this event, case sensitive
        `since` - since this time, 0 for all
      Returns:
        last event time, or 0 for none