From a63f28a2e50af78314359f6c1d48b715eb11b0f7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 22 Feb 2021 12:39:55 +0100 Subject: [PATCH] :sparkles: Normalize logging messages on backend. --- backend/src/app/cli/fixtures.clj | 2 +- backend/src/app/http/awsns.clj | 10 +++++----- backend/src/app/http/errors.clj | 4 ++-- backend/src/app/loggers/loki.clj | 8 ++++---- backend/src/app/loggers/mattermost.clj | 10 +++++----- backend/src/app/loggers/zmq.clj | 2 +- backend/src/app/main.clj | 2 +- backend/src/app/notifications.clj | 2 +- backend/src/app/rpc.clj | 4 ++-- backend/src/app/rpc/mutations/ldap.clj | 2 +- backend/src/app/rpc/mutations/profile.clj | 1 - backend/src/app/tasks/delete_object.clj | 2 +- backend/src/app/tasks/delete_profile.clj | 2 +- backend/src/app/tasks/file_media_gc.clj | 2 +- backend/src/app/telemetry.clj | 4 ++-- backend/src/app/worker.clj | 22 +++++++++++----------- 16 files changed, 39 insertions(+), 40 deletions(-) diff --git a/backend/src/app/cli/fixtures.clj b/backend/src/app/cli/fixtures.clj index 4400654c6..ed986d36d 100644 --- a/backend/src/app/cli/fixtures.clj +++ b/backend/src/app/cli/fixtures.clj @@ -237,6 +237,6 @@ (try (run-in-system system preset) (catch Exception e - (log/errorf e "Unhandled exception.")) + (log/errorf e "unhandled exception")) (finally (ig/halt! system))))) diff --git a/backend/src/app/http/awsns.clj b/backend/src/app/http/awsns.clj index 9443b90eb..8a776477d 100644 --- a/backend/src/app/http/awsns.clj +++ b/backend/src/app/http/awsns.clj @@ -42,7 +42,7 @@ (= mtype "SubscriptionConfirmation") (let [surl (get body "SubscribeURL") stopic (get body "TopicArn")] - (log/infof "Subscription received (topic=%s, url=%s)" stopic surl) + (log/infof "subscription received (topic=%s, url=%s)" stopic surl) (http/send! {:uri surl :method :post :timeout 10000})) (= mtype "Notification") @@ -52,7 +52,7 @@ (process-report cfg notification))) :else - (log/warn (str "Unexpected data received.\n" + (log/warn (str "unexpected data received\n" (pprint-report body)))) {:status 200 :body ""}))) @@ -184,14 +184,14 @@ (defn- process-report [cfg {:keys [type profile-id] :as report}] - (log/debug (str "Procesing report:\n" (pprint-report report))) + (log/debug (str "procesing report:\n" (pprint-report report))) (cond ;; In this case we receive a bounce/complaint notification without ;; confirmed identity, we just emit a warning but do nothing about ;; it because this is not a normal case. All notifications should ;; come with profile identity. (nil? profile-id) - (log/warn (str "A notification without identity recevied from AWS\n" + (log/warn (str "a notification without identity recevied from AWS\n" (pprint-report report))) (= "bounce" type) @@ -201,7 +201,7 @@ (register-complaint-for-profile cfg report) :else - (log/warn (str "Unrecognized report received from AWS\n" + (log/warn (str "unrecognized report received from AWS\n" (pprint-report report))))) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index 020ebc921..72fa34a65 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -73,7 +73,7 @@ (let [edata (ex-data error) cdata (get-error-context request error)] (update-thread-context! cdata) - (log/errorf error "Internal error: assertion (id: %s)" (str (:id cdata))) + (log/errorf error "internal error: assertion (id: %s)" (str (:id cdata))) {:status 500 :body {:type :server-error :data (-> edata @@ -88,7 +88,7 @@ [error request] (let [cdata (get-error-context request error)] (update-thread-context! cdata) - (log/errorf error "Internal error: %s (id: %s)" + (log/errorf error "internal error: %s (id: %s)" (ex-message error) (str (:id cdata))) {:status 500 diff --git a/backend/src/app/loggers/loki.clj b/backend/src/app/loggers/loki.clj index 32813e5ec..2514d5725 100644 --- a/backend/src/app/loggers/loki.clj +++ b/backend/src/app/loggers/loki.clj @@ -33,13 +33,13 @@ (defmethod ig/init-key ::reporter [_ {:keys [receiver uri] :as cfg}] (when uri - (log/info "Intializing loki reporter.") + (log/info "intializing loki reporter") (let [output (a/chan (a/sliding-buffer 1024))] (receiver :sub output) (a/go-loop [] (let [msg (a/ system-config (ig/prep) (ig/init)))) - (log/infof "Welcome to penpot! Version: '%s'." + (log/infof "welcome to penpot (version: '%s')" (:full cfg/version)))) (defn stop diff --git a/backend/src/app/notifications.clj b/backend/src/app/notifications.clj index 4ff66aac8..4b9a72ce1 100644 --- a/backend/src/app/notifications.clj +++ b/backend/src/app/notifications.clj @@ -188,7 +188,7 @@ (aa/> (db/query conn :file-media-object {:file-id id}) (remove #(contains? used (:id %))))] - (log/infof "processing file: id='%s' age='%s' to-delete=%s" id age (count unused)) + (log/debugf "processing file: id='%s' age='%s' to-delete=%s" id age (count unused)) ;; Mark file as trimmed (db/update! conn :file diff --git a/backend/src/app/telemetry.clj b/backend/src/app/telemetry.clj index a8e5edae7..a5268ef23 100644 --- a/backend/src/app/telemetry.clj +++ b/backend/src/app/telemetry.clj @@ -88,7 +88,7 @@ (catch Exception e ;; We don't want notify user of a error, just log it for posible ;; future investigation. - (log/warn e (str "Unexpected error on telemetry:\n" + (log/warn e (str "unexpected error on telemetry:\n" (when-let [edata (ex-data e)] (str "ex-data: \n" (with-out-str (pprint edata)))) @@ -118,4 +118,4 @@ data data]))) (catch Exception e - (log/errorf e "Error on procesing request.")))) + (log/errorf e "error on procesing request")))) diff --git a/backend/src/app/worker.clj b/backend/src/app/worker.clj index 306604b81..9b7cdc478 100644 --- a/backend/src/app/worker.clj +++ b/backend/src/app/worker.clj @@ -94,7 +94,7 @@ (defmethod ig/init-key ::worker [_ {:keys [pool poll-interval name queue] :as cfg}] - (log/infof "Starting worker '%s' on queue '%s'." name queue) + (log/infof "starting worker '%s' on queue '%s'" name queue) (let [cch (a/chan 1) poll-ms (inst-ms poll-interval)] (a/go-loop [] @@ -103,30 +103,30 @@ ;; Terminate the loop if close channel is closed or ;; event-loop-fn returns nil. (or (= port cch) (nil? val)) - (log/infof "Stop condition found. Shutdown worker: '%s'" name) + (log/infof "stop condition found; shutdown worker: '%s'" name) (db/pool-closed? pool) (do - (log/info "Worker eventloop is aborted because pool is closed.") + (log/info "worker eventloop is aborted because pool is closed") (a/close! cch)) (and (instance? java.sql.SQLException val) (contains? #{"08003" "08006" "08001" "08004"} (.getSQLState ^java.sql.SQLException val))) (do - (log/error "Connection error, trying resume in some instants.") + (log/error "connection error, trying resume in some instants") (a/= (:retry-num item) (:max-retries item)) {:status :failed :task item :error error} {:status :retry :task item :error error}))))) @@ -235,12 +235,12 @@ (defn- run-task [{:keys [tasks]} item] (try - (log/debugf "Started task '%s/%s/%s'." (:name item) (:id item) (:retry-num item)) + (log/debugf "started task '%s/%s/%s'" (:name item) (:id item) (:retry-num item)) (handle-task tasks item) (catch Exception e (handle-exception e item)) (finally - (log/debugf "Finished task '%s/%s/%s'." (:name item) (:id item) (:retry-num item))))) + (log/debugf "finished task '%s/%s/%s'" (:name item) (:id item) (:retry-num item))))) (def sql:select-next-tasks "select * from task as t @@ -330,7 +330,7 @@ (defn- synchronize-schedule-item [conn {:keys [id cron]}] (let [cron (str cron)] - (log/debugf "initialize scheduled task '%s' (cron: '%s')." id cron) + (log/infof "initialize scheduled task '%s' (cron: '%s')" id cron) (db/exec-one! conn [sql:upsert-scheduled-task id cron cron]))) (defn- synchronize-schedule