Is there a special variable that holds the name of the currently
running function so it can be output in a logging message?
I'm thinking of something like this:
(defn my-function []
(println entered *current-function*)
...
)
--
R. Mark Volkmann
Object Computing, Inc.
you might already have this way ... but probably only during debug since it
throws an exception and parses it.
http://forums.sun.com/thread.jspa?threadID=548409start=0
that page also mentions something that sounds better:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html
such a var by updating its value on every function entry
would be prohibitively expensive in runtime in the general case.
As e mentioned, it's possible to use the exception system to get the
name of the current function in a particular case.
Here's an example:
[debug_utils.clj]
(ns
at those locations instead.
[class-name]
(.replace
(re-sub #^(.+)\$(.+)__\d+$ $1/$2 class-name)
\_ \-))
(defmacro current-function-name []
Returns a string, the name of the current Clojure function
`(- (Throwable.) .getStackTrace first .getClassName unmangle))
[repl]
Clojure
On 3 Mai, 15:58, Mark Volkmann r.mark.volkm...@gmail.com wrote:
Is there a special variable that holds the name of the currently
running function so it can be output in a logging message?
I'm thinking of something like this:
(defn my-function []
(println entered *current-function*)