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

mulog/trace captures incorrect namespace #35

Closed
bn-darindouglass-zz opened this issue Sep 18, 2020 · 2 comments · Fixed by #36
Closed

mulog/trace captures incorrect namespace #35

bn-darindouglass-zz opened this issue Sep 18, 2020 · 2 comments · Fixed by #36
Assignees
Labels
bug Something isn't working

Comments

@bn-darindouglass-zz
Copy link
Contributor

During implementation of mulog we found that when using mulog/trace the value for :mulog/namespace isn't the namespace where the trace/log originated.

Here's a minimal example:

(ns repl
  (:require [com.brunobonacci.mulog :as log]))

(defn log-something []
  (log/trace ::here [] (Thread/sleep 100)))

(ns other-ns
  (:require [com.brunobonacci.mulog :as log]))

(defn start-and-log []
  (let [pub (log/start-publisher! {:type :console :pretty? true})]
    (repl/log-something)
    pub))

Running clj -Scp $(lein classpath) -i repl.clj -e "(do (require 'other-ns) (other-ns/start-and-log) (Thread/sleep 1000))" returns the following:

{:mulog/event-name :repl/here,
 :mulog/timestamp 1600456838488,
 :mulog/trace-id #mulog/flake "4YMr-xWd4709HLRatGWaM4ZUjltmTpb7",
 :mulog/root-trace #mulog/flake "4YMr-xWd4709HLRatGWaM4ZUjltmTpb7",
 :mulog/duration 110060556,
 :mulog/namespace "user",
 :mulog/outcome :ok}
@bn-darindouglass-zz
Copy link
Contributor Author

The problem seems to be with the log-trace macro. It doesn't capture the value of *ns* at macroexpansion-time which means it'll use whatever *ns* is at call time.

@BrunoBonacci
Copy link
Owner

This is now released with v0.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants