protected void rollOverSize()

in contribs/KevinSteppe/CompositeRollingAppender.java [646:705]


	protected void rollOverSize() {
		File file;

		this.closeFile(); // keep windows happy.

		LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount());
		LogLog.debug("maxSizeRollBackups = " + maxSizeRollBackups);
		LogLog.debug("curSizeRollBackups = " + curSizeRollBackups);
		LogLog.debug("countDirection = " + countDirection);

		// If maxBackups <= 0, then there is no file renaming to be done.
		if (maxSizeRollBackups != 0) {

			if (countDirection < 0) {
				// Delete the oldest file, to keep Windows happy.
				if (curSizeRollBackups == maxSizeRollBackups) {
				    deleteFile(fileName + '.' + maxSizeRollBackups);
					curSizeRollBackups--;
				}

				// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
				for (int i = curSizeRollBackups; i >= 1; i--) {
					rollFile((fileName + "." + i), (fileName + '.' + (i + 1)));
				}

				curSizeRollBackups++;
				// Rename fileName to fileName.1
				rollFile(fileName, fileName + ".1");

			} //REMOVE This code branching for Alexander Cerna's request
			else if (countDirection == 0) {
				//rollFile based on date pattern
				curSizeRollBackups++;
				now.setTime(System.currentTimeMillis());
				scheduledFilename = fileName + sdf.format(now);
				rollFile(fileName, scheduledFilename);
			}
			else { //countDirection > 0
				if (curSizeRollBackups >= maxSizeRollBackups && maxSizeRollBackups > 0) {
					//delete the first and keep counting up.
					int oldestFileIndex = curSizeRollBackups - maxSizeRollBackups + 1;
					deleteFile(fileName + '.' + oldestFileIndex);
				}

				if (staticLogFileName) {
					curSizeRollBackups++;
					rollFile(fileName, fileName + '.' + curSizeRollBackups);
				}
			}
		}

		try {
			// This will also close the file. This is OK since multiple
			// close operations are safe.
			this.setFile(baseFileName, false);
		}
		catch(IOException e) {
			LogLog.error("setFile("+fileName+", false) call failed.", e);
		}
	}