Interface IEventLogger
- All Known Implementing Classes:
ILogEventLogger
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
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.
Event Types
| 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 |
Thread Safety
Implementations must be thread-safe as log events may be generated from multiple threads simultaneously (update scheduler, lookup threads, etc.).
Host integration
This library carries no logging framework of its own. The host application supplies the implementation through IP2LocationService.Builder.logger(IEventLogger) and IP2LocationManager.setLogger(IEventLogger); when none is supplied the service logs nothing (nullLogger()) and the manager falls back to the console.
- Author:
- Christopher Mindus
- See Also:
Field Summary
FieldsMethod Summary
Modifier and TypeMethodDescriptiondefault voidLogs an event without an exception.voidLogs an event with an optional exception.static IEventLoggerReturns a logger that discards all messages.
Field Details
INFO
static final int INFOLog level for informational messages.Used for normal operational messages such as:
- Service startup and shutdown
- Successful database downloads
- Database reloads
- Configuration changes
- See Also:
WARNING
static final int WARNINGLog level for warning messages.Used for potentially problematic situations that don't prevent operation:
- Download retry attempts
- Missing database files (will be downloaded)
- Stale database detection
- Proxy configuration issues
- See Also:
ERROR
static final int ERRORLog level for error messages.Used for serious failures that may affect functionality:
- Database load failures
- Persistent download failures
- I/O errors during lookup
- Initialization failures
- See Also:
Method Details
logEvent
Logs an event without an exception.This is a convenience method that delegates to
logEvent(Class, int, String, Throwable)with anullexception.*logEvent
Logs an event with an optional exception.This is the primary logging method that implementations must provide. It receives all information needed to produce a complete log entry.
- Parameters:
callerClass- The class that generated the log event (never null). Useful for creating class-specific loggers.type- The event type:INFO,WARNING, orERROR. 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, ornullif none. When present, implementations should include the stack trace at WARNING and ERROR levels.
nullLogger
Returns a logger that discards all messages.Useful for testing or when logging is handled externally. This is also the logger an
IP2LocationServiceuses when its builder was given none.- Returns:
- A no-op logger that ignores all events.