 
 (defn unify-and-log [a b model]
   (let [result (unify a b)]
-    (log-unification-result a b result model)
+    (when (and (not (= :fail a)) (not (= :fail b)))
+      (if (= :fail result)
+        (let [message (str "failed to unify:( "
+                           "  a: " ((:morph-ps model) a) ","
+                           "  b: " ((:morph-ps model) b)
+                           "  morph a: " ((:morph model) a) ","
+                           "  b: " (keys b)
+                           ") => fail@" (fail-path a b))]
+          (handle-unify-fail message)
+          (if (= true throw-exception-on-unify-fail)
+            (throw (Exception. message))))
+        
+        (log/debug (str "unify(" ((:morph-ps model) a)
+                        " , " ((:morph-ps model) b) ") => "
+                        ((:morph-ps model) result)))))
     result))
 
 (defn comp-path-to-complements

;; use map or pmap.
(def ^:const mapfn map)

(def ^:const exception-on-unify-fail
  false)

;; deterministic generation:
;;(def ^:const shufflefn (fn [x] x))

(declare find-comp-paths)
(declare get-lexemes)
(declare lexemes-before-phrases)
(declare lightning-bolts)
(declare not-fail?)
(declare unify-and-log)

;; TODO: demote 'depth' and 'max-depth' down to lower-level functions.
(defn generate-all [spec model & [depth max-depth]]
  (let [depth (or depth 0)
        truncate truncate
