Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken compile-time log's levels #43

Closed
prepor opened this issue Dec 3, 2013 · 3 comments
Closed

Broken compile-time log's levels #43

prepor opened this issue Dec 3, 2013 · 3 comments

Comments

@prepor
Copy link

prepor commented Dec 3, 2013

Hello! When I've started hacking #42 I found that timbre are broken :)

taoensso.timbre> (def level-compile-time :warn)
#'taoensso.timbre/level-compile-time
taoensso.timbre> (info "hello!")
CompilerException java.lang.Exception: Invalid logging level: level__5490__auto__, compiling:(/private/var/folders/mq/b8drc2px3gj486d1hj75w8800000gn/T/form-init934025151497129718.clj:1)

So let's look at macroexpansion:

(clojure.core/let [s1__5487__auto__ :info
                   default-config?__5488__auto__ (clojure.core/or
                                                  (clojure.core/keyword?
                                                   s1__5487__auto__)
                                                  (clojure.core/nil?
                                                   s1__5487__auto__))
                   config__5489__auto__ (if
                                            default-config?__5488__auto__
                                          @taoensso.timbre/config
                                          s1__5487__auto__)
                   level__5490__auto__ (if
                                           default-config?__5488__auto__
                                         s1__5487__auto__
                                         "hello!")]
  (clojure.core/when (taoensso.timbre/logging-enabled?
                      level__5490__auto__
                      config__5489__auto__)
    (clojure.core/when-let [juxt-fn__5491__auto__ (clojure.core/get-in
                                                   (taoensso.timbre/compile-config
                                                    config__5489__auto__)
                                                   [:appenders-juxt
                                                    level__5490__auto__])]
      (clojure.core/let [[x1__5492__auto__
                          &
                          xn__5493__auto__
                          :as
                          xs__5494__auto__] (if
                          default-config?__5488__auto__
                          (clojure.core/vector
                           "hello!")
                          (clojure.core/vector))
                          has-throwable?__5495__auto__ (clojure.core/instance?
                                                        java.lang.Throwable
                                                        x1__5492__auto__)
                          log-vargs__5496__auto__ (clojure.core/vec
                                                   (if
                                                       has-throwable?__5495__auto__
                                                     xn__5493__auto__
                                                     xs__5494__auto__))]
        (taoensso.timbre/send-to-appenders!
         level__5490__auto__
         {}
         log-vargs__5496__auto__
         "taoensso.timbre"
         (clojure.core/when has-throwable?__5495__auto__
           x1__5492__auto__)
         nil
         juxt-fn__5491__auto__
         :print-str
         (clojure.core/let [file__5497__auto__ "/private/var/folders/mq/b8drc2px3gj486d1hj75w8800000gn/T/form-init934025151497129718.clj"]
           (clojure.core/when (clojure.core/not=
                               file__5497__auto__
                               "NO_SOURCE_PATH")
             file__5497__auto__))
         1)))))

You can see here:

(taoensso.timbre/logging-enabled?
                      level__5490__auto__
                      config__5489__auto__)

But logging-enabled? itself is macro

(defmacro logging-enabled?
  "Returns true iff current logging level is sufficient and current namespace
  unfiltered. The namespace test is runtime, the logging-level test compile-time
  iff a compile-time logging level was specified."
  [level & [config]]
  (if level-compile-time
    (when (level-sufficient? level)
      `(let [ns-filter# (:ns-filter (compile-config (or ~config @config)))]
         (ns-filter# ~(str *ns*))))
    `(and (level-sufficient? ~level)
          (let [ns-filter# (:ns-filter (compile-config (or ~config @config)))]
            (ns-filter# ~(str *ns*))))))

And its trying to use level (actually level__5490__auto__ symbol from macroexpanstion). It's wrong.

I thing mistake is somewhere :) May be first let should not be quouted.

@ptaoussanis
Copy link
Member

Hi Andrew, thanks for reporting this - I believe I know what the problem is. Will try look into this w/in the next couple hours and get back to you.

@ptaoussanis
Copy link
Member

Hi Andrew, this should be fixed in 3.0.0-SNAPSHOT (on the dev branch). Cheers!

@ptaoussanis
Copy link
Member

Upd: fix is now in 3.0.0-RC2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants