Fork me on GitHub
#clojure
<
2022-10-04
>
Kevin Izevbigie07:10:02

When using next.jdbc, how can I remove this from being printed to the command line: 3850 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated id like to only see what I print.

Ben Sless07:10:05

As you can see it's coming from your connection pool, not next.jdbc Have you checked how hikari's log levels can be configured?

Kevin Izevbigie07:10:39

Id like to stop it irrespective of where it comes from. How do I check the logs?

rolt09:10:34

there are many different logging implementation in java so it's hard to help unless we know what you are using. Are you using logback ? You can setup level by prefix, so let's say your app is called "my_project" (so every namespace in your source file starts with "my_project.*", you could have a config like that:

default: off
overrides:
  my_project: all

rolt09:10:01

i don't think that's a good idea though, you might miss some pretty important messages, so it's better to configure the default to at least warn

Ben Sless10:10:40

Look in hikari and see it uses slf4j Then configure slf4j however it's configured for the proper logger name and set the desired logging level

lread13:10:16

Logging can be configured at the package/class and info level. Here's the https://github.com/brettwooldridge/HikariCP/blob/dev/src/main/java/com/zaxxer/hikari/HikariDataSource.java that is doing the logging. As suggested above, unless it is super noisy, I'd live with the log line, as you might end up turning off valuable logging info.

madis10:10:07

Hello. I'm trying to pretty print clojure data structure in Babashka so that namespaced keyword stays like :is.mad/wut instead of #:is.mad{:wut} In Clojure clj the following works (1)

(binding [*print-namespace-maps* false] (clojure.pprint/pprint {:is.mad/wut 42}))
{:is.mad/wut 42}
But in babashka REPL (https://github.com/babashka/babashka) the *print-namespace-maps* binding doesn't seem to have effect (2)
(binding [*print-namespace-maps* false] (clojure.pprint/pprint {:is.mad/wut 42}))
#:is.mad{:wut 42}
Is there a way to achieve the 1st result with babashka? Found these places in Clojure source that seemed relevant https://github.com/clojure/clojure/blob/5ffe3833508495ca7c635d47ad7a1c8b820eab76/src/clj/clojure/pprint/dispatch.clj#L109 https://github.com/clojure/clojure/blob/5ffe3833508495ca7c635d47ad7a1c8b820eab76/src/clj/clojure/core_print.clj#L250

borkdude10:10:07

This is a edge-case in bb which should be solved in the coming release: https://github.com/babashka/babashka/issues/1381

borkdude10:10:55

If you want and have time you can look into this yourself and I could guide you

madis10:10:34

Wow, awesome man. That's fast. Someone's been practicing mind reading looks like 😄 I'll see on the weekend if I can do a pull request for it (unless someone takes it first). I've never contributed to babashka, so getting started may take a bit of time

borkdude10:10:20

So the PR would be adding that + adding a test

bg12:10:23

@U04V15CAJ It’s a small change and I can create a PR right-away. One question, should we expose the var via sci (copy it from sio) or should we directly access sio/print-namespace-maps from babashka.impl.pprint ? We could add this line to sci.core#130 -

(def print-namespace-maps "SCI var that represents SCI's `clojure.core/*print-namespace-maps*`" sio/print-namespace-maps)

partyparrot 1
borkdude12:10:19

yes, the latter would be a good addition

bg12:10:34

Thanks. So I will first add a PR for sci

borkdude12:10:42

sounds good :)

borkdude12:10:49

I'll bump SCI afterwards in bb

bg12:10:18

@U04V15CAJ I need some help with writing a proper test for this. I can see that there is a similar test in io_test.cljc that uses println, but I am unable to figure out a good way to test this new exposed var in sci.core Would appreciate suggestions.

bg13:10:27

This is just about exposing a new var from sci.core

borkdude13:10:31

@U0505RKEL You can just write a test in core_test.clj like this: (sci/binding [sci/print-namespace-maps ...] (sci/eval-string ...))

bg13:10:42

Thanks!

bg13:10:27

Is this an acceptable test for the presence of the dyn var?

(deftest print-namespace-maps-var-test
  (is (= (sci/binding [sci/print-namespace-maps :test-val]
           (sci/eval-string "*print-namespace-maps*"))
        :test-val)))

bg13:10:06

I feel bringing in pprint etc in core_test may not be the best thing. Open to suggestions.

borkdude13:10:22

There may already be a pprint test in sci somewhere

borkdude13:10:44

There is sci.pprint which there may be a test for

bg13:10:07

there are tests for pprint, yes

bg13:10:12

I added this test to pprint_test.clj in sci, but it’s failing -

(deftest print-namespace-maps-test
  (is (= "{:x/a 1 :x/b 2}"
        (str/trim
          (sci/with-out-str
            (sci/binding [sci/print-namespace-maps false] ;; was trying both to test
              (sci/eval-string "
(require '[clojure.pprint :as pprint])
(binding [*print-namespace-maps* false]
  (pprint/pprint {:x/a 1 :x/b 2}))
"
               conf)))))))

bg13:10:25

I wonder what I am doing wrong :thinking_face:

borkdude13:10:40

it's failing how?

bg13:10:57

(not (= "{:x/a 1 :x/b 2}" "#:x{:a 1, :b 2}")) the dyn var setting is not getting picked up

borkdude13:10:28

This is the same issue that should be fixed in babashka. You should re-bind the clojure var to the value of the SCI var

bg13:10:51

I already have this in core.cljc -

(def print-namespace-maps "SCI var that represents SCI's `clojure.core/*print-namespace-maps*`" sio/print-namespace-maps)
sio is already capturing the var as core-dynamic-var Do I need to do something additional for the tests?

borkdude13:10:49

sorry, doing something else at the moment, will come back

bg13:10:14

No worries. I appreciate the help.

bg14:10:40

I have figured it out 🎉

borkdude14:10:57

OK, PR is now pushed to bb as well

borkdude14:10:08

feel free to continue

bg14:10:57

Yes, second PR for babashka is also ready.

borkdude14:10:50

I don't see it yet... :)

bg14:10:54

I am yet to push it sir. I will do it soon 🙂

borkdude15:10:25

oh, take your time ;)

1
bg18:10:55

@U013E93QDJ5 The fix is now available on Babashka 🎉

🙌 1
madis11:10:40

Thanks @U0505RKEL, just built babashka from master and it works perfectly!

clojure-spin 2
borkdude11:10:50

You can also go here for dev builds :) https://github.com/babashka/babashka-dev-builds

🎉 1
Drew Verlee16:10:12

Why would evaling the Handler expression below result in a java.lang.RuntimeException? My best guess is that the close expression doesn't know what the

(ns foo.cast
  "Monitoring library."
  (:require [centriq-web.env :as env])
  (:import [java.util ArrayList Collection UUID]
           [java.util.concurrent BlockingQueue LinkedBlockingQueue]))

(set! *warn-on-reflection* true)

(defprotocol HandlerImpl
  (register* [_ type cb]
    "Internal, do not call. Register callback for the given type.")
  (enqueue* [_ data]
    "Internal, do not call. Enqueue the given data to be dispatched to callbacks."))

(deftype Handler [^BlockingQueue q ^Thread t callbacks]
  java.lang.AutoCloseable
  (close [_]
    (.put q q) ;; <---- this seems to be the issue.
    (.join t))
  HandlerImpl
  (register* [_ type callback]
    (swap! (get callbacks type) conj callback))
  (enqueue* [_ data]
    (.offer q (assoc data
                     :id (UUID/randomUUID)
                     :thread (.getName (Thread/currentThread))
                     :timestamp (System/currentTimeMillis)))))

Drew Verlee16:10:33

full stack trace:

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling src/centriq_web/cast.clj at (18:5)
   #:clojure.error{:phase :compile-syntax-check,
                   :line 18,
                   :column 5,
                   :source
                   "/home/drewverlee/Centriq/centriq-web/backend/src/centriq_web/cast.clj"}
             Compiler.java: 6825  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 3893  clojure.lang.Compiler$InvokeExpr/parse
             Compiler.java: 7126  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 3900  clojure.lang.Compiler$InvokeExpr/parse
             Compiler.java: 7126  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 3900  clojure.lang.Compiler$InvokeExpr/parse
             Compiler.java: 7126  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6135  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7112  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 1020  clojure.lang.Compiler$HostExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7112  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6135  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 8570  clojure.lang.Compiler$NewInstanceMethod/parse
             Compiler.java: 8076  clojure.lang.Compiler$NewInstanceExpr/build
             Compiler.java: 7952  clojure.lang.Compiler$NewInstanceExpr$DeftypeParser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6135  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 6453  clojure.lang.Compiler$LetExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7112  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6137  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 6453  clojure.lang.Compiler$LetExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6137  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 5479  clojure.lang.Compiler$FnMethod/parse
             Compiler.java: 4041  clojure.lang.Compiler$FnExpr/parse
             Compiler.java: 7122  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7191  clojure.lang.Compiler/eval
             Compiler.java: 7149  clojure.lang.Compiler/eval
                  core.clj: 3215  clojure.core/eval
                  core.clj: 3211  clojure.core/eval
             enlighten.clj:   84  cider.nrepl.middleware.enlighten/eval-with-enlighten
             enlighten.clj:   78  cider.nrepl.middleware.enlighten/eval-with-enlighten
                  Var.java:  384  clojure.lang.Var/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1990  clojure.core/with-bindings*
                  core.clj: 1990  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  218  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  217  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  833  java.lang.Thread/run

1. Caused by java.lang.RuntimeException
   Unable to resolve symbol: STATE__ in this context

                 Util.java:  221  clojure.lang.Util/runtimeException
             Compiler.java: 7431  clojure.lang.Compiler/resolveIn
             Compiler.java: 7375  clojure.lang.Compiler/resolve
             Compiler.java: 7336  clojure.lang.Compiler/analyzeSymbol
             Compiler.java: 6785  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 3893  clojure.lang.Compiler$InvokeExpr/parse
             Compiler.java: 7126  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 3900  clojure.lang.Compiler$InvokeExpr/parse
             Compiler.java: 7126  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 3900  clojure.lang.Compiler$InvokeExpr/parse
             Compiler.java: 7126  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6135  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7112  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 1020  clojure.lang.Compiler$HostExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7112  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6135  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 8570  clojure.lang.Compiler$NewInstanceMethod/parse
             Compiler.java: 8076  clojure.lang.Compiler$NewInstanceExpr/build
             Compiler.java: 7952  clojure.lang.Compiler$NewInstanceExpr$DeftypeParser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6135  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 6453  clojure.lang.Compiler$LetExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7112  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6137  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 6453  clojure.lang.Compiler$LetExpr$Parser/parse
             Compiler.java: 7124  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 6762  clojure.lang.Compiler/analyze
             Compiler.java: 6137  clojure.lang.Compiler$BodyExpr$Parser/parse
             Compiler.java: 5479  clojure.lang.Compiler$FnMethod/parse
             Compiler.java: 4041  clojure.lang.Compiler$FnExpr/parse
             Compiler.java: 7122  clojure.lang.Compiler/analyzeSeq
             Compiler.java: 6806  clojure.lang.Compiler/analyze
             Compiler.java: 7191  clojure.lang.Compiler/eval
             Compiler.java: 7149  clojure.lang.Compiler/eval
                  core.clj: 3215  clojure.core/eval
                  core.clj: 3211  clojure.core/eval
             enlighten.clj:   84  cider.nrepl.middleware.enlighten/eval-with-enlighten
             enlighten.clj:   78  cider.nrepl.middleware.enlighten/eval-with-enlighten
                  Var.java:  384  clojure.lang.Var/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1990  clojure.core/with-bindings*
                  core.clj: 1990  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  218  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  217  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  833  java.lang.Thread/run

Drew Verlee16:10:13

This might be super obvious to someone who writes a lot of deftypes. I'm perplexed because this logic is currently working (or at least i believe it is!), so it has to do with the context in which i'm evaling it, or so i'm guessing.

hiredman16:10:52

it is an error in the internals of nrepl, not in your code

dpsutton16:10:10

yeah works in a plain clj repl

hiredman16:10:12

you can see the symbol it complains about is STATE__ which doesn't exist in your code

Drew Verlee16:10:13

yeah, that's what it looks like to me to. huh.

hiredman16:10:46

but does exist and is used for something connected to the debugger in cider-nrepl https://github.com/clojure-emacs/cider-nrepl/search?q=STATE__

Ben Sless16:10:53

Did you try to debug it in cider

Ben Sless17:10:12

That looks like an error you'd get if you try to debug a deftype

dpsutton17:10:14

"Let-wrap `body` with STATE__ map containing code, file, line, column etc.
  STATE__ is an anaphoric variable available to all breakpoint macros. Ends with
  __ to avid conflicts with user locals and to signify that it's an internal
  variable which is cleaned in `sanitize-env' along other clojure's
  temporaries."

Drew Verlee17:10:27

Ah, it's because i have "cider enlighten mode" on. Well, cool, that's a cider feature i really like and i'm hoping to contribute towards at some point, so hopefully ill be able to improve the experience here a bit. ty @U0NCTKEV8 @UK0810AQ2 and @U11BV7MTK i really do appreciate the input!

Drew Verlee17:10:29

i'm not even seeing the stacktrace i pasted in either. I'll try it in a vanilla doom emacs install at somepoint to see if it's something i did to myself. (i did click "all" to, it doesn't do anything)

dpsutton17:10:42

And just by the by, is putting a queue on itself what you intended?

Drew Verlee17:10:01

i'm trying to learn why our logging isn't doing what i expect and ... logging. putting a que on a que doesn't seem right so maybe that's something to look into. 👍

Dallas Surewood22:10:16

Edit: Nevermind. I got it with triple quotes around the version @seancorfield Is there a reason a fresh install of clj-new would have an invalid tag error? Running clojure -Ttools install com.github.seancorfield/clj-new '{:git/tag "v1.2.399"}' :as clj-new in powershell

seancorfield00:10:48

You're on Windows? See https://clojure.org/reference/deps_and_cli#quoting (I know you figured it out but this leaves a trail for others who hit this issue)

Dallas Surewood23:10:42

How many people here are using Kit framework, and how are they liking it?

seancorfield00:10:39

It's pretty new so I doubt it has many users yet... There's a #kit-clj channel for it (haven't looked in there to see how active it is).