public class EventLog extends Object
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.
| Modifier and Type | Field and Description |
|---|---|
static String | ABORTEDfor convenience, not required |
static String | BECAME_FLOODFILLBECAME_FLOODFILL. |
static String | CHANGE_IPCHANGE_IP. |
static String | CHANGE_PORTCHANGE_PORT. |
static String | CLOCK_SHIFTCLOCK_SHIFT. |
static String | CRASHEDCRASHED. |
static String | CRITICALCRITICAL. |
static String | DEADLOCKDEADLOCK. |
static String | INSTALL_FAILEDINSTALL_FAILED. |
static String | INSTALLEDINSTALLED. |
static String | NETWORKNETWORK. |
static String | NEW_IDENTNEW_IDENT. |
static String | NOT_FLOODFILLNOT_FLOODFILL. |
static String | OOMOOM. |
static String | REACHABILITYREACHABILITY. |
static String | REKEYEDREKEYED. |
static String | RESEEDRESEED. |
static String | SOFT_RESTARTSOFT_RESTART. |
static String | STARTEDSTARTED. |
static String | STOPPEDSTOPPED. |
static String | UPDATEDUPDATED. |
static String | WATCHDOGWATCHDOG. |
| Constructor and Description |
|---|
EventLog(I2PAppContext ctx,
File file) |
| 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. |
public static final String ABORTED
public static final String BECAME_FLOODFILL
public static final String CHANGE_IP
public static final String CHANGE_PORT
public static final String CLOCK_SHIFT
public static final String CRASHED
public static final String CRITICAL
public static final String DEADLOCK
public static final String INSTALL_FAILED
public static final String INSTALLED
public static final String NETWORK
public static final String NEW_IDENT
public static final String NOT_FLOODFILL
public static final String OOM
public static final String REACHABILITY
public static final String REKEYED
public static final String RESEED
public static final String SOFT_RESTART
public static final String STARTED
public static final String STOPPED
public static final String UPDATED
public static final String WATCHDOG
public EventLog(I2PAppContext ctx, File file)
file - should be absolutepublic void addEvent(String event)
event - no spaces, e.g. "started"IllegalArgumentException - if event contains a space or newlinepublic void addEvent(String event, String info)
event - no spaces or newlines, e.g. "started"info - no newlines, may be blank or nullIllegalArgumentException - if event contains a space or either contains a newlinepublic SortedMap<Long,String> getEvents(long since)
since - since this time, 0 for allpublic SortedMap<Long,String> getEvents(String event, long since)
event - matching this event only, case sensitivesince - since this time, 0 for allpublic long getLastEvent(String event, long since)
event - matching this event, case sensitivesince - since this time, 0 for all