Fork me on GitHub
#babashka
<
2024-03-28
>
kiemdoder05:03:05

Hi all, can I ask nbb questions in this channel or is there a separate channel for nbb?

borkdude06:03:49

#C029PTWD3HR

jjttjj16:03:11

Is there a quick way to disable all tools.logging output (at least all stdio output?) from a script? I tried https://stackoverflow.com/a/58854666:

(binding [clojure.tools.logging/*logger-factory*
          clojure.tools.logging.impl/disabled-logger-factory]
  (do-stuff-that-will-not-be-logged))
but clojure.tools.logging.impl/disabled-logger-factory apparently isn't available in babashka.
user=> (ns-publics 'clojure.tools.logging.impl)
{get-logger #'clojure.tools.logging.impl/get-logger, enabled? #'clojure.tools.logging.impl/enabled?}
edit: actually it's a private var so wouldn't show up in ns-publics, but the regular var derf trick of @@(requiring-resolve 'clojure.tools.logging.impl/disabled-logger-factory) is giving an NPE as well I had a little script that I used as a git credential fetcher and was expected to output a particular string, and it uses https://github.com/grzm/awyeah-api/blob/d98a9f6210c61d64f22e9b577d2254d6f6d2f35f/src/com/grzm/awyeah/credentials.cljc#L137-L141

borkdude16:03:25

.impl stuff isn't supposed to be used by users, it's an implementation detail

borkdude16:03:42

this is the reason why it isn't exposed

borkdude16:03:17

perhaps you can just bump the default log level

borkdude16:03:31

(however that is done using clojure.tools,logging...)

jjttjj16:03:03

Yeah I'm wondering if there is a way to set the clojure.tools.logging level without having to deal with some external logging imeplemntation's factory config files, since it previously was just a small 10 line script. My understanding is that this could be done by extending one of https://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging/impl.clj but I don't think they're available from babashka. I dont have much experience with tools.logging though

borkdude16:03:44

you can use timbre to set the logging level

borkdude16:03:51

the timbre logger is the default in bb

jjttjj16:03:08

ah! didn't realize that, should be able to do that. thanks

borkdude09:03:14

did it work?

jjttjj11:03:48

Yup! Just required timbre and did set-level! To error

👍 1