Class Logger
java.lang.Object
de.spiritscorp.datasync.io.Logger
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidWrites 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.voidsetEntry(String filePath, String changeStatus, FileAttributes fileAttributes) Sets a new log entry and queues it inside the volatile internal cache.
-
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
Sets a new log entry and queues it inside the volatile internal cache.- Parameters:
filePath- The path where the file is/was locatedchangeStatus- The status representing the change eventfileAttributes- 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
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
-