This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-03
Channels
- # beginners (7)
- # calva (25)
- # clerk (2)
- # clj-kondo (5)
- # clojure (42)
- # clojure-brasil (1)
- # clojure-europe (10)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojure-uk (3)
- # conjure (6)
- # datahike (4)
- # datomic (3)
- # etaoin (4)
- # fulcro (6)
- # graalvm (7)
- # hoplon (9)
- # hyperfiddle (6)
- # introduce-yourself (2)
- # london-clojurians (1)
- # off-topic (22)
- # pedestal (5)
- # portal (12)
- # proletarian (1)
- # releases (1)
- # shadow-cljs (9)
- # vim (9)
Can anyone give me a hint on how to use the *ns*
dynamic variable in native image? Imagine I have a macro for logging:
(defmacro logf [level template & args]
`(println (ns-name *ns*)
(-> ~level name str/upper-case)
(format ~template ~@args)))
In repl, it renders the corresponding ns like my.project.utils INFO ...
. But when running a binary file, I see clojure.core INFO
everywhere. Is it even possible with native image?@U1WAUKQ3E I mean:
(defmacro logf [..] (let [nsn (ns-name *ns*)] `(println ... ~nsn)))
Not sure if that would helpYou were right! Here is the final version of my logging ns:
(ns lambda-demo.log
(:require
[clojure.string :as str]))
(defmacro logf [level template & args]
(let [nsn (ns-name *ns*)]
`(println '~nsn
(-> ~level name str/upper-case)
(format ~template ~@args))))
(defmacro debugf [template & args]
`(logf :debug ~template ~@args))
(defmacro infof [template & args]
`(logf :info ~template ~@args))
(defmacro errorf [template & args]
`(logf :error ~template ~@args))