On Dec 14, 2011, at 11:48 PM, jaime wrote: > I want to write a function named "debug" which will print out "date- > time msg + current source-line + etc. info", but I don't know how to > get the current source and line number of the running point (just like > what REPL does when encounter any exceptions) ...
In addition to Jay's solution (getting line number information out of a form), here's code that gets it from Java: (defn user-file-position "Guesses the file position (basename and line number) that the user is most likely to be interested in if a test fails." [] (second (map #(list (.getFileName %) (.getLineNumber %)) (.getStackTrace (Throwable.))))) (This is derived from the one in clojure.test.) Midje has no less than three ways of determining which file/line to print. They're in https://github.com/marick/Midje/blob/master/src/midje/internal_ideas/file_position.clj The other two are fairly specific to Midje, so they're probably harder to understand, but they may be of use. ----- Brian Marick, Artisanal Labrador Now working at http://path11.com Contract programming in Ruby and Clojure Occasional consulting on Agile -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en