Fork me on GitHub
#aleph
<
2022-06-12
>
Eugen20:06:24

any idea on how I can log the requests and responses I get via aleph client ? I can't seem to figure this out based on the docs. I've tried several combinations, including:

(netty/set-logger! :slf4j)

(def conn-pool (http/connection-pool {:connection-options {:log-activity :trace}
                                      :log-activity :trace}))
and using this like:

   req (merge {:method :get
                    :pool conn-pool
                    :url url} opts)
I can see my log messages but nothing from aleph http client p.s. I am willing to improve the docs for this

jcf20:06:57

One simple approach is to compose functions on to the deferred response. Something like this:

(manifold.deferred/chain (http/request req) (fn [response] (log/info :response response) response))

jcf20:06:50

I often convert my responses into a map of request and response in all cases to make testing and debugging easier using a similar approach.

Eugen20:06:46

thanks, but I might be doing something wrong, because it does not work for me

Eugen20:06:51

(try+
     (let [res (-> @(d/chain (http/request req)
                             (fn [response] (log/info "WHAAAA " :response response) response)))
           body (:body res)]
       (log/info "Writing statement to file" file)
       (bs/transfer body file))
I can see "Writing statement" line but nothing for the manifold chain

Eugen21:06:33

so it seems to work but I was looking for the logs in the wrong window

jcf21:06:12

I was about to ask about log configuration and tooling. Glad to hear you've found the output. 🙂

Eugen09:06:51

yeah, the experience is not great (being gentle). I'll see if I can improve it somehow (docs at least)

Eugen09:06:59

thanks for the help 🙂

👍 1
Matthew Davidson (kingmob)07:06:22

@U011NGC5FFY doc improvements are always welcome. Maybe it belongs in examples/?

👍 1
Eugen07:06:17

there was some logging in the repl output window and some (from timbre) in the calva output file. that was a bit confusing. I was checking only calva output file