 (ns riemann.campfire
   "Forwards events to Campfire"
-  (:use [clojure.string :only [join]])
+  (:use [clojure.string :only [join upper-case]])
   (:require [clj-campfire.core :as cf]))
 
 (defn cf-settings

  [settings room-name]
  (cf/room-by-name settings room-name))

(defn format_string
  [e]
  (str (join " " ["HOST:" (str (:host e)) "SERVICE:" (str (:service e)) "STATE:" (str (:state e)) "DESC:" (str (:description e))]))
  )

(defn campfire
  "Creates an adaptor to forward events to campfire.
  TODO: write more here once the event formatting is better.
  TODO: tests
  Tested with:
  (streams
    (by [:host, :service]

        camp)))"
  [token ssl sub-domain room-name]
  (fn [e]
    (let [string (campfire_message e)
          settings (cf-settings token ssl sub-domain)]
      (cf/message (room settings room-name) string))))
