     ///
     func rotateFileAuto(cause: Rotation) {  // parameter unnecessary. for clarity only
       let fileManager = FileManager.default
-      let path = writeToFileURL!.path
+        guard let path = writeToFileURL?.path else { fatalError("Cannot call rotateFileAuto with nil writeTOoFileURL") }
 
       // prepare parts of rotation file name for future use
       if (!rotateAutoCalledBefore) {


        // assemble a dictionary of date:file
        var fileDateMap = [Date: String]()
        let iter = fileManager.enumerator(atPath: logFileDirectory!)
        while let element = iter?.nextObject() as? String {
          let filePath = logFileDirectory! + element
          action = "get attributes of " + filePath
          let fileAttr = try fileManager.attributesOfItem(atPath: filePath)
          let creationDate = fileAttr[FileAttributeKey.creationDate] as! Date

        // quit if log file is not large enough yet
        action = "get attributes of " + path
        let fileAttr = try fileManager.attributesOfItem(atPath: path)
        guard let fileSize = fileAttr[FileAttributeKey.size] as? NSNumber else { fatalError("Unknown type of size from fileAttr") }
        guard fileSize.intValue > rotationFileSizeBytes else {return}

        // form rotation file name
