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.

@FunctionalInterface public interface IEventLogger
Event logger interface for IP2Location components integrated with a host application server and its logging framework.

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

ConstantValueUsage
INFO0Normal operations: startup, successful downloads
WARNING1Recoverable issues: retry attempts, missing files
ERROR2Serious 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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Log level for error messages.
    static final int
    Log level for informational messages.
    static final int
    Log level for warning messages.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    Returns a logger that discards all messages.
  • Field Details

    • INFO

      static final int INFO
      Log 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 WARNING
      Log 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 ERROR
      Log 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

      default void logEvent(Class<?> callerClass, int type, String message)
      Logs an event without an exception.

      This is a convenience method that delegates to logEvent(Class, int, String, Throwable) with a null exception.*

      Parameters:
      callerClass - The class that generated the log event
      type - The event type: INFO, WARNING, or ERROR
      message - The log message (never null)
    • logEvent

      void logEvent(Class<?> callerClass, int type, String message, Throwable ex)
      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, 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.
    • nullLogger

      static IEventLogger nullLogger()
      Returns a logger that discards all messages.

      Useful for testing or when logging is handled externally. This is also the logger an IP2LocationService uses when its builder was given none.

      Returns:
      A no-op logger that ignores all events.