Add logging to frontend repo namespace

This commit is contained in:
Andrey Antukh 2025-09-25 09:57:56 +02:00
parent 0295f0f7c8
commit c70e7f3876

View File

@ -8,6 +8,8 @@
(:require
[app.common.data :as d]
[app.common.exceptions :as ex]
[app.common.logging :as log]
[app.common.time :as ct]
[app.common.transit :as t]
[app.common.uri :as u]
[app.config :as cf]
@ -17,6 +19,8 @@
[beicon.v2.core :as rx]
[cuerdas.core :as str]))
(log/set-level! :info)
(defn handle-response
[{:keys [status body headers uri] :as response}]
(cond
@ -126,13 +130,21 @@
(select-keys params query-params)
nil))
:response-type
(if stream? nil response-type)}]
(if stream? nil response-type)}
tpoint
(ct/tpoint-ms)]
(log/trc :hint "make request" :id id)
(->> (http/fetch request)
(rx/map http/response->map)
(rx/mapcat (fn [{:keys [headers body] :as response}]
(log/trc :hint "response received" :id id :elapsed (tpoint))
(let [ctype (get headers "content-type")
response-stream? (str/starts-with? ctype "text/event-stream")]
response-stream? (str/starts-with? ctype "text/event-stream")
tpoint (ct/tpoint-ms)]
(when (and response-stream? (not stream?))
(ex/raise :type :internal
@ -148,6 +160,8 @@
(->> response
(http/process-response-type response-type)
(rx/map decode-fn)
(rx/tap (fn [_]
(log/trc :hint "response decoded" :id id :elapsed (tpoint))))
(rx/mapcat handle-response)))))))))
(defmulti cmd! (fn [id _] id))