Ah, very well. I find it useful to print out so I know which code is doing the logging, since stack inspection is very expensive, and in the case of clojure, looks like a mess of underscores and dollar signs. ;)
On Aug 6, 12:31 pm, Richard Newman <holyg...@gmail.com> wrote: > > In every case the name used by the log is the runtime *ns*, which > > really defeats the purpose of naming the specific usages of log. I'm > > surprised no one mentioned this (imo wrong) behavior. > > In my case, I don't see the namespace being printed in my log entries, > so I wasn't even aware this was happening until I looked at the code. > > > > > I'll get to work on fixing it so it behaves properly. > > > On Aug 5, 11:24 pm, Richard Newman <holyg...@gmail.com> wrote: > >>> Bah! I tried to simplify the example code, and missed conveying the > >>> actual problem. Your example code (and sadly, mine) pulls *ns* at > >>> runtime, the logging macro doesn't; it writes the value of the > >>> *ns* at > >>> macro-expansion-time precisely so that it will be the "right" value > >>> when called. > > >> Are you sure? > > >> From logging.clj: > > >> (defmacro log > >> "Logs a message, either directly or via an agent. See also the > >> level-specific > >> convenience macros." > >> ([level message] > >> `(log ~level ~message nil)) > >> ([level message throwable] > >> `(log ~level ~message ~throwable (str *ns*))) > >> ([level message throwable log-ns] > >> `(if (and @*allow-direct-logging* > >> (not (clojure.lang.LockingTransaction/isRunning))) > >> (do-log *log-system* ~level (delay ~message) ~throwable > >> ~log- > >> ns) > >> (send-off *log-system-agent* > >> do-log ~level (delay ~message) ~throwable ~log-ns)))) > > >> user=> (use 'clojure.contrib.logging) > >> nil > > >> user=> (macroexpand-1 '(log :info "Hello, world")) > >> (clojure.contrib.logging/log :info "Hello, world" nil) > > >> user=> (macroexpand-1 *1) > >> (clojure.contrib.logging/log :info "Hello, world" nil > >> (clojure.core/str clojure.core/*ns*)) > > >> user=> (macroexpand-1 *1) > >> (if (clojure.core/and (clojure.core/deref clojure.contrib.logging/ > >> *allow-direct-logging*) (clojure.core/not > >> (clojure.lang.LockingTransaction/isRunning))) > >> (clojure.contrib.logging/ > >> do-log clojure.contrib.logging/*log-system* :info (clojure.core/delay > >> "Hello, world") nil (clojure.core/str clojure.core/*ns*)) > >> (clojure.core/send-off clojure.contrib.logging/*log-system-agent* > >> clojure.contrib.logging/do-log :info (clojure.core/delay "Hello, > >> world") nil (clojure.core/str clojure.core/*ns*))) > > >> Looks like you want to unquote (str *ns*) in your definition... if I > >> do that and rebuild, the REPL looks much happier -- > > >> Clojure 1.1.0-alpha-SNAPSHOT > >> user=> (use 'clojure.contrib.logging) > >> nil > >> user=> (macroexpand-1 '(log :info "Hello, world")) > >> (clojure.contrib.logging/log :info "Hello, world" nil) > > >> user=> (macroexpand-1 *1) > >> (clojure.contrib.logging/log :info "Hello, world" nil "user") > > >> -R --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---