Class IP2LocationEventLog.LogEntry

java.lang.Object
co.mindus.ip2location.IP2LocationEventLog.LogEntry
Enclosing class:
IP2LocationEventLog

public static class IP2LocationEventLog.LogEntry extends Object
Represents a single log entry.

Log entries are immutable and contain all information about a single event, including timestamp, severity, category, message, and optional detail (such as a stack trace for errors).

Author:
Christopher Mindus
  • Constructor Details

  • Method Details

    • getTimestamp

      public Instant getTimestamp()
      Returns the timestamp when this event occurred.
      Returns:
      The event timestamp
    • getType

      Returns the severity level of this event.
      Returns:
      The event type (INFO, WARNING, or ERROR)
    • getCategory

      public IP2LocationEventLog.EventCategory getCategory()
      Returns the category/classification of this event.
      Returns:
      The event category
    • getMessage

      public String getMessage()
      Returns the human-readable message describing this event.
      Returns:
      The event message
    • getDetail

      public String getDetail()
      Returns optional detail text such as a stack trace.
      Returns:
      The detail text, or null if none
    • getFormattedTimestamp

      public String getFormattedTimestamp()
      Returns a formatted timestamp string for display.

      Format: "yyyy-MM-dd HH:mm:ss" in the system's default timezone.

      Returns:
      The formatted timestamp string
    • getSummary

      public String getSummary()
      Returns a single-line summary suitable for display in lists.

      Format: "[timestamp] TYPE: message"

      Returns:
      The summary string
    • toJson

      public String toJson()
      Converts this entry to a JSON string for file persistence.

      The JSON format is a single line with no pretty-printing, suitable for JSON-lines file format.

      Returns:
      The JSON representation of this entry
    • fromJson

      public static IP2LocationEventLog.LogEntry fromJson(String json)
      Parses a log entry from a JSON string.

      This is the inverse of toJson(). If the JSON is malformed or missing required fields, returns null.

      Parameters:
      json - The JSON string to parse
      Returns:
      The parsed LogEntry, or null if parsing failed