MichaelDrogalis / dire

Erlang-style supervisor error handling for Clojure
482 stars 20 forks source link

Provide a pre+post hooks (and conditions). #26

Closed ludwik closed 9 years ago

ludwik commented 10 years ago

This is a feature request where by "pre and post" hook is created as one item. This way we could log out or act on a function based on the values is consumed AND generated. This seems to be not possible right now.

example:

(defn addme [x y]  (+ x y))

(with-pre-post-hook! #'addme
   (fn [result x y] (println "x:" x " added to y: " y " gave the result " result ))

(addme 1 2)     => "x: 1 added to y: 2 gave the result 3"

I think this could be great for debugging, without polluting the function implementations.

Thanks!

L

MichaelDrogalis commented 10 years ago

@ludwik Interesting idea. Would night-vision help for now?

MichaelDrogalis commented 10 years ago

Considering implementation. I'll let you know soon. :)

ludwik commented 10 years ago

Great!

Night-vision feels like the light weight repl use case. This being in dire feels like it could be used in production to embed optional debug logging, without code alterations, which is v cool.

MichaelDrogalis commented 10 years ago

Yeah, I like this. I'll try to get it out by the end of this week.

MichaelDrogalis commented 10 years ago

Really busy this week. Might be able to get to it next week. Patch would be stellar, too. ;)

MichaelDrogalis commented 9 years ago

Fixed in #28.