 ; perfomance log
 (defonce log-msgs (atom []))
 (defn add-log [msg]
-  (let [msg (clojure.string/join " " [(Thread/currentThread) (System/currentTimeMillis) msg "\r\n"])]
-  (swap! log-msgs conj msg)))
+  (if (< (count @log-msgs) 4096)
+    (do
+      (let [msg (clojure.string/join " " [(Thread/currentThread) (System/currentTimeMillis) msg "\r\n"])]
+      (swap! log-msgs conj msg)))))
 (defn dump []
   (do
     (with-open [wrtr (writer "perfomance.txt" :append true)]

        (do
          (send! channel
            (json-str {:status "ok" :data (sort-by :id < (filter (fn [msg] (>= (:id msg) last-id)) @all-msgs))}))
          (swap! clients-last-id assoc channel cur-id)
          (clear-old-msgs))))))
; perfomance dump version 1
(defmethod process-packet ["dump" "1"] [packet channel] (dump))
; default method - simple print packet

  (when (:data packet)
    (let [author (@clients channel) text (strip-html-tags (:data packet))]
      (do
        (add-msg-to-storage {:id (next-id) :time (now) :msg text :author author})
        (send! channel (json-str {:status "ok"}))))))
; fetch version 1
(defmethod process-packet ["fetch" "1"] [packet channel]
  (let [last-id (@clients-last-id channel) cur-id (+ @max-id 1)]
