Skip to content

Commit

Permalink
added more flexible leveling
Browse files Browse the repository at this point in the history
  • Loading branch information
source-c committed Apr 6, 2018
1 parent c0b8d86 commit 84558fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.1.7
33 changes: 22 additions & 11 deletions src/sentry_tiny/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,30 @@
:headers {"X-Sentry-Auth" header "User-Agent" client-name}
:body (json/generate-string event-info)})))

(defn capture [packet-info event-info]
(defn -level [^String level]
(or (#{"error"
"fatal"
"warning"
"info"
"debug"} level) "error"))

(def ^:private elevel (memoize -level))

(defn capture
"Send a message to a Sentry server.
event-info is a map that should contain a :message key and optional
keys found at http://sentry.readthedocs.org/en/latest/developer/client/index.html#building-the-json-packet"
(send-event
packet-info
(merge
{:level "error"
:platform "clojure"
:server_name @hostname
:timestamp (ft/unparse (ft/formatters :date-hour-minute-second) (t/now))
:event_id (generate-uuid)}
event-info)))
keys found at https://docs.sentry.io/clientdev/attributes/#optional-attributes"
([packet-info event-info] (capture packet-info event-info "error"))
([packet-info event-info ^String level]
(send-event
packet-info
(merge
{:level (elevel level)
:platform "clojure"
:server_name @hostname
:timestamp (ft/unparse (ft/formatters :date-hour-minute-second) (t/now))
:event_id (generate-uuid)}
event-info))))

(defn- add-info [event-map iface info-fn req]
(if info-fn
Expand Down

0 comments on commit 84558fa

Please sign in to comment.