-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Close file before rotating in RollingFileLogWriter
#433
base: main
Are you sure you want to change the base?
Conversation
Otherwise a `java.nio.file.FileSystemException` will be raised, at least on Windows.
rollLogs() | ||
true | ||
} else false | ||
private fun shouldRollLogs(logFilePath: Path): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the signature of this function because calling maybeRollLogs(fileSizeOrZero())
seemed cumbersome.
@@ -136,8 +134,8 @@ open class RollingFileLogWriter( | |||
private suspend fun writer() { | |||
val logFilePath = pathForLogIndex(0) | |||
|
|||
if (fileSystem.exists(logFilePath)) { | |||
maybeRollLogs(fileSizeOrZero(logFilePath)) | |||
if (fileSystem.exists(logFilePath) && shouldRollLogs(logFilePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT we should just do this:
if (fileSystem.exists(logFilePath) && shouldRollLogs(logFilePath)) { | |
if (shouldRollLogs(logFilePath)) { |
because metadataOrNull()
already handled the case where the file doesn't exist.
Waiting for touchlab/Kermit#433 to be merged.
Waiting for touchlab/Kermit#433 to be merged.
Initially the goal was to use Kermit's `RollingFileLogWriter`, but an issue was found during testing (see touchlab/Kermit#433) so we are using a local patched version in the meantime. Logging can be configured with these two new config parameters: - `--log-rotate-size` Log rotate size in MB (default 10 MB) - `--log-rotate-max-files`: Maximum number of log files kept (default 5)
Otherwise a
java.nio.file.FileSystemException
will be raised, at least on Windows.