     (cond
       (:help options) (exit 0 (usage summary))
       errors (exit 1 (error-msg errors)))
-    (config-logging (:log options))
+    (init-logging (:log options))
     (process-fasta-files (:minlen options) arguments)))

;;; Module:      biotool.core
;;; Description: Reads one or more FASTA files and computes various
;;;              simple statistics about them. Intended as an example
;;;              bioinformatics command line tool 
;;; Copyright:   (c) Bernie Pope, 2017 
;;; License:     MIT 
;;; Maintainer:  bjpope@unimelb.edu.au

        options-summary]
       (string/join \newline)))

(defn error-msg
  "Display a message about command line errors.

   Arguments:
     errors: The command line errors that occurred (array of string).

   Result:
     nil
  "
  [errors]
  (str "The following errors occurred while parsing your command:\n\n"
       (string/join \newline errors)))

(defn exit
  "Print an error message to stderr and then exit the program
  with a given exit status.

  Arguments:
    status: The exit status of the program (non-negative integer).
    msg: Error message to display on stderr (string).

  Result:
    nil"
  [status msg]
  (binding [*out* *err*] println msg)
  (System/exit status))

(def cli-options
  "Define the command line options of the program."
  (let [default-minlen 0]
    [[nil "--minlen N" "Minimum length sequence to include in stats"
      :default default-minlen :parse-fn #(Integer/parseInt %)]
     [nil "--log LOG-FILE" "record program progress in LOG-FILE"]
     ["-v" "--version"]
     ["-h" "--help"]]))

(defn init-logging
  "Initialise program logging if a log-filename has been specified, and also log
  a message indicating that the program has started. Log messages are configured to
  be written to the specified log file.

  Arguments:
    log-filename: Either a string indicating the name of the log file, or nil indicating
      that no logging should happen

  Result:
    nil"
  [log-filename]
  ;; Turn off the default logging to stdout.
  (timbre/merge-config! {:appenders {:println {:enabled? false}}})
  (when log-filename
      ;; Enable log messages to be written to the specified log file.
      (timbre/merge-config! {:appenders {:spit (appenders/spit-appender {:fname log-filename})}})
      ;; Set the minimum log level to "info"
      (timbre/set-level! :info))
    ;; Write a log message indicating that the program has started.
    (timbre/info "Program started")
    (timbre/info "Command line: " (string/join " " *command-line-args*)))

(defn -main
  "Orchestrate the computation"
