Makes logging unified

This commit is contained in:
2023-10-30 12:35:18 -07:00
parent f0a7c378f7
commit 930b900849
44 changed files with 485 additions and 555 deletions

View File

@@ -4,12 +4,11 @@
[auto-ap.datomic.clients :as d-clients]
[auto-ap.graphql :as ql]
[auto-ap.graphql.utils :refer [limited-clients]]
[auto-ap.logging :refer [warn-event]]
[auto-ap.logging :as alog]
[auto-ap.routes.utils :refer [wrap-secure]]
[buddy.auth :refer [throw-unauthorized]]
[clojure.edn :as edn]
[clojure.set :as set]
[clojure.tools.logging :as log]
[datomic.api :as dc]))
@@ -30,21 +29,21 @@
clients) ))
:headers {"Content-Type" "application/edn"}})
(catch Throwable e
(log/info "here we are " (.getCause e))
(if-let [result (:result (ex-data e))]
(do (log/warn "Graphql Result error" e)
(do (alog/warn ::result-error :error e)
{:status 400
:body (pr-str result)
:headers {"Content-Type" "application/edn"}})
(if-let [message (:validation-error (ex-data (.getCause e)) )]
(do
(warn-event "GraphQL Validation error" {:message message
:data e})
(alog/warn ::graphql-validation-error
:message message
:error e)
{:status 400
:body (pr-str {:errors [{:message message}]})
:headers {"Content-Type" "application/edn"}})
(do (log/error "GraphQL error" e)
(do (alog/error ::error :error e)
{:status 500
:body (pr-str {:errors [{:message (str "Unhandled error:" (str e))}]})
:headers {"Content-Type" "application/edn"}}))))))