     SpySession
     KeyspaceProvider]))
 
-(def ^:dynamic *trace* nil)
-
-(defmacro with-debug
-  [& forms]
-  `(binding [*trace* true]
-     ~@forms))
-
 (defn- execute*
-  [alia-session statement opts]
+  [alia-session
+   statement
+   {trace? :trace?
+    :as  opts}]
   (aliam/execute
    alia-session
    (let [str-statement (if (string? statement)
                          statement
                          (h/->raw statement))]
-     (when *trace*
-       (debug str-statement))
+     (when trace?
+       (if (true? trace?)
+         (debug str-statement)
+         (log trace? str-statement)))
      str-statement)
-   opts))
+   (dissoc opts :trace?)))
 
 (defn- execute-buffered*
   "execute a statement returning a Deferred<Stream<record>>"
-  [alia-session statement opts]
+  [alia-session
+   statement
+   {trace? :trace?
+    :as  opts}]
   (return
    deferred-context
    (aliam/execute-buffered

        (s/reset-spy-log spy-session)
        (return true)))))

(defrecord AliaSpySession [keyspace alia-session spy-log-atom truncate-on-close]
  Session
  (execute [this statement]
    (s/execute this statement {}))
  (execute [_ statement opts]
    (swap! spy-log-atom conj statement)
    (execute* alia-session statement opts))
  (execute-buffered [this statement]
    (s/execute-buffered this statement {}))
  (execute-buffered [_ statement opts]
    (swap! spy-log-atom conj statement)
    (execute-buffered* alia-session statement opts))
  (close [self]
    (with-context deferred-context
      (mlet [_ (if truncate-on-close

  (reset-spy-log [_] (reset! spy-log-atom [])))

(defnk create-spy-session
  [contact-points
   datacenter
   keyspace
   {truncate-on-close nil}
   {trace? nil}
   :as args]
  (with-context deferred-context
    (mlet [datastax-session (create-alia-session*
                             (dissoc args
                                     :truncate-on-close
                                     :trace?))
           :let [spy-session (map->AliaSpySession
                              {:keyspace keyspace
                               :alia-session datastax-session
                               :spy-log-atom (atom [])
                               :truncate-on-close truncate-on-close
                               :trace? trace?})]]
      (return
       [spy-session
        (fn [] (s/close spy-session))]))))
