;; Original, un-instrumented function
(defn as-currency
"Money amounts are transmitted as \\"$2.44\\".
Parse this and return a numeric type."
[currency-amount]
(-> (subs currency-amount 1)
(bigdec)))
;; Instrumented versions:
(defn as-currency
"Money amounts are transmitted as \\"$2.44\\".
Parse this and return a numeric type."
[currency-amount]
(let [currency (-> (subs currency-amount 1)
(bigdec))]
(log/debug currency)
currency))
(defn as-currency
"Money amounts are transmitted as \\"$2.44\\".
Parse this and return a numeric type."
[currency-amount]
(-> (subs currency-amount 1)
(bigdec)
((fn [x] (log/debug x) x))))
(defn as-currency
"Money amounts are transmitted as \\"$2.44\\".
Parse this and return a numeric type."
[currency-amount]
(doto (-> (subs currency-amount 1)
(bigdec))
(log/debug)))
;;;; The instrumented versions all output the same logging data:
;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 1200.20
;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 0.03
;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 120.00
;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 5.99
;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 20
;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 12.33
;; NumberFormatException java.math.BigDecimal.<init> (BigDecimal.java:494)