     }
 
     init?(filename: String, flags: Int32, key: String? = nil, prevKey: String? = nil) {
+        log.debug("Opening connection to \(filename).")
         self.filename = filename
         self.queue = dispatch_queue_create("SQLite connection: \(filename)", DISPATCH_QUEUE_SERIAL)
-        if let _ = openWithFlags(flags) {
+        if let failure = openWithFlags(flags) {
+            log.warning("Opening connection to \(filename) failed: \(failure).")
             return nil
         }
 


    /// Closes a connection. This is called via deinit. Do not call this yourself.
    private func closeCustomConnection() -> NSError? {
        let status = sqlite3_close(sqliteDB)

        sqliteDB = nil

        if status != SQLITE_OK {
            return createErr("During: Closing Database with Flags", status: Int(status))
        }

        return nil

    }

    deinit {
        log.debug("deinit: closing connection on thread \(NSThread.currentThread()).")
        closeCustomConnection()
    }

