Fork me on GitHub
#babashka
<
2023-11-06
>
jmglov06:11:52

I'm up to no good again, which also means I'm in the sort of trouble that only the Clojurians hivemind can solve. It seems that the clojure.tools.logging support in babashka doesn't provide clojure.tools.logging.test, so I thought I'd be clever and stuff https://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging/test.clj into my project. Not so clever, it turns out, because when I try to eval it, I get a lovely exception:

clojure.lang.ExceptionInfo: Could not resolve symbol: impl/LoggerFactory
{:type :sci/error, :line 202, :column 3, :message "Could not resolve symbol: impl/LoggerFactory", ...}
 at sci.impl.utils$rethrow_with_location_of_node.invokeStatic (utils.cljc:129)
    sci.impl.utils$rethrow_with_location_of_node.invoke (utils.cljc:93)
I've dropped the full exception into a https://gist.github.com/jmglov/bcb9f7bf8b5cdbdbab143bdff31c401a. Does anyone have a clue what's going on here and how to make it work? I'll keep poking in the meantime, but I imagine someone here will slap me upside the head with the solution before I bang my head against the wall enough that it crumbles (the wall, not my head—I hope!) and reveals the truth beyond.

Eugen09:11:34

babashka uses timbre for loggign I believe, because it's a clojure logging library. clojure.tools.logging being a facade does pull in some code for implementations - which are java based. being java baased they can't work with bb unless they are compiled in - which will increase size of bb binary

borkdude09:11:50

What is clojure.tools.logging.test for?

Eugen09:11:35

"Support for testing whether logging calls are made.> > Usage example: > (require '[clojure.tools.logging :as log] > '[clojure.tools.logging.test :refer [logged? with-log]) > (with-log > (log/info \"Hello World!\") > (log/error (Exception. \"Did a thing\") \"Error: oops\") > (logged? 'user :info #\"Hello\") ; true > (logged? 'user :error [Throwable #\"thing\"] #\"Error:\") ; true > (logged? 'user :debug \"Hi\")) ; false"}

borkdude09:11:13

and how important is this to get working in bb?

borkdude09:11:15

I'm mostly asking @U054AT6KT here since he's the one who tried to use it in bb ;)

jmglov17:11:25

It’s not crucial, but I was looking at using it in awyeah-api, as I’m porting across the new changes that have been made in aws-api.

jmglov17:11:30

Since bb includes clojure.tools.logging, it was just surprising that c.t.l.test wasn’t available. Not a big deal; I can certainly live without it.

borkdude17:11:03

yeah I only added the most frequently used things, so that clarifies it

1
borkdude10:11:17

hehe great. using clojure.data.json is fine, but it 1) is much much slower than using a built-in JSON client, so for big payloads, I don't recommend this approach and 2) it affects startup time since it has to load/process all of that code too

borkdude10:11:40

using a reader condition or a if-bb macro would be good if you want to optimize this

borkdude10:11:50

same for http-client etc

jmglov12:11:13

awyeah (and by extension, awno) uses bb’s built-in Cheshire and the java.net.http stuff that’s baked into bb as well.

borkdude13:11:55

I see, I thought I read something about clojure.data.json

jmglov13:11:44

You read about ripping it out and using Cheshire instead. 😅

jmglov13:11:25

I’m not sure why Cognitect’s aws-api uses clojure.data.json. Maybe they reckon that payloads returned by AWS API calls aren’t too large. :man-shrugging::skin-tone-3:

borkdude13:11:25

clojure.data.json is fine in JVM Clojure, but when executed through SCI it's slow

borkdude13:11:53

since the overhead of reading a file character by character is just way too much interpreter overhead

jmglov13:11:57

Ah, OK. Makes sense.

Thierry14:11:13

Replacing bash scripts with babashka scripts feels so rewarding 💯

🎉 12
☝️ 10
babashka 8
🚀 7
💯 7
4
1
lispyclouds15:11:50

One of my favourite bash rewrites: https://github.com/babashka/babashka/pull/1239 which incidentally caused one of our more severe incidents 😅 hence more memorable 😆

Felix Dorner15:11:30

Worth it just alonw for reader comments. I find myself prefixing optional shell args with #_ and it doesnt work! :stuck_out_tongue:

borkdude15:11:30

I do it too in JavaScript... it doesn't work

Felix Dorner15:11:59

It should work anywhere no? In ALL languages

borkdude15:11:21

agreed... also, comma's optional!

💯 2