@FunctionalInterface public interface IEventLogger
This functional interface provides a bridge between IP2Location's internal logging and your application's logging framework. Implementations receive structured log events with severity level, message, and optional exception.
| Constant | Value | Usage |
|---|---|---|
INFO | 0 | Normal operations: startup, successful downloads |
WARNING | 1 | Recoverable issues: retry attempts, missing files |
ERROR | 2 | Serious failures: I/O errors, initialization failures |
Implementations must be thread-safe as log events may be generated from multiple threads simultaneously (update scheduler, lookup threads, etc.).
IP2LocationService.Builder.logger(IEventLogger), IP2LocationManager.setLogger(IEventLogger)| Modifier and Type | Field and Description |
|---|---|
static int | ERRORLog level for error messages. |
static int | INFOLog level for informational messages. |
static int | WARNINGLog level for warning messages. |
| Modifier and Type | Method and Description |
|---|---|
static IEventLogger | eventManagerLogger()Returns a logger that routes events to the NetPhantom EventManager. |
default void | logEvent(Class<?> callerClass, int type, String message)Logs an event without an exception. |
void | logEvent(Class<?> callerClass, int type, String message, Throwable ex)Logs an event with an optional exception. |
static IEventLogger | nullLogger()Returns a logger that discards all messages. |
static final int INFO
Used for normal operational messages such as:
static final int WARNING
Used for potentially problematic situations that don't prevent operation:
static final int ERROR
Used for serious failures that may affect functionality:
default void logEvent(Class<?> callerClass, int type, String message)
This is a convenience method that delegates to logEvent(Class, int, String, Throwable) with a null exception.*
void logEvent(Class<?> callerClass, int type, String message, Throwable ex)
This is the primary logging method that implementations must provide. It receives all information needed to produce a complete log entry.
callerClass - The class that generated the log event (never null). Useful for creating class-specific loggers.type - The event type: INFO, WARNING, or ERROR. Other values should be treated as INFO.message - The log message (never null). May contain formatting but no placeholders (already formatted).ex - An exception associated with the event, or null if none. When present, implementations should include the stack trace at WARNING and ERROR levels.static IEventLogger eventManagerLogger()
EventManager.It does NOT write to System.out or System.err. The level is mapped to an EventID event class - ERROR to EVENTCLASS_ERROR, WARNING to EVENTCLASS_WARNING, everything else to EVENTCLASS_INFORMATIONAL - and the event is queued on the server's event manager. When an exception is supplied its stack trace is appended to the message text, at every level rather than only at WARNING and ERROR.
With no server running this is a silent no-op. EventManager.logEvent ends in if ( em!=null ) em.queueEvent(...), and eventManager is null until the server starts it - so in a standalone tool or a test JVM this logger discards everything and behaves exactly like nullLogger(). Anything that needs output without a server must not use this.
This method was called consoleLogger() until 2026-08-07, and its JavaDoc described a real console logger writing INFO and WARNING to System.out and ERROR to System.err. That had not been true since the NetPhantom integration. The wrong name and the wrong description together cost five tests, which asserted captured console output that could never appear and failed for the whole life of the suite. Renamed to say what it does.
EventManager.static IEventLogger nullLogger()
Useful for testing or when logging is handled externally.
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.