Class Logger

java.lang.Object
de.spiritscorp.datasync.io.Logger

public class Logger extends Object
High-performance background logger using JSON Lines format (NDJSON). Features an automated, size-based log rotation upon initialization. Designed with Dependency Injection for optimal testability.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Public default constructor utilizing production configurations.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Writes the cached log entries to the file system using an efficient O(1) append strategy.
    List<jakarta.json.JsonArray>
    Reads the log file sequentially and parses the JSON lines.
    void
    setEntry(String filePath, String changeStatus, FileAttributes fileAttributes)
    Sets a new log entry and queues it inside the volatile internal cache.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Logger

      public Logger()
      Public default constructor utilizing production configurations. Fetches the default log path and enforces a 10 MB retention limit with 5 backups.
  • Method Details

    • setEntry

      public void setEntry(String filePath, String changeStatus, FileAttributes fileAttributes)
      Sets a new log entry and queues it inside the volatile internal cache.
      Parameters:
      filePath - The path where the file is/was located
      changeStatus - The status representing the change event
      fileAttributes - The structural attributes of the file
    • printStatus

      public void printStatus()
      Writes the cached log entries to the file system using an efficient O(1) append strategy. Avoids loading existing files into memory, keeping the footprint static.
    • readLogForGui

      public List<jakarta.json.JsonArray> readLogForGui()
      Reads the log file sequentially and parses the JSON lines. Returns the entries in reverse order, positioning the newest events at the top for UI representation.
      Returns:
      A list containing all logged structures ordered from newest to oldest