Skip to content
A simple amon client for clojure
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A simple amon client in clojure, uses chesire to convert data structures to json and clj-http to hit amon's api; supports tagging functionality to associate logged data into groups.


Add [amon-log "0.1.1"] to your project.clj file under :dependencies and run lein deps.

To send the data directly to amon, use to-amon. You must provide a hashmap containing a clojure structure to be logged named :data and optionally a vector of classification keywords named :tags.

(require '[amon-log.core :as log])

;; (log/to-amon my-log-data)
(log/to-amon {:data my-clojure-data})
(log/to-amon {:data my-clojure-data :tags [:vector :of :keywords]})

You can also wrap your function with a log to retain a single clojure form.

(require '[amon-log.core :as log])

;; (log/with-amon my-log-data my-func my-args)
  {:data '(Im adding numbers together!) 
   :tags [:math :simple]}
  + 1 2)
;; returns 3, and logs "Im adding numbers together!" with the tags of "math" and "simple".

You can log your exceptions with exception-to-amon. By default it will include the stacktrace, the error class, a timestamp and the exception message.

You can optionally give amon richer error context by providing a hashmap containing any clojure data structure that can be converted to json.

(require '[amon-log.core :as log])

;; (log/exception-to-amon my-exception)
;; (log/exception-to-amon my-exception my-hashmap)
(defn divide-with-amon
  [numerator denominator]
      (/ numerator denominator) 
      (catch Exception e 
          (log/exception-to-amon e {:context "Caused by 'divide-with-amon'" 
                                    :args [numerator, denominator]})
          (your-own-handler e)))))

(divide-with-amon 10 5) ; returns 2
(divide-with-amon 10 0) ; logs the error to amon and passes the exception to 'handle-error'

Note: if your amon instance lives at an address other than you can change it by binding the *amon-host* var.

;; logs to
(binding [*amon-host* ""] 
  (with-amon {:data '(Hello world)} println "Hello world."))

Amon will fail silently if the amon host is not available. If you need different behavior you can bind amon-throws-exceptions to true.

;; will raise an exception due to logging failure
(binding [*amon-host* "amon.badhost.fake"
          *amon-throws-exceptions* true] 
  (with-amon {:data '(Hello world)} println "Hello world."))


Add functionality to wrap (i.e. extend) an exception class with amon logging


Copyright (C) 2012

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.