Skip to content

Commit

Permalink
#14 Align log and exception messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
vy committed Jul 29, 2021
1 parent a38e111 commit 3cfa1c0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/com/vlkan/rfos/RotatingFileOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,28 @@ private synchronized void unsafeRotate(RotationPolicy policy, Instant instant) t
}

private boolean renameBackups() {
File newFile = getBackupFile(config.getMaxBackupCount() - 1);
File dstFile = getBackupFile(config.getMaxBackupCount() - 1);
for (int backupIndex = config.getMaxBackupCount() - 2; backupIndex >= 0; backupIndex--) {
File oldFile = getBackupFile(backupIndex);
if (!oldFile.exists()) {
File srcFile = getBackupFile(backupIndex);
if (!srcFile.exists()) {
continue;
}
LOGGER.debug("renaming backup {} to {}", oldFile, newFile);
boolean renamed = oldFile.renameTo(newFile);
LOGGER.debug("renaming backup {srcFile={}, dstFile={}}", srcFile, dstFile);
boolean renamed = srcFile.renameTo(dstFile);
if (!renamed) {
LOGGER.error("failed renaming backup {} to {}", oldFile, newFile);
LOGGER.error("failed renaming backup {srcFile={}, dstFile={}}", srcFile, dstFile);
return false;
}
newFile = oldFile;
dstFile = srcFile;
}
return true;
}

private boolean backupFile(File[] backupFileRef) {
File newFile = backupFileRef[0] = getBackupFile(0);
File oldFile = config.getFile();
LOGGER.debug("renaming {} to {} for backup", oldFile, newFile);
return oldFile.renameTo(newFile);
File dstFile = backupFileRef[0] = getBackupFile(0);
File srcFile = config.getFile();
LOGGER.debug("renaming for backup {srcFile={}, dstFile={}}", srcFile, dstFile);
return srcFile.renameTo(dstFile);
}

private File getBackupFile(int backupIndex) {
Expand Down

0 comments on commit 3cfa1c0

Please sign in to comment.