aleph

Eugen 2022-06-12T20:45:24.881489Z

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

jcf 2022-06-12T20:47:57.673309Z

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))

jcf 2022-06-12T20:48:50.467439Z

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.

Eugen 2022-06-12T20:55:46.316969Z

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

Eugen 2022-06-12T20:56:51.772789Z

(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

Eugen 2022-06-12T21:36:33.406479Z

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

jcf 2022-06-12T21:37:12.236899Z

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

Eugen 2022-06-13T09:07:51.264859Z

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

Eugen 2022-06-13T09:07:59.495579Z

thanks for the help 🙂

👍 1
Matthew Davidson 2022-06-14T07:01:22.415889Z

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

👍 1
Eugen 2022-06-14T07:06:17.290249Z

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