<< Back to previous view

[TLOG-11] tools.logging doesn't AOT Created: 22/Mar/13  Updated: 30/Apr/13  Resolved: 30/Apr/13

Status: Closed
Project: tools.logging
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Allen Rohner Assignee: Alexander Taggart
Resolution: Declined Votes: 0
Labels: None

Waiting On: Allen Rohner

 Description   

tools.logging does not work if used in a project that is AOT'd.

To reproduce, in a project using tools.logging:

lein jar
lein run

I can workaround it in my project by including

(when *compile-files*
  (compile 'clojure.tools.logging)
  (compile 'clojure.tools.logging.impl))


 Comments   
Comment by Alexander Taggart [ 30/Apr/13 5:11 PM ]

It's not clear to me what "does not work" means.

I've made a quick test project: https://github.com/ataggart/aot-log-test

Cloning that repo, running lein jar then lein run yields the output I would expect.

Further details appreciated.

Comment by Allen Rohner [ 30/Apr/13 6:32 PM ]

This isn't a bug; User Error.

I thought I had fully isolated the bug in my app's codebase, but I forgot about an :injection that we have that jams a debug macro into clojure.core.

for posterity, it was caused by doing

(binding [*ns* (find-ns 'clojure.core)]
  (require 'clojure.tools.logging)
  (defmacro inspect
    "prints the expression '<name> is <value>', and returns the value"
    [value]
    `(do
       (let [value# (quote ~value)
             result# ~value]
         (println value# "is" (with-out-str (clojure.pprint/pprint result#)))
         (clojure.tools.logging/infof "%s is %s" value# result#)
         result#))

Moving the require call to inside the macroexpansion resolved the bug. (And yes, I'm moving to https://github.com/dgrnbrg/spyscope now that I'm aware of it)

Sorry to waste your time, Alex.

Comment by Alexander Taggart [ 30/Apr/13 7:06 PM ]

No worries.

On a related note, do you see any utility in keeping the spy macro? It's pretty much what you're doing. Do you use inspect for logging or as an in-repl debugging tool? Perhaps spy makes more sense in tools.trace.

Comment by Allen Rohner [ 30/Apr/13 7:12 PM ]

TBH, I didn't know about spy. Also, my inspect macro predates clojure.tools.logging, and might even predate clojure.contrib.logging, if you can believe that.

I use inspect as a debugging tool. The main value to jamming it into clojure.core is that I can use it in any file, without having to stop and muck with the ns declaration. Therefore if I was going to use anything else, it would need to have that property.

Generated at Fri Aug 22 22:52:13 CDT 2014 using JIRA 4.4#649-r158309.