Skip to content

Commit

Permalink
Allow pspy to capture time for exception-throwing bodies (thanks Ja…
Browse files Browse the repository at this point in the history
…cek Lach)
  • Loading branch information
ptaoussanis committed Jul 19, 2013
1 parent 807cb40 commit 95109b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**[API docs](http://ptaoussanis.github.io/timbre/)** | **[CHANGELOG](https://github.com/ptaoussanis/timbre/blob/master/CHANGELOG.md)** | [contact & contributing](#contact--contributing) | [other Clojure libs](https://www.taoensso.com/clojure-libraries) | [Twitter](https://twitter.com/#!/ptaoussanis) | current [semantic](http://semver.org/) version:

```clojure
[com.taoensso/timbre "2.3.0"] ; See CHANGELOG for breaking changes since 1.x
[com.taoensso/timbre "2.3.1"] ; See CHANGELOG for breaking changes since 1.x
```

# Timbre, a (sane) Clojure logging & profiling library
Expand All @@ -26,7 +26,7 @@ Logging with Java can be maddeningly, unnecessarily hard. Particularly if all yo
Add the necessary dependency to your [Leiningen](http://leiningen.org/) `project.clj` and `require` the library in your ns:

```clojure
[com.taoensso/timbre "2.3.0"] ; project.clj
[com.taoensso/timbre "2.3.1"] ; project.clj
(ns my-app (:require [taoensso.timbre :as timbre
:refer (trace debug info warn error fatal spy with-log-level)])) ; ns
```
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.taoensso/timbre "2.3.0"
(defproject com.taoensso/timbre "2.3.1"
:description "Clojure logging & profiling library"
:url "https://github.com/ptaoussanis/timbre"
:license {:name "Eclipse Public License"
Expand Down
11 changes: 6 additions & 5 deletions src/taoensso/timbre/profiling.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
`(if-not *pdata*
(do ~@body)
(let [name# ~name
start-time# (System/nanoTime)
result# (do ~@body)
elapsed# (- (System/nanoTime) start-time#)]
(swap! *pdata* #(assoc % name# (conj (% name# []) elapsed#)))
result#))))
start-time# (System/nanoTime)]
(try
~@body
(finally
(let [elapsed# (- (System/nanoTime) start-time#)]
(swap! *pdata* #(assoc % name# (conj (% name# []) elapsed#))))))))))

(defmacro p [name & body] `(pspy ~name ~@body)) ; Alias

Expand Down

0 comments on commit 95109b7

Please sign in to comment.