   "Retrieve value from REF."
   (gethash t ref))
 
-(defun emacsql-connect (file)
-  "Open a connected to database stored in FILE."
+(cl-defun emacsql-connect (file &key log)
+  "Open a connected to database stored in FILE.
+
+:log LOG -- When non-nil, log all SQLite commands to a log
+buffer. This is for debugging purposes."
   (emacsql-start-reap-timer)
   (let* ((buffer (generate-new-buffer "*emacsql-connection*"))
          (process (start-process "emacsql" buffer sqlite-program-name file)))

  "Path to the sqlite3 executable.")

(cl-defstruct (emacsql (:constructor emacsql--create))
  process file)

(defvar emacsql-connections ()
  "Collection of all known emacsql connections.

    (process-send-string process ".prompt #\n")
    (process-send-string process ".mode line\n")
    (let ((emacsql (emacsql--create :process process :file file)))
      (when log
        (setf (emacsql-log emacsql) (generate-new-buffer "*emacsql-log*")))
      (prog1 emacsql
        (push (cons (copy-seq emacsql) (emacsql--ref emacsql))
              emacsql-connections)))))
