Skip to content

Instantly share code, notes, and snippets.

@deobald
Created June 14, 2011 22:22
Show Gist options
  • Save deobald/1026083 to your computer and use it in GitHub Desktop.
Save deobald/1026083 to your computer and use it in GitHub Desktop.
Get a meaningful clojure call stack from anywhere.
(defn ignored? [classname]
(let [ignored #{"callers" "dbg" "clojure.lang" "swank" "eval"}]
(some #(s/substring? % classname) ignored)))
(defn callers []
(let [fns (map #(str (.getClassName %))
(-> (Throwable.) .fillInStackTrace .getStackTrace))]
(vec (doall (remove ignored? fns)))))
@MatthewDarling
Copy link

For any internet denizens who wind up here, here's a working version of the ignored? function for Clojure 1.6:

(defn ignored? [classname]
  (let [ignored #{"callers" "dbg" "clojure.lang" "swank" "nrepl" "eval"}]
    (some #(re-find (re-pattern %) classname) ignored)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment