         // quit if log file is not large enough yet
         action = "get attributes of " + path
         let fileAttr = try fileManager.attributesOfItem(atPath: path)
-        let fileSize = fileAttr[FileAttributeKey.size] as! NSNumber
+        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

        formatter.locale = Locale(identifier: "en_US_POSIX")
        formatter.dateFormat = rotationFileDateFormat
        let dateString = formatter.string(from: Date())
        let rotationFilePath = logFileDirectory! + logFileBaseName + dateString + logFileSuffix

        // actually rotate
        owner?._logln("Auto rotate for \(cause.description) at size \(fileSize.intValue)", level: .info)


        // assemble a dictionary of date:file
        var fileDateMap = [Date: String]()
        guard let logFileDirectory = logFileDirectory else { fatalError("logFileDirectory is nil") }
        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
