FlixelLogFileHandler
View sourceinterface
org.flixelgdx.logging.FlixelLogFileHandler
Platform-specific handler for writing log output to a persistent file.
Implementations are responsible for the entire file-logging lifecycle: creating the log file, pruning old files when the maximum is exceeded, writing individual log lines (potentially on a background thread to avoid blocking the game loop), and shutting down cleanly on game exit so that all buffered output is flushed.
On platforms where file logging is not feasible (for example, web/TeaVM), no handler needs to be registered and the logger will simply skip file output.
Assign an implementation to Flixel.logFileHandler before Flixel.initialize in the platform launcher.
See Also: FlixelLogger
Methods
start(String, int)
Starts file logging in the specified folder, keeping at most maxLogFiles log files. Older files beyond the limit are deleted before the new file is created.
If logsFolderPath is null, the implementation should fall back to a platform-appropriate default (for example, next to the running JAR or in the project root during development).
Implementations that perform file writes on a background thread should start that thread here.
Parameters:
| Name | Description |
|---|---|
logsFolderPath | The absolute path to the directory where log files are stored, or null to use the platform default. |
maxLogFiles | The maximum number of log files to retain. When the folder already contains this many files, the oldest are deleted before a new file is created. |
stop()
Shuts down the file handler, flushing any buffered log lines and releasing resources such as background threads and file handles.
This method should block briefly (for example, up to five seconds) to allow the write queue to drain so that logs written during shutdown are persisted. After this method returns, subsequent calls to FlixelLogFileHandler.write(String) are silently ignored.
write(String)
Writes a single pre-formatted log line to the current log file.
Implementations should enqueue the line for asynchronous writing when a background thread is in use, so that the calling game thread is not blocked by disk I/O. If the handler has not been started or has already been stopped, the call is silently ignored.
Parameters:
| Name | Description |
|---|---|
logLine | The fully formatted, plain-text log line to write. A trailing newline is appended by the handler if necessary. |
isActive()
Returns whether the handler is currently active and accepting log lines.
A handler is active between a successful FlixelLogFileHandler.start(String, int) call and the completion of FlixelLogFileHandler.stop().
Returns: true if file logging is active, false otherwise.
getDefaultLogsFolderPath()
Returns the platform-appropriate default directory for log files, or null if the platform does not support file logging.
On JVM platforms this typically resolves to a logs/ folder next to the running JAR or in the project root when running from an IDE.
Returns: An absolute path to the default logs directory, or null when file logging is not supported on this platform.