 
     var fileManager = NSFileManager.defaultManager()
     var calendar = NSCalendar.currentCalendar()
-    var mutex : Mutex?
+    var mutex = Mutex()
     var baseName : String
     var dateFormatter = NSDateFormatter()
     var keepDays : Int

    }

    class func createFileLog(name: String, fileName: String, formatter: LogFormatter?) throws -> FileLog {
        return try FileLog(name: name, fileName: fileName, formatter: formatter)
    }

    // MARK: override LogManager.Log

    override func log(entry : LogManager.LogEntry) -> Void {
        if daysBetween(entry.timestamp, and: mostRecentLog!) > 0 {
            try! cleanup(entry.timestamp)
        }

        mostRecentLog = entry.timestamp

        // delegate

        delegate!.log(entry)
    }
}
        self.formatter = formatter != nil ? formatter! : LogManager.Log.defaultFormatter

        let exists = fileManager.fileExistsAtPath(logName())
        mostRecentLog = NSDate()
        delegate = try! createFileLog()

        if exists {
            mostRecentLog = delegate!.lastModificationDate()
        }

        // initial cleanup

        try cleanup(NSDate())
    }

    // MARK: internal

    func dateRegex(pattern : String) -> String {
        //regexp = try NSRegularExpression(pattern: "\\b([a-z|_|A-Z|\\-]+)\\-(\\d{4}\\-\\d{2}\\-\\d{2})\\.log\\b", options: [])


        return ""
    }

    public func createLogDirectory(directoryPath : String)  throws -> NSURL {
        let url = NSURL(fileURLWithPath: directoryPath, isDirectory: true)
