Fork me on GitHub
#clojure
<
2020-06-13
>
kwladyka15:06:11

...
(:require [org.httpkit.client :as http])
...

@(http/request
     {:timeout 1000
      :url ""})
at java.base/sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:102) Received fatal alert: handshake_failure but
curl 
not found⏎
just work I was waiting about 30 minutes, restarted the REPL etc. Why Java things SSL handshake failed? edit: ok it looks like http-kit specific issue. stable and alpha version. The URL works with clj-http

wombawomba15:06:39

Is there an easier way to copy a directory than https://github.com/Raynes/fs/blob/master/src/me/raynes/fs.clj#L510-L532? Seems like such a hassle..

Phil Jackson20:06:23

Sup, all. I'd like to generate a spec for an empty map, is that possible in a simple way, or do I need to do #(= % {}) ?

Phil Jackson20:06:11

Actually, (s/and map? empty?) probably makes more sense as I get an easy generator?

seancorfield20:06:23

@phil638 #{{}} would also work, as a predicate and as a generator.

seancorfield20:06:59

user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/valid? #{{}} {:a 1})
false
user=> (s/valid? #{{}} {})
true
user=> (s/exercise #{{}})
([{} {}] [{} {}] [{} {}] [{} {}] [{} {}] [{} {}] [{} {}] [{} {}] [{} {}] [{} {}])
user=>

Daniel Bastos22:06:56

hey, has anyone implemented or tried property based testing with test.check for concurrent systems? Haven't found much content on this topic in Clojure...

kwladyka22:06:55

Old and boring topic, but comes to my mind once again… What do you use for logging? timbre / tools.logging / … ? With java.util.logging / … ? In most cases I use timbre with Clojure, but world is changing and I am curious if maybe worth to switch to tools.logging today?

seancorfield22:06:34

There was a discussion about logging in #observability just the other day @kwladyka

kwladyka22:06:39

Thank you. I will read this in bed 🙂

seancorfield22:06:51

As a TL;DR for folks who don't want to go digging there, we went back and forth over the years and ended up (back) on clojure.tools.logging and switching to log4j2 for the implementation and we've been very happy with that (and that was after switching from c.t.l to Timbre for a while)

seancorfield17:06:17

@kwladyka Because log4j2 is more modern so it has learned its lessons from all of the other libraries. slf4j treats FATAL and ERROR the same which annoys me. And just adding a single logging dependency is not enough when you have any complex app because you can guarantee you'll be bringing in multiple logging solutions from your dependencies so you're going to need all of the bridging dependencies too. And I like that we can configure log4j2 via properties files, instead of XML (it also supports YAML and JSON), and that we can control which config file it uses via environment variables and via JVM options.

👍 3
kwladyka19:06:17

Do you have link to simple example of project which use clojure.tools.logging with log4j2 where I can see appenders and configuration?

kwladyka19:06:47

I don’t have energy to learn more this week and figure out this

kwladyka19:06:12

Why you don’t have :jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2"] in project?

seancorfield19:06:24

(and, yeah, I spent days reading over the log4j2 stuff before deciding to make the switch at work -- there's a lot of info there)

kwladyka19:06:44

;; bridge into log4j:
                      org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.13.3"}
                      org.apache.logging.log4j/log4j-jcl {:mvn/version "2.13.3"}
                      org.apache.logging.log4j/log4j-jul {:mvn/version "2.13.3"}
                      org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.13.3"}
How to figure out when I need this?

kwladyka19:06:59

Any clever command to run or soemthing?

seancorfield19:06:12

This project does not use clojure.tools.logging -- it's using log4j2 to control all the logging that the various JDBC drivers bring in.

kwladyka19:06:50

Why not clojure.tools.logging?

seancorfield19:06:27

The different JDBC drivers all use different logging libraries -- the bridges ensure that log4j2 ends up controlling all the logging.

seancorfield19:06:51

next.jdbc doesn't do any logging itself, so it doesn't need c.t.l

kwladyka19:06:08

I know, but when to use them? Should I add this dependencies always when start new project or under some conditions?

seancorfield19:06:31

The answer to questions like that is always "it depends".

kwladyka19:06:49

any hints how to decide?

seancorfield19:06:55

This has all been discussed in the thread in #observability

kwladyka19:06:33

I saw it, but I didn’t notice answer for my question

seancorfield19:06:49

Which specific question doesn't it answer?

kwladyka19:06:48

How to determine if and which dependencies should I add in the context of bridges to log4j2

seancorfield19:06:08

As I said, the answer is "it depends".

kwladyka19:06:22

but depends on what? 🙂

seancorfield19:06:24

If you decide to use clojure.tools.logging yourself, then you get to choose which logging implementation you want to use with it, and you may need the logging.factory option to override the default choice it makes based on what else is on your classpath.

seancorfield19:06:46

This is all about what is on your classpath in a specific project.

kwladyka19:06:02

let’s say I will use :jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2"]

kwladyka19:06:19

ok and how can I know what is there?

seancorfield19:06:42

clojure -Stree or clojure -Spath

kwladyka19:06:47

considering I use a lot of deps which use deps which use deps… any easy way to figure out when should I use bridge and which bridge?

seancorfield19:06:07

It's up to you.

seancorfield19:06:18

There is no "wrong" or "right" choice here.

kwladyka19:06:35

hmm I think I don’t understand this part of Java logging 😉

kwladyka19:06:00

Is it not like I want to bridge everything and remove or other loggers dependecies from project?

seancorfield19:06:19

Using clojure.tools.logging directly in your project is a choice. Using a specific logging implementation for c.t.l is a choice. Bridging other logging implementations into that implementation is a choice. Only you can make those decisions.

kwladyka19:06:30

Sorry if I have stupid questions, but why I could want to not bridge logging?

seancorfield19:06:46

Some people like to control all logging in their app -- including logging from all the dependencies they use -- via one centralized system. Some people only want to control their own logging, and leave all the other logging alone.

kwladyka19:06:06

oh ok I see

seancorfield19:06:18

Did you read the Lambda Island blog post about logging?

kwladyka19:06:59

yes, but it was very late and I was sleepy. I could not remember something.

seancorfield19:06:18

While developing next.jdbc, I had left all the JDBC drivers' logging alone for a long time. I "didn't care" what each driver did -- because I felt that's up to users of next.jdbc to control.

kwladyka19:06:59

but after all you decided to bridge everything to log4j2 right?

seancorfield19:06:27

But when I was writing the new multiple result set support, I needed more control over debugging and logging so that I could a) control the level of logging separately for each JDBC driver and b) make PostgreSQL's logging more detailed since that was the driver I was having problems with.

kwladyka19:06:56

Thank you. Your answers saved me at least 1 week of live :)

seancorfield20:06:15

So, even tho' next.jdbc doesn't use clojure.tools.logging at all, I decided to bridge all logging to log4j2 since I prefer its configuration approach, and then I could dial logging up or down for individual libraries in one centralized place. This only mattered while I was debugging multiple result sets: so I could focus logging on a single JDBC driver at a time.

kwladyka20:06:16

going 1 level deeper, if I plan to use tracer (https://cloud.google.com/trace) it is still good approach to use clojure.tools.logging with log4j2? I didn’t use tracers so far.

seancorfield20:06:23

The TL;DR is that this only matters if you care about a specific library's logging -- which I didn't... until recently... and still only for testing rather than anyone's general usage of next.jdbc.

seancorfield20:06:38

I have no idea about any of the GCP stuff.

kwladyka20:06:05

but considering any tracer?

seancorfield20:06:33

I have no idea. I don't use tracers.

kwladyka20:06:42

ok, thank you

seancorfield20:06:47

These are your decisions to make, not mine.

kwladyka20:06:50

it was really helpful!

kwladyka20:06:21

sure, just your hints save weeks of my live to figure out what decisions I can make 🙂

seancorfield20:06:34

OK. Glad it was useful. As you can see from the thread in #observability different people have different preferences when it comes to logging libraries 🙂

kwladyka20:06:08

yes, your sounds similar to main

seancorfield20:06:14

I don't like slf4j -- primarily because it treats FATAL the same as ERROR and that's just wrong, in my opinion.

kwladyka20:06:22

I care about 100% of logs

kwladyka20:06:48

debugging without this can be nightmare

seancorfield20:06:57

(we used to use slf4j at work "by default" and the FATAL/ERROR thing was the main reason I switched away from it)

kwladyka20:06:05

and I can even not know about the issue because of this

kwladyka20:06:52

hmm I think I didn’t experience FATAL (app abort) so far

kwladyka20:06:14

the craziest issue which I had was websocket connection when call API and prase XML file. For some reasons it stack during parsing and froze whole APP forever. No exceptions, totally nothing. I took me so long time to figure out. I solved this by adding params to timeout for sockets when running app in jvm.

seancorfield20:06:35

It (FATAL) is just a logging level -- but we wanted it separate from ERROR in testing because we deliberately do some things that we want to suppress logging of in some tests (that would otherwise log ERROR level stuff) but we still want to see FATAL level stuff -- and you can't do that with slf4j.

kwladyka20:06:44

once again thank you for your hints today and for hints in the past ❤️

kwladyka20:06:29

however heart looks strange here haha 😉

kwladyka20:06:45

🍻

🍺 3
❤️ 3