         }
     }
 
+    /// Clears the currently selected file and begins writing again at its beginning.
+    public func resetCurrentFile() {
+        self.currentFile?.reset()
+    }
+
+    /// Instructs the Endpoint to rotate to the next log file in its sequence.
+    public func rotate() {
+        if let nextFile = self.nextFile() {
+            self.rotateToFile(nextFile)
+        }
+    }
+
     /// Sets the current file to the next index and notifies about rotation
-    private func rotateTo(nextFile: LXLogFile) {
+    private func rotateToFile(nextFile: LXLogFile) {
         //TODO: Move these notifications into property observers, if the properties can be made non-lazy.
         //TODO: Getting `nextURL` from `nextFile`, instead of calculating it again, might be more robust.
         NSNotificationCenter.defaultCenter().postNotificationName(

        )
    }

    /// Clears the currently selected file and begins writing again at its beginning.
    public func resetCurrentFile() {
        self.currentFile?.reset()
    }

    /// This method provides an opportunity to determine whether a new log file should be selected before writing the
    /// next Log Entry.
    ///
    /// - parameter length: The length of the data (number of bytes) that will be written next.
    ///
    /// - returns: A new log file to write this data to, or `nil` if the Endpoint should continue using the existing
    ///            file.
    private func rotateToFileBeforeWritingDataWithLength(length: Int) -> LXLogFile? {
        switch self.currentFile?.sizeInBytes {
        case .Some(let size) where size + UIntMax(length) > self.maxFileSizeBytes:  // Won't fit in current file
            fallthrough
        case .None:                                                                 // Can't determine size of current file
            return LXLogFile(URL: self.nextURL, shouldAppend: false)
        case .Some:                                                                 // Will fit in current file
            return nil
        }
    }

}


//MARK: Manually Rotated File Endpoint

/**
A version of LXRotatingFileEndpoint which can be manually rotated. Setting the max file size to 0 causes it to only rotate when
told to do so.
*/
public class LXManuallyRotatingFileEndpoint: LXRotatingFileEndpoint {

    // Same as super initializer, except that the default file size is 0 (don't rotate)
    public override init?(
        baseURL: NSURL? = defaultLogFileURL,
        numberOfFiles: UInt = 5,
        maxFileSizeKiB: UInt = 0,
        minimumPriorityLevel: LXPriorityLevel = .All,
        dateFormatter: LXDateFormatter = LXDateFormatter.standardFormatter(),
        entryFormatter: LXEntryFormatter = LXEntryFormatter.standardFormatter()
    ) {
        super.init(baseURL: baseURL, numberOfFiles: numberOfFiles, maxFileSizeKiB: maxFileSizeKiB, minimumPriorityLevel: minimumPriorityLevel, dateFormatter: dateFormatter, entryFormatter: entryFormatter)
        /// Listen for rotation notifications
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotateNotification:", name: LXFileEndpointCauseRotationNotification, object: nil)
    }
    
    @objc private func rotateNotification(notification: NSNotification){
        rotate()
    }

    /**
    Attempt to rotate to the next file in the cycle.
    */
    public func rotate() {
        //TODO: Should it throw if unable to rotate?
        if let nextFile = LXLogFile(URL: self.nextURL, shouldAppend: false) {
            rotateTo(nextFile)
        }
    }

    /// Don't rotate before writing if the maximum file size is non-positive
    override private func rotateToFileBeforeWritingDataWithLength(length: Int) -> LXLogFile? {
        if self.maxFileSizeBytes <= 0 {
            return nil
        }else{
            return super.rotateToFileBeforeWritingDataWithLength(length)
        }
    }
}



/// the new file.
public let LXFileEndpointDidRotateFilesNotification:  String = "info.logkit.endpoint.fileEndpoint.didRotateFiles"

/// The value found at this key is the `NSURL` of the sender's previous log file.
public let LXFileEndpointRotationPreviousURLKey:      String = "info.logkit.endpoint.fileEndpoint.previousURL"

