Makes logging unified
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.graphql.utils
|
||||
:refer [->graphql
|
||||
@@ -29,7 +30,6 @@
|
||||
[clojure.java.io :as io]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[config.core :refer [env]]
|
||||
@@ -430,6 +430,7 @@
|
||||
nil)}))
|
||||
|
||||
(defn get-payment-page [context args _]
|
||||
(alog/info ::TEST)
|
||||
(let [[payments checks-count] (d-checks/get-graphql (-> args
|
||||
:filters
|
||||
(<-graphql)
|
||||
@@ -570,7 +571,7 @@
|
||||
:ids)
|
||||
specific-ids (d-checks/filter-ids (:ids args))
|
||||
all-ids (into (set ids) specific-ids)]
|
||||
(log/info "Voiding " (count all-ids) args)
|
||||
(alog/info ::voiding-payments :count (count all-ids))
|
||||
|
||||
(void-payments-internal all-ids (:id context))
|
||||
{:message (str "Succesfully voided " (count all-ids))}))
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
[clojure.java.io :as io]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[datomic.api :as dc]
|
||||
[iol-ion.tx :refer [random-tempid]]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]
|
||||
[auto-ap.solr :as solr])
|
||||
(:import
|
||||
@@ -151,7 +149,6 @@
|
||||
|
||||
_ (mu/log ::upserting :up updated-entity)
|
||||
_ (assert-no-shared-transaction-sources client-code [[:upsert-entity updated-entity]])
|
||||
_ (log/info "upserting client" updated-entity)
|
||||
|
||||
result (audit-transact [[:upsert-entity updated-entity]] (:id context))]
|
||||
(when (:square_auth_token edit_client)
|
||||
@@ -182,7 +179,7 @@
|
||||
|
||||
|
||||
(defn refresh-all-current-balance []
|
||||
(lc/with-context {:source "current-balance-refresh"}
|
||||
(mu/with-context {:source "current-balance-refresh"}
|
||||
(let [db (dc/db conn)
|
||||
clients (dc/q '[:find (pull ?c [:db/id :client/code {:client/bank-accounts [:db/id :bank-account/code]}])
|
||||
:where [?c :client/code]]
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.graphql.checks :as gq-checks]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.graphql.utils
|
||||
:as u
|
||||
:refer [<-graphql
|
||||
@@ -20,7 +21,6 @@
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[datomic.api :as dc]
|
||||
[auto-ap.solr :as solr]))
|
||||
@@ -293,10 +293,10 @@
|
||||
all-ids)
|
||||
(map first))
|
||||
]
|
||||
(log/info "Voiding " (count voidable-cash-payments) "cash payments first")
|
||||
(alog/info ::void-payments :count (count voidable-cash-payments))
|
||||
(gq-checks/void-payments-internal voidable-cash-payments (:id context))
|
||||
|
||||
(log/info "Voiding " (count all-ids) args)
|
||||
(alog/info ::voiding-invoices :count (count all-ids))
|
||||
(audit-transact
|
||||
(->> all-ids
|
||||
(dc/q '[:find (pull ?i [:db/id :invoice/date {:invoice/expense-accounts [:db/id]}])
|
||||
@@ -452,7 +452,6 @@
|
||||
all-ids (all-ids-not-locked (get-ids-matching-filters args))
|
||||
invoices (pull-many (dc/db conn) '[:db/id :invoice/total] (vec all-ids))
|
||||
account-total (reduce + 0 (map (fn [x] (:percentage x)) (:accounts args)))]
|
||||
(log/info "client is" locations)
|
||||
(when
|
||||
(not (dollars= 1.0 account-total))
|
||||
(let [error (str "Account total (" account-total ") does not reach 100%")]
|
||||
@@ -467,7 +466,7 @@
|
||||
(:location a))))
|
||||
(let [err (str "Account " name " uses location " (:location a) ", but doesn't belong to the client.")]
|
||||
(throw (ex-info err {:validation-error err}) ))))
|
||||
(log/info "Bulk coding " (count all-ids) args)
|
||||
(alog/info ::bulk-code :count (count all-ids))
|
||||
(audit-transact-batch
|
||||
(map (fn [i]
|
||||
[:upsert-invoice {:db/id (:db/id i)
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as t]
|
||||
[clojure.data.csv :as csv]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[datomic.api :as dc]
|
||||
[iol-ion.tx :refer [random-tempid]])
|
||||
@@ -180,7 +179,7 @@
|
||||
(map (fn [client-id]
|
||||
[client-id (build-account-lookup client-id)]))
|
||||
(into {}))]
|
||||
(log/info "Running balance sheet with " args)
|
||||
(alog/info ::balance-sheet :params args)
|
||||
|
||||
(cond-> {:balance-sheet-accounts (mapcat
|
||||
#(roll-up-until (lookup-account %) (all-ledger-entries %) end-date )
|
||||
@@ -357,7 +356,7 @@
|
||||
(if (> (count all-ids) 1000)
|
||||
{:message (str "You can only delete 1000 ledger entries at a time.")}
|
||||
(do
|
||||
(log/info "Deleting " (count all-ids) args)
|
||||
(alog/info ::deleting :args args)
|
||||
(audit-transact-batch
|
||||
(map (fn [i]
|
||||
[:db/retractEntity i])
|
||||
@@ -547,8 +546,9 @@
|
||||
)
|
||||
(map first)
|
||||
(map (fn [je] [:db/retractEntity je])))]
|
||||
(log/info "manual ledger import has " (count success) " new rows")
|
||||
(log/info errors)
|
||||
(alog/info ::manual-import
|
||||
:errors (count errors)
|
||||
:sample (take 3 errors))
|
||||
|
||||
|
||||
(mu/trace ::retraction-tx
|
||||
@@ -558,7 +558,6 @@
|
||||
[:count (count ignore-retraction)]
|
||||
(when (seq ignore-retraction)
|
||||
(audit-transact-batch ignore-retraction (:id context))))
|
||||
#_(log/info (map :tx success))
|
||||
(let [invalidated
|
||||
(mu/trace ::success-tx
|
||||
[:count (count success)]
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
[iol-ion.query :refer [entid]]
|
||||
[clojure.walk :as walk]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[clojure.tools.logging :as log]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[clojure.set :as set]))
|
||||
[clojure.set :as set]
|
||||
[auto-ap.logging :as alog]))
|
||||
|
||||
|
||||
(defn snake->kebab [s]
|
||||
@@ -56,7 +56,7 @@
|
||||
|
||||
(defn assert-admin [id]
|
||||
(when-not (= "admin" (:user/role id))
|
||||
(log/warn "user " id " not an admin!")
|
||||
(alog/warn ::unauthorized :user id :role "admin")
|
||||
(throw-unauthorized)))
|
||||
|
||||
(defn assert-present
|
||||
@@ -74,19 +74,19 @@
|
||||
|
||||
(defn assert-power-user [id]
|
||||
(when-not (#{"power-user" "admin"} (:user/role id))
|
||||
(log/warn "user " id " not an power-user!")
|
||||
(alog/warn ::unauthorized :user id :role "power-user")
|
||||
(throw-unauthorized)))
|
||||
|
||||
(defn can-see-client? [identity client]
|
||||
(when (not client)
|
||||
(log/warn "WARNING - permission checking for null client"))
|
||||
(alog/error ::checking-for-null-client :id identity))
|
||||
(or (= "admin" (:user/role identity))
|
||||
((set (map :db/id (:user/clients identity))) (:db/id client))
|
||||
((set (map :db/id (:user/clients identity))) client)))
|
||||
|
||||
(defn assert-can-see-client [identity client]
|
||||
(when-not (can-see-client? identity client)
|
||||
(log/warn "IDENTITY " identity " can not see company " client)
|
||||
(alog/warn ::unauthorized :id identity :client client)
|
||||
(throw-unauthorized)))
|
||||
|
||||
(defn limited-clients [id]
|
||||
@@ -149,10 +149,12 @@
|
||||
|
||||
(defn trace-query [key f]
|
||||
(fn trace [a b c]
|
||||
(mu/with-context {:query key
|
||||
:mutation (boolean (= "mutation"
|
||||
(namespace key)))
|
||||
:user (:id a)}
|
||||
(mu/with-context (merge
|
||||
(:log-context a {})
|
||||
{:query key
|
||||
:mutation (boolean (= "mutation"
|
||||
(namespace key)))
|
||||
:user (:id a)})
|
||||
(mu/trace (keyword "graphql" (name key))
|
||||
[]
|
||||
(f a b c)))))
|
||||
|
||||
Reference in New Issue
Block a user