@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 |
ERROR
Log level for error messages.
|
static int |
INFO
Log level for informational messages.
|
static int |
WARNING
Log level for warning messages.
|
| Modifier and Type | Method and Description |
|---|---|
static IEventLogger |
consoleLogger()
Returns a logger that writes to the console (System.out/System.err).
|
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 consoleLogger()
INFO and WARNING messages go to System.out, ERROR messages to System.err. Stack traces are printed for WARNING and ERROR events with exceptions.
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.