         ;; client -> target
         (loop []
           (when-some [client-msg (transport/recv client-transport)]
-            (log log-out :client client-msg)
+            (send write-agent log log-out :client client-msg)
             (transport/send target-transport client-msg)
             (recur)))
         (catch Exception e


(defonce print-lock (Object.))

(defn log [out from msg]
  (let [text (with-out-str (pprint msg))]
    (prn [:msg from (count text)])
    (locking print-lock

        (println ";; ----------------------------------------")
        (println ";; -- FROM " from)
        (println ";; ----------------------------------------")
        (println text))))
  agent-state)

(defn client-loop [id client to-port]
  (let [target (Socket. "localhost" to-port)
