Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Audit log statements (#78841)

Alexander Polyankine312b487577d
diff --git a/enterprise/backend/src/metabase_enterprise/action_v2/actions.clj b/enterprise/backend/src/metabase_enterprise/action_v2/actions.clj
index 4c882797d14..04dbc1ff8a3 100644
--- a/enterprise/backend/src/metabase_enterprise/action_v2/actions.clj
+++ b/enterprise/backend/src/metabase_enterprise/action_v2/actions.clj
@@ -8,7 +8,6 @@
[metabase.driver.util :as driver.u]
[metabase.util :as u]
[metabase.util.i18n :refer [tru]]
- [metabase.util.log :as log]
[metabase.util.malli :as mu]
[methodical.core :as methodical])
(:import
@@ -90,8 +89,7 @@
input+row (map vector inputs coerced)]
input+row)]
(for [input inputs]
- (u/prog1 (assoc input :row (input->coerced input))
- (log/tracef "coerce row %s => %s" (:row input) (:row <>))))))
+ (assoc input :row (input->coerced input)))))
(defn- perform-data-grid-action! [action-kw context inputs]
(let [next-inputs (coerce-inputs inputs)]
diff --git a/enterprise/backend/src/metabase_enterprise/advanced_config/file/api_keys.clj b/enterprise/backend/src/metabase_enterprise/advanced_config/file/api_keys.clj
index f8f5a86175c..5ef394e445f 100644
--- a/enterprise/backend/src/metabase_enterprise/advanced_config/file/api_keys.clj
+++ b/enterprise/backend/src/metabase_enterprise/advanced_config/file/api_keys.clj
@@ -57,7 +57,7 @@
;; Check if there's an existing API key with the same name first
(if-let [existing-api-key (select-api-key name)]
(do
- (log/info (u/format-color :blue "API key with name %s already exists, skipping" (pr-str name)))
+ (log/info (u/format-color :blue "API key with ID %s already exists, skipping" (u/the-id existing-api-key)))
existing-api-key)
(let [group-id (case group
"admin" (u/the-id (perms/admin-group))
@@ -73,7 +73,7 @@
(when (t2/exists? :model/ApiKey :key_prefix prefix)
(throw (ex-info (format "API key with prefix '%s' already exists. Keys must have unique prefixes." prefix)
{:name name :prefix prefix})))
- (log/info (u/format-color :green "Creating new API key %s" (pr-str name)))
+ (log/info (u/format-color :green "Creating new API key"))
;; Create a user for the API key
(let [email (format "api-key-user-%[email protected]" (random-uuid))
user (first
diff --git a/enterprise/backend/src/metabase_enterprise/advanced_config/file/databases.clj b/enterprise/backend/src/metabase_enterprise/advanced_config/file/databases.clj
index e1960ec0560..f976b08c5af 100644
--- a/enterprise/backend/src/metabase_enterprise/advanced_config/file/databases.clj
+++ b/enterprise/backend/src/metabase_enterprise/advanced_config/file/databases.clj
@@ -31,7 +31,7 @@
(every? (fn [pattern]
(try
(boolean (re-pattern pattern))
- (catch Exception e (log/error e) false)))
+ (catch Exception e (log/error (ex-message e)) false)))
patterns))
(s/def :metabase-enterprise.advanced-config.file.databases.config-file-spec/settings
@@ -105,7 +105,7 @@
(throw (ex-info (format "To delete database %s set `delete` to %s" (pr-str (:name database)) (pr-str magic-request))
{:database-name (:name database)})))
(when-let [existing-database-id (t2/select-one-pk :model/Database :engine (:engine database), :name (:name database))]
- (log/info (u/format-color :blue "Deleting Database %s %s" (:engine database) (pr-str (:name database))))
+ (log/info (u/format-color :blue "Deleting Database %s with ID %s" (:engine database) existing-database-id))
(t2/delete! :model/Database existing-database-id)))
(:is_sample database)
@@ -122,14 +122,14 @@
;; A stub entry is just a placeholder to satisfy serdes references. If a real database
;; with this name+engine already exists, leave it alone — overwriting it with `:details {}`
;; and `:is_stub true` would break a working database.
- (log/info (u/format-color :yellow "Database %s %s already exists; ignoring stub entry"
- (:engine database) (pr-str (:name database))))
+ (log/info (u/format-color :yellow "Database %s with ID %s already exists; ignoring stub entry"
+ (:engine database) existing-database-id))
(let [database (cond-> database
(:is_attached_dwh database) strip-attached-dwh-update-ks)]
- (log/info (u/format-color :blue "Updating Database %s %s" (:engine database) (pr-str (:name database))))
+ (log/info (u/format-color :blue "Updating Database %s with ID %s" (:engine database) existing-database-id))
(t2/update! :model/Database existing-database-id (normalize-settings database))))
(do
- (log/info (u/format-color :green "Creating new %s Database %s" (:engine database) (pr-str (:name database))))
+ (log/info (u/format-color :green "Creating new %s Database" (:engine database)))
(let [db (first (t2/insert-returning-instances! :model/Database (normalize-settings database)))]
(cond
(:is_stub database)
diff --git a/enterprise/backend/src/metabase_enterprise/advanced_config/file/users.clj b/enterprise/backend/src/metabase_enterprise/advanced_config/file/users.clj
index b64dd23a92d..60170de64dc 100644
--- a/enterprise/backend/src/metabase_enterprise/advanced_config/file/users.clj
+++ b/enterprise/backend/src/metabase_enterprise/advanced_config/file/users.clj
@@ -39,7 +39,7 @@
[user]
(if-let [existing-user (select-user (:email user))]
(do
- (log/info (u/format-color :blue "Updating User with email %s" (pr-str (:email user))))
+ (log/info (u/format-color :blue "Updating User %d" (:id existing-user)))
(let [new-user (update user :login_attributes
#(merge % (:login_attributes existing-user)))]
(t2/update! :model/User (:id existing-user) new-user)))
@@ -47,10 +47,7 @@
(let [user (cond-> user
(not (setup/has-user-setup)) (assoc :is_superuser true))]
(log/info (u/colorize :green "Creating the first User for this instance. The first user is always created as an admin."))
- (log/info (u/format-color :green
- "Creating new User %s with email %s"
- (pr-str (str (:first_name user) \space (:last_name user)))
- (pr-str (:email user))))
+ (log/info (u/colorize :green "Creating new User"))
(t2/insert! :model/User user))))
(defmethod advanced-config.file.i/initialize-section! :users
diff --git a/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj b/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj
index c73e1fd651a..69a94675584 100644
--- a/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj
+++ b/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj
@@ -174,7 +174,7 @@
(let [report (serdes/with-cache (serialization/load-metabase! (serialization/ingest-yaml temp-dir) {}))]
(log/info "Import complete:" (count (:seen report)) "entities loaded")
(when (seq (:errors report))
- (log/warn "Import had errors:" (:errors report)))
+ (log/warn "Import had errors:" (mapv ex-message (:errors report))))
report)
(finally
(when (.exists (io/file temp-dir))
@@ -201,7 +201,7 @@
(serialization/file-writer (.getPath temp-path))))]
(log/info "Export complete:" (reduce + 0 (vals (:entity-counts report))) "entities exported")
(when (seq (:errors report))
- (log/warn "Export had errors:" (:errors report)))
+ (log/warn "Export had errors:" (mapv ex-message (:errors report))))
{:report report
:export-dir (.getPath temp-path)})
(catch Exception e
@@ -306,12 +306,12 @@
(log/info "Analytics dev environment already set up, skipping initialization")
(when-let [admin-user (first-admin-user)]
(cleanup-real-analytics)
- (log/info "Setting up analytics dev environment with user:" (:email admin-user))
+ (log/info "Setting up analytics dev environment with user:" (:id admin-user))
(create-analytics-dev-database! (:id admin-user))
(import-analytics-content! (:email admin-user))
(log/info "Analytics dev environment ready")))
(catch Exception e
- (log/error e "Failed to set up analytics dev environment"))))))
+ (log/errorf "Failed to set up analytics dev environment: %s" (ex-message e)))))))
(defmethod startup/def-startup-logic! ::analytics-dev-mode-setup
[_] (analytics-dev-mode-setup))
diff --git a/enterprise/backend/src/metabase_enterprise/audit_app/api/analytics_dev.clj b/enterprise/backend/src/metabase_enterprise/audit_app/api/analytics_dev.clj
index 03a69efbff3..fd3c293eba2 100644
--- a/enterprise/backend/src/metabase_enterprise/audit_app/api/analytics_dev.clj
+++ b/enterprise/backend/src/metabase_enterprise/audit_app/api/analytics_dev.clj
@@ -46,7 +46,7 @@
{:archive (when (.exists dst) dst)
:cleanup! cleanup!}
(catch Exception e
- (log/error e "Error during analytics export")
+ (log/errorf "Error during analytics export: %s" (ex-message e))
(try (cleanup!) (catch Error _))
{:error-message (.getMessage e)})))))
diff --git a/enterprise/backend/src/metabase_enterprise/audit_app/audit.clj b/enterprise/backend/src/metabase_enterprise/audit_app/audit.clj
index f33602a116c..5aaaf7a0308 100644
--- a/enterprise/backend/src/metabase_enterprise/audit_app/audit.clj
+++ b/enterprise/backend/src/metabase_enterprise/audit_app/audit.clj
@@ -366,7 +366,7 @@
(audit-app.settings/audit-db-dialect-sync-pending! false)
(log/info "Audit DB sync complete.")
(catch Exception e
- (log/error e "Audit DB sync failed."))))))
+ (log/errorf "Audit DB sync failed: %s" (ex-message e)))))))
(defn- host-canonical-table
"The `[name schema]` an audit-DB `metabase_table` row should use for the host engine, matching the
diff --git a/enterprise/backend/src/metabase_enterprise/cloud_add_ons/api.clj b/enterprise/backend/src/metabase_enterprise/cloud_add_ons/api.clj
index 898679c604f..64789345cba 100644
--- a/enterprise/backend/src/metabase_enterprise/cloud_add_ons/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/cloud_add_ons/api.clj
@@ -131,7 +131,7 @@
(try
{:status 200 :body (make-public-store-request! "/plan")}
(catch Exception e
- (log/warn e "Error fetching plans information")
+ (log/warnf "Error fetching plans information: %s" (ex-message e))
(handle-store-api-error e)))))
;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to
@@ -150,7 +150,7 @@
(try
{:status 200 :body (make-public-store-request! "/addons")}
(catch Exception e
- (log/warn e "Error fetching addons information")
+ (log/warnf "Error fetching addons information: %s" (ex-message e))
(handle-store-api-error e)))))
;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to
@@ -209,7 +209,7 @@
(premium-features/clear-cache!)
response-success-empty
(catch Exception e
- (log/warnf e "Error purchasing add-on '%s'" product-type)
+ (log/warnf "Error purchasing add-on '%s': %s" product-type (ex-message e))
(handle-store-api-error e {400 error-cannot-purchase})))))
(api.macros/defendpoint :delete "/:product-type" :- [:map
@@ -232,7 +232,7 @@
(premium-features/clear-cache!)
response-success-empty
(catch Exception e
- (log/warnf e "Error removing add-on '%s'" product-type)
+ (log/warnf "Error removing add-on '%s': %s" product-type (ex-message e))
(handle-store-api-error e {400 error-cannot-remove})))))
(def ^{:arglists '([request respond raise])} routes
diff --git a/enterprise/backend/src/metabase_enterprise/data_apps/sync.clj b/enterprise/backend/src/metabase_enterprise/data_apps/sync.clj
index af5897142ab..2a77ff383bb 100644
--- a/enterprise/backend/src/metabase_enterprise/data_apps/sync.clj
+++ b/enterprise/backend/src/metabase_enterprise/data_apps/sync.clj
@@ -143,7 +143,7 @@
:allowed_hosts allowed_hosts
:bundle_path bundle
:sync_error (ex-message e)})
- (log/warnf e "[data-app] failed to sync app %s" slug)
+ (log/warnf "[data-app] failed to sync app %s: %s" slug (ex-message e))
;; a failing app counts as a change unless it was already failing identically
(or (nil? existing) (not= (:sync_error existing) (ex-message e))))))
@@ -215,5 +215,5 @@
(count config-errors) (str/join "; " config-errors)))
result)
(catch Throwable e
- (log/warn e "[data-app] sync from remote-sync snapshot failed")
+ (log/warnf "[data-app] sync from remote-sync snapshot failed: %s" (ex-message e))
nil)))
diff --git a/enterprise/backend/src/metabase_enterprise/data_complexity_score/complexity.clj b/enterprise/backend/src/metabase_enterprise/data_complexity_score/complexity.clj
index 2a3d93de037..62f05ad0300 100644
--- a/enterprise/backend/src/metabase_enterprise/data_complexity_score/complexity.clj
+++ b/enterprise/backend/src/metabase_enterprise/data_complexity_score/complexity.clj
@@ -392,7 +392,7 @@
pairs (synonym-pair-count known-vectors synonym-similarity-threshold)]
(component-score :synonym-pair pairs))
(catch Throwable t
- (log/warn t "Complexity score: synonym detection failed; cascading nil through aggregates")
+ (log/warnf "Complexity score: synonym detection failed; cascading nil through aggregates: %s" (ex-message t))
(let [msg (some-> (.getMessage t) str/trim)
err (if (str/blank? msg)
(or (some-> (class t) .getName) "synonym detection failed")
@@ -528,7 +528,7 @@
{::snowplow-published? (boolean (try
(emit-snowplow! score)
(catch Throwable t
- (log/warn t "Failed to re-publish cached complexity score to Snowplow"))))}))
+ (log/warnf "Failed to re-publish cached complexity score to Snowplow: %s" (ex-message t)))))}))
(defn score-from-entities
"Pure: compute the full complexity score from pre-built entity vectors and an embedder. No DB
@@ -635,7 +635,7 @@
(try
(emit-snowplow! result)
(catch Throwable t
- (log/warn t "Failed to publish complexity score to Snowplow")))))))]
+ (log/warnf "Failed to publish complexity score to Snowplow: %s" (ex-message t))))))))]
(with-meta result {::snowplow-published? published?}))
(finally
(analytics.interface/observe! :metabase-data-complexity/scoring-duration-ms
diff --git a/enterprise/backend/src/metabase_enterprise/data_complexity_score/task/complexity_score.clj b/enterprise/backend/src/metabase_enterprise/data_complexity_score/task/complexity_score.clj
index 17c2338b977..ac00815a503 100644
--- a/enterprise/backend/src/metabase_enterprise/data_complexity_score/task/complexity_score.clj
+++ b/enterprise/backend/src/metabase_enterprise/data_complexity_score/task/complexity_score.clj
@@ -66,10 +66,10 @@
(data-complexity-score/record-score! claim-fingerprint "appdb" result)
(maybe-advance-last-fingerprint! claim-fingerprint result)
(catch Throwable t
- (log/warn t "Data Complexity Score: failed to persist score snapshot; leaving fingerprint unchanged so the next boot or cron retries")))
+ (log/warnf "Data Complexity Score: failed to persist score snapshot; leaving fingerprint unchanged so the next boot or cron retries: %s" (ex-message t))))
result)
(catch Throwable t
- (log/warn t "Data Complexity Score run failed")
+ (log/warnf "Data Complexity Score run failed: %s" (ex-message t))
nil))
(log/debug "Data Complexity Score run skipped — scoring-active? is false")))
@@ -184,7 +184,7 @@
(settings/data-complexity-scoring-claim! "")
(log/info "Data Complexity Score: skipping claim release — persisted claim no longer belongs to this node (sibling takeover after TTL)")))))
(catch Throwable t
- (log/warn t "Data Complexity Score: failed to clear scoring claim; it will expire via TTL"))))
+ (log/warnf "Data Complexity Score: failed to clear scoring claim; it will expire via TTL: %s" (ex-message t)))))
(defn- with-scoring-claim!
"Acquire a scoring claim, invoke `f` with the claim map, then release the claim via
@@ -246,7 +246,7 @@
(log/info "Data Complexity Score: fingerprint changed, emitting boot-time score")
(run-scoring! fingerprint)))
(catch Throwable t
- (log/warn t "Data Complexity Score: boot-time emission failed"))))
+ (log/warnf "Data Complexity Score: boot-time emission failed: %s" (ex-message t)))))
(defmethod task/init! ::DataComplexityScoring [_]
(let [job (jobs/build
diff --git a/enterprise/backend/src/metabase_enterprise/dependencies/core.clj b/enterprise/backend/src/metabase_enterprise/dependencies/core.clj
index 1eb03df7448..a5a98717f53 100644
--- a/enterprise/backend/src/metabase_enterprise/dependencies/core.clj
+++ b/enterprise/backend/src/metabase_enterprise/dependencies/core.clj
@@ -77,7 +77,7 @@
:let [bad-refs (try
(deps.analysis/check-entity provider entity-type id)
(catch Exception e
- (log/warnf e "Error checking %s %s" entity-type id)
+ (log/warnf "Error checking %s %s: %s" entity-type id (ex-message e))
#{(lib/validation-exception-error (ex-message e))}))]]
(when (seq bad-refs)
(vswap! errors assoc-in [entity-type id] bad-refs)))
diff --git a/enterprise/backend/src/metabase_enterprise/dependencies/events.clj b/enterprise/backend/src/metabase_enterprise/dependencies/events.clj
index 729a6e8352d..ad60e65e452 100644
--- a/enterprise/backend/src/metabase_enterprise/dependencies/events.clj
+++ b/enterprise/backend/src/metabase_enterprise/dependencies/events.clj
@@ -26,7 +26,7 @@
(deps.dependency-status/mark-stale! entity-type [entity-id])
(task.backfill/trigger-backfill-job!)
(catch Throwable e
- (log/error e "Failed to mark entity stale" {:entity-type entity-type :entity-id entity-id}))))
+ (log/error "Failed to mark entity stale" {:entity-type entity-type :entity-id entity-id :error (ex-message e)}))))
;; ### Cards
(derive ::card-deps :metabase/event)
diff --git a/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj b/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj
index 35ac2d09416..6de5f909caa 100644
--- a/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj
+++ b/enterprise/backend/src/metabase_enterprise/dependencies/findings.clj
@@ -61,7 +61,7 @@
(let [mp (lib-be/application-database-metadata-provider db-id)
results (try (deps.analysis/check-entity mp entity-type instance-id)
(catch Exception e
- (log/error e "Error analyzing entity")
+ (log/errorf "Error analyzing entity: %s" (ex-message e))
[(lib/validation-exception-error (.getMessage e))]))
success (empty? results)]
(deps.analysis-finding/upsert-analysis! entity-type instance-id success results))
@@ -78,8 +78,8 @@
(doseq [instance instances]
(try (upsert-analysis! instance)
(catch Exception e
- (log/errorf e "Analyzing entity %s %s failed"
- (t2/model instance) (:id instance))))))
+ (log/errorf "Analyzing entity %s %s failed: %s"
+ (t2/model instance) (:id instance) (ex-message e))))))
(def analyzable-entities
"Entities for which we can compute analysis findings."
@@ -169,6 +169,6 @@
(doseq [instance instances]
(try (upsert-analysis! instance)
(catch Exception e
- (log/errorf e "Analyzing entity %s %s failed"
- (t2/model instance) (:id instance))))))
+ (log/errorf "Analyzing entity %s %s failed: %s"
+ (t2/model instance) (:id instance) (ex-message e))))))
(count instances)))
diff --git a/enterprise/backend/src/metabase_enterprise/dependencies/task/backfill.clj b/enterprise/backend/src/metabase_enterprise/dependencies/task/backfill.clj
index 0818142cc07..5578e91005d 100644
--- a/enterprise/backend/src/metabase_enterprise/dependencies/task/backfill.clj
+++ b/enterprise/backend/src/metabase_enterprise/dependencies/task/backfill.clj
@@ -111,15 +111,15 @@
:entity_type entity-type
:entity_id id)]
(if terminal
- (log/errorf e "Entity %s %s failed %d times, marking as terminally broken."
- type-name id fail_count)
- (log/warnf e "Entity %s %s failed, failure count: %d."
- type-name id fail_count)))
+ (log/errorf "Entity %s %s failed %d times, marking as terminally broken: %s"
+ type-name id fail_count (ex-message e))
+ (log/warnf "Entity %s %s failed, failure count: %d. %s"
+ type-name id fail_count (ex-message e))))
(catch Exception record-ex
- (log/errorf e "Entity %s %s failed during dependency calculation."
- type-name id)
- (log/errorf record-ex "Additionally, failed to record the failure for %s %s."
- type-name id))))
+ (log/errorf "Entity %s %s failed during dependency calculation: %s"
+ type-name id (ex-message e))
+ (log/errorf "Additionally, failed to record the failure for %s %s: %s"
+ type-name id (ex-message record-ex)))))
0))))
0
instances)))
diff --git a/enterprise/backend/src/metabase_enterprise/entity_retrieval/core.clj b/enterprise/backend/src/metabase_enterprise/entity_retrieval/core.clj
index b82583967ba..de24b7ffa28 100644
--- a/enterprise/backend/src/metabase_enterprise/entity_retrieval/core.clj
+++ b/enterprise/backend/src/metabase_enterprise/entity_retrieval/core.clj
@@ -79,7 +79,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/debug e "The application database user cannot host the library retrieval schema")
+ (log/debugf "The application database user cannot host the library retrieval schema: %s" (ex-message e))
false))))
(defonce ^{:doc "Set once [[app-db-schema-usable?*]] has answered yes. Rebound by tests."}
@@ -170,7 +170,7 @@
{:status :missing}
;; DEBUG: entity-retrieval-available? probes per tool-offering request, so a pgvector outage would
;; WARN-flood the logs; the :unreachable status and the health check already carry the signal.
- (do (log/debug e "entity-retrieval index probe failed")
+ (do (log/debugf "entity-retrieval index probe failed: %s" (ex-message e))
{:status :unreachable, :error (ex-message e)})))))
(defn retrieval-status
@@ -299,8 +299,8 @@
diff (reconcile/reconcile-entity! ds embedding/get-configured-model entity-type entity-local-id)]
(record-run! "targeted" diff (elapsed-ms started)))
(catch Throwable e
- (log/error e "library entity index: targeted reconcile failed; re-queuing"
- entity-type entity-local-id)
+ (log/error "library entity index: targeted reconcile failed; re-queuing"
+ entity-type entity-local-id (ex-message e))
(locking run-lock (swap! dirty-entities conj entity-key)))))))
(defn reconcile-full-coalesced!
@@ -412,7 +412,7 @@
;; reports the search as unavailable rather than as an empty library.
(case (.getSQLState e)
"42P01" []
- "22000" (do (log/warn e "library entity index incompatible with the query vector; returning no results")
+ "22000" (do (log/warnf "library entity index incompatible with the query vector; returning no results: %s" (ex-message e))
[])
(do (analytics/inc! :metabase-entity-retrieval/search-failed)
(throw e)))))]
diff --git a/enterprise/backend/src/metabase_enterprise/entity_retrieval/reconcile.clj b/enterprise/backend/src/metabase_enterprise/entity_retrieval/reconcile.clj
index 651ed421d2c..54af8e03d50 100644
--- a/enterprise/backend/src/metabase_enterprise/entity_retrieval/reconcile.clj
+++ b/enterprise/backend/src/metabase_enterprise/entity_retrieval/reconcile.clj
@@ -354,8 +354,8 @@
(insert-batch! conn embedding-model batch)
(catch Exception e
(vswap! failed into (map entity-class batch))
- (log/error e "library entity index: failed to insert batch of"
- (count batch) "docs; will retry next run")
+ (log/error "library entity index: failed to insert batch of"
+ (count batch) "docs; will retry next run:" (ex-message e))
0)))))
0
to-insert)
@@ -391,8 +391,8 @@
inserted (try
(if (seq to-insert) (insert-batch! conn embedding-model to-insert) 0)
(catch Exception e
- (log/error e "library entity index: failed to reconcile entity"
- entity-type entity-local-id "; will retry next run")
+ (log/error "library entity index: failed to reconcile entity"
+ entity-type entity-local-id "; will retry next run:" (ex-message e))
::failed))
failed? (= ::failed inserted)
to-delete (if failed? [] orphans)]
diff --git a/enterprise/backend/src/metabase_enterprise/entity_retrieval/task/sync.clj b/enterprise/backend/src/metabase_enterprise/entity_retrieval/task/sync.clj
index 67b1d1fc1d4..3b401d86adc 100644
--- a/enterprise/backend/src/metabase_enterprise/entity_retrieval/task/sync.clj
+++ b/enterprise/backend/src/metabase_enterprise/entity_retrieval/task/sync.clj
@@ -32,7 +32,7 @@
(entity-retrieval.core/reconcile-full-coalesced!)
(catch Throwable e
;; Log and move on: the next periodic run retries from the authoritative appdb table.
- (log/error e "entity-retrieval mirror reconciliation failed")))))
+ (log/errorf "entity-retrieval mirror reconciliation failed: %s" (ex-message e))))))
(def ^:private ^Duration startup-delay (Duration/parse "PT10S"))
;; Slow: this is the backstop, not the freshness mechanism — the targeted write path keeps the index live.
diff --git a/enterprise/backend/src/metabase_enterprise/gsheets/api.clj b/enterprise/backend/src/metabase_enterprise/gsheets/api.clj
index 2071e9f6c70..2ceaed91806 100644
--- a/enterprise/backend/src/metabase_enterprise/gsheets/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/gsheets/api.clj
@@ -269,7 +269,7 @@
(try (hm-get-gdrive-conn conn-id)
(catch Exception e
(do
- (log/errorf e "Exception getting status of connection %s." conn-id)
+ (log/errorf "Exception getting status of connection %s: %s" conn-id (ex-message e))
(throw-error 502 cannot-check-message nil {:gdrive/conn-id conn-id
:hm/exception e})))))
[hm-status {hm-status-code :status hm-body :body hm-err-body :ex-data}] hm-response]
diff --git a/enterprise/backend/src/metabase_enterprise/harbormaster/client.clj b/enterprise/backend/src/metabase_enterprise/harbormaster/client.clj
index 7f0ef974cd5..1c8f6eddbff 100644
--- a/enterprise/backend/src/metabase_enterprise/harbormaster/client.clj
+++ b/enterprise/backend/src/metabase_enterprise/harbormaster/client.clj
@@ -69,15 +69,14 @@
(str store-api-url (+slash-prefix url))
request)
(catch Exception e
- (log/errorf e "Error making request to %s" url)
+ (log/errorf "Error making request to %s: %s" url (ex-message e))
{:ex-data (ex-data e)
:request request
:url url}))]
(log/info "Harbormaster API call:"
{:method (m.util/upper-case-en (last (str/split (-> request-method-fn class .getSimpleName) #"\$")))
:url url
- :request-body (:body request)
- :response (select-keys response [:status :body])})
+ :status (:status response)})
response))
(defn- decode-response [unparsed-response url request]
@@ -86,7 +85,7 @@
(try
(m/update-existing unparsed-response :body json/decode+kw)
(catch Exception e
- (log/errorf e "Error decoding response from %s, is it json?" url)
+ (log/errorf "Error decoding response from %s, is it json? %s" url (ex-message e))
{:ex-data (ex-data e)
:unparsed-response unparsed-response
:request request
@@ -96,7 +95,7 @@
(try
(get-safe-status response)
(catch Exception e
- (log/errorf e "Error decoding response from %s, is it json?" url)
+ (log/errorf "Error decoding response from %s, is it json? %s" url (ex-message e))
{:response response
:request request
:url url
@@ -184,7 +183,7 @@
(catch Exception e
(let [resp-body (some-> e ex-data :body maybe-decode m.util/deep-kebab-keys)
msg (format "Error on Harbormaster operation call %s" operation-id)]
- (log/error msg (or resp-body e))
+ (log/error msg (ex-message e))
(throw (ex-info msg (if (map? resp-body) resp-body {})))))))
(defn request
diff --git a/enterprise/backend/src/metabase_enterprise/impersonation/driver.clj b/enterprise/backend/src/metabase_enterprise/impersonation/driver.clj
index 47d69a4a48e..74c5869da50 100644
--- a/enterprise/backend/src/metabase_enterprise/impersonation/driver.clj
+++ b/enterprise/backend/src/metabase_enterprise/impersonation/driver.clj
@@ -142,5 +142,5 @@
;; in case impersonation used to be enabled and the connection still uses an impersonated role.
(driver/set-role! driver conn role)))
(catch Throwable e
- (log/debug e "Error setting role on connection")
+ (log/debugf "Error setting role on connection: %s" (ex-message e))
(throw e)))))
diff --git a/enterprise/backend/src/metabase_enterprise/mcp/usage.clj b/enterprise/backend/src/metabase_enterprise/mcp/usage.clj
index 2a2ff43726e..c4052206c82 100644
--- a/enterprise/backend/src/metabase_enterprise/mcp/usage.clj
+++ b/enterprise/backend/src/metabase_enterprise/mcp/usage.clj
@@ -69,7 +69,7 @@
:client_version (truncate (:version client-info) client-version-max-length)}
pii))))
(catch Throwable e
- (log/warn e "Failed to record MCP session"))))
+ (log/warnf "Failed to record MCP session: %s" (ex-message e)))))
(defenterprise record-mcp-session-end!
"EE: stamp `ended_at` on the session row at teardown. Best-effort; the row may be absent
@@ -80,7 +80,7 @@
(when session-id
(t2/update! :model/McpSessionLog :id session-id {:ended_at :%now}))
(catch Throwable e
- (log/warn e "Failed to record MCP session end"))))
+ (log/warnf "Failed to record MCP session end: %s" (ex-message e)))))
(defn- resolve-client-identity
"Client identity for a tool-call row, denormalized so `v_mcp_tool_calls` needs no session join.
@@ -132,4 +132,4 @@
(truncate error-message error-message-max-length))}
pii)))
(catch Throwable e
- (log/warn e "Failed to record MCP tool call"))))
+ (log/warnf "Failed to record MCP tool call: %s" (ex-message e)))))
diff --git a/enterprise/backend/src/metabase_enterprise/memoize_monitor/init.clj b/enterprise/backend/src/metabase_enterprise/memoize_monitor/init.clj
index a7845c925c2..f5a05305c93 100644
--- a/enterprise/backend/src/metabase_enterprise/memoize_monitor/init.clj
+++ b/enterprise/backend/src/metabase_enterprise/memoize_monitor/init.clj
@@ -63,7 +63,8 @@
{:cache (str (symbol cache-var))
:entries entries}))
(catch Exception e
- (log/warn e "Error measuring memoization cache size" {:cache (str (symbol cache-var))}))))
+ (log/warn "Error measuring memoization cache size" {:cache (str (symbol cache-var))
+ :error (ex-message e)}))))
(defn- all-cache-stats
[]
diff --git a/enterprise/backend/src/metabase_enterprise/metabot/usage.clj b/enterprise/backend/src/metabase_enterprise/metabot/usage.clj
index 843e34e8aee..ac7280dd486 100644
--- a/enterprise/backend/src/metabase_enterprise/metabot/usage.clj
+++ b/enterprise/backend/src/metabase_enterprise/metabot/usage.clj
@@ -78,7 +78,7 @@
:request_id request-id
:ai_proxied ai-proxied}))
(catch Exception e
- (log/warn e "Failed to log LLM usage to ai_usage_log")))))
+ (log/warnf "Failed to log LLM usage to ai_usage_log: %s" (ex-message e))))))
(defn- period-start
"Return the start of the current billing period as an Instant, based on the reset rate setting."
diff --git a/enterprise/backend/src/metabase_enterprise/metabot_analytics/queries.clj b/enterprise/backend/src/metabase_enterprise/metabot_analytics/queries.clj
index 5b3708bca76..3e89bd9082b 100644
--- a/enterprise/backend/src/metabase_enterprise/metabot_analytics/queries.clj
+++ b/enterprise/backend/src/metabase_enterprise/metabot_analytics/queries.clj
@@ -34,7 +34,7 @@
refs (sql-tools/referenced-tables-raw driver sql)]
(->> refs (map :table) (remove nil?) distinct vec))
(catch Throwable e
- (log/warn e "Failed to extract referenced tables from generated SQL")
+ (log/warnf "Failed to extract referenced tables from generated SQL: %s" (ex-message e))
[]))
[]))
diff --git a/enterprise/backend/src/metabase_enterprise/mfa/core.clj b/enterprise/backend/src/metabase_enterprise/mfa/core.clj
index ccd969183e3..0b0c317ba8f 100644
--- a/enterprise/backend/src/metabase_enterprise/mfa/core.clj
+++ b/enterprise/backend/src/metabase_enterprise/mfa/core.clj
@@ -63,7 +63,7 @@
(try
(messages/send-mfa-login-code-email! user-email code)
(catch Throwable e
- (log/warn e "Failed to send MFA email OTP")
+ (log/warnf "Failed to send MFA email OTP: %s" (ex-message e))
;; don't tell an unauthenticated caller "the code exists but the email failed"
(throw (ex-info (tru "Failed to send the sign-in code. Please try again or contact your administrator.")
{:status-code 500}))))))
diff --git a/enterprise/backend/src/metabase_enterprise/mfa/management.clj b/enterprise/backend/src/metabase_enterprise/mfa/management.clj
index 2f949b6f747..5faa5c011aa 100644
--- a/enterprise/backend/src/metabase_enterprise/mfa/management.clj
+++ b/enterprise/backend/src/metabase_enterprise/mfa/management.clj
@@ -75,7 +75,7 @@
(when-let [user-info (sso/find-user user-email)]
(sso/verify-password user-info password)))
(catch Exception e
- (log/warn e "LDAP re-auth failed because the directory is unreachable")
+ (log/warnf "LDAP re-auth failed because the directory is unreachable: %s" (ex-message e))
false)))))))
;; Notification emails here are fire-and-log by construction: the messages/send-mfa-*-email!
diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/api.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/api.clj
index 4cf9bebcbeb..af362173d57 100644
--- a/enterprise/backend/src/metabase_enterprise/remote_sync/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/api.clj
@@ -316,7 +316,7 @@
(let [branch-list (source.p/branches source)]
{:items branch-list})
(catch Exception e
- (log/errorf e "Failed to get branches from source: %s" (ex-message e))
+ (log/errorf "Failed to get branches from source: %s" (ex-message e))
(let [error-msg (impl/source-error-message e)]
(throw (ex-info error-msg {:status-code 400}
e)))))))
diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj
index e8754ebc764..c9b3335425b 100644
--- a/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj
+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/impl.clj
@@ -267,7 +267,7 @@
:path (or repo-path (:path fspec))
:content_hash (source/content-hash (:content fspec))})
(catch Exception e
- (log/warnf e "Skipping %s %s: failed to serialize for content hash" model-type (:id instance))
+ (log/warnf "Skipping %s %s: failed to serialize for content hash: %s" model-type (:id instance) (ex-message e))
nil)))]
;; One transduction over the model groups: stream each model's extract-query through `serialize` via an
;; eduction — extract-one runs while the ResultSet is open, with no intermediate per-model sequence.
@@ -530,7 +530,7 @@
(let [{:keys [conflicts merged summary]} (source/compute-merge (spec/extract-entities-for-export) snapshot base-snapshot task-id)]
(if (seq conflicts)
(let [labels (mapv remote-sync.merge/conflict-label conflicts)]
- (log/infof "Pull merge conflict on %d entit(ies): %s" (count labels) (str/join ", " labels))
+ (log/infof "Pull merge conflict on %d entit(ies)" (count labels))
{:status :conflict
:version (source.p/version snapshot)
:conflicts labels
@@ -699,7 +699,7 @@
(if (:cancelled? (ex-data e))
(log/info "Import from git repository was cancelled")
(do
- (log/errorf e "Failed to reload from git repository: %s" (ex-message e))
+ (log/errorf "Failed to reload from git repository: %s" (ex-message e))
(analytics/inc! :metabase-remote-sync/imports-failed)
{:status :error
:message (source-error-message e)
@@ -748,7 +748,7 @@
{:keys [merged conflicts summary]} (source/compute-merge models snapshot base-snapshot task-id)]
(if (seq conflicts)
(let [labels (mapv remote-sync.merge/conflict-label conflicts)]
- (log/infof "Export merge conflict on %d entit(ies): %s" (count labels) (str/join ", " labels))
+ (log/infof "Export merge conflict on %d entit(ies)" (count labels))
{:status :conflict
:version (source.p/version snapshot)
:conflicts labels
@@ -1254,7 +1254,7 @@
(catch Exception e
;; handle-task-result! records the failure on this result, and skips entirely when the task
;; was already cancelled (ended_at set) — so cancellation needs no special case here.
- (log/errorf e "Failed to export to git repository: %s" (ex-message e))
+ (log/errorf "Failed to export to git repository: %s" (ex-message e))
(analytics/inc! :metabase-remote-sync/exports-failed)
{:status :error
:message (format "Failed to export to git repository: %s" (ex-message e))})
@@ -1456,7 +1456,7 @@
(let [result (try
(sync-fn task-id)
(catch Exception e
- (log/error e "Remote sync task failed")
+ (log/errorf "Remote sync task failed: %s" (ex-message e))
{:status :error
:message (source-error-message e)}))]
(handle-task-result! result task-id branch)
@@ -1464,7 +1464,7 @@
(try
(on-success task-id result)
(catch Exception e
- (log/error e "Remote sync task :on-success function failed")))))))
+ (log/errorf "Remote sync task :on-success function failed: %s" (ex-message e))))))))
task))
(defn async-import!
diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/merge.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/merge.clj
index 1966ab61bd1..c3293c72427 100644
--- a/enterprise/backend/src/metabase_enterprise/remote_sync/merge.clj
+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/merge.clj
@@ -37,7 +37,7 @@
;; A serialized entity that won't parse is abnormal (malformed/partially-written file) and demotes
;; this side to a path key while the other side stays identity-keyed — which reads as a phantom
;; add+remove rather than an update. Warn so it's visible rather than silently mis-merged.
- (log/warn e "Could not parse serialized content during merge; treating it as a non-serdes (path-keyed) file")
+ (log/warnf "Could not parse serialized content during merge; treating it as a non-serdes (path-keyed) file: %s" (ex-message e))
nil)))
(defn- file-key
diff --git a/enterprise/backend/src/metabase_enterprise/remote_sync/task/import.clj b/enterprise/backend/src/metabase_enterprise/remote_sync/task/import.clj
index 9e46d0e2343..f51c7abc09e 100644
--- a/enterprise/backend/src/metabase_enterprise/remote_sync/task/import.clj
+++ b/enterprise/backend/src/metabase_enterprise/remote_sync/task/import.clj
@@ -45,7 +45,7 @@
(impl/publish-sync-event! :event/remote-sync-import task-id
{:branch branch :auto true} nil)
(catch Exception e
- (log/error e "Failed to publish remote-sync audit event")))))))))))))
+ (log/errorf "Failed to publish remote-sync audit event: %s" (ex-message e))))))))))))))
(task/defjob ^{:doc "Auto-imports any remote collections."} AutoImport [_]
(auto-import!))
diff --git a/enterprise/backend/src/metabase_enterprise/replacement/models/replacement_run.clj b/enterprise/backend/src/metabase_enterprise/replacement/models/replacement_run.clj
index 06e47b692dc..82ab5312f05 100644
--- a/enterprise/backend/src/metabase_enterprise/replacement/models/replacement_run.clj
+++ b/enterprise/backend/src/metabase_enterprise/replacement/models/replacement_run.clj
@@ -144,7 +144,7 @@
(when on-complete
(deliver on-complete :run/success)))
(fail-run! [_ throwable]
- (log/errorf throwable "Replacement run %d failed" run-id)
+ (log/errorf "Replacement run %d failed: %s" run-id (ex-message throwable))
(fail-run! run-id (ex-message throwable))
(when on-complete
(deliver on-complete :run/fail)))))))
diff --git a/enterprise/backend/src/metabase_enterprise/replacement/runner.clj b/enterprise/backend/src/metabase_enterprise/replacement/runner.clj
index 83bea598b64..28b08f29db3 100644
--- a/enterprise/backend/src/metabase_enterprise/replacement/runner.clj
+++ b/enterprise/backend/src/metabase_enterprise/replacement/runner.clj
@@ -135,7 +135,7 @@
(try
(replacement.source-swap/swap-source! entity object old-source new-source)
(catch Exception e
- (log/warnf e "Failed to swap %s, continuing with next entity" entity)
+ (log/warnf "Failed to swap %s, continuing with next entity: %s" entity (ex-message e))
(swap! failures conj {:entity entity :error (ex-message e)})))
(replacement.protocols/advance! progress)))))
(when-let [fs (seq @failures)]
diff --git a/enterprise/backend/src/metabase_enterprise/replacement/timeout.clj b/enterprise/backend/src/metabase_enterprise/replacement/timeout.clj
index cb12924b5ee..11091251ba6 100644
--- a/enterprise/backend/src/metabase_enterprise/replacement/timeout.clj
+++ b/enterprise/backend/src/metabase_enterprise/replacement/timeout.clj
@@ -16,7 +16,7 @@
(try
(replacement-run/timeout-old-runs! 30 :minute)
(catch Throwable t
- (log/error t "Error timing out old source replacement runs."))))
+ (log/errorf "Error timing out old source replacement runs: %s" (ex-message t)))))
(task/defjob ^{:doc "Timeout long-running source replacement runs."
org.quartz.DisallowConcurrentExecution true}
diff --git a/enterprise/backend/src/metabase_enterprise/sandbox/query_processor/middleware/sandboxing.clj b/enterprise/backend/src/metabase_enterprise/sandbox/query_processor/middleware/sandboxing.clj
index 49a22fa24d5..dd63f0c77c8 100644
--- a/enterprise/backend/src/metabase_enterprise/sandbox/query_processor/middleware/sandboxing.clj
+++ b/enterprise/backend/src/metabase_enterprise/sandbox/query_processor/middleware/sandboxing.clj
@@ -165,8 +165,7 @@
persisted-info (:lib/persisted-info card)
persisted? (qp.persisted/can-substitute? card persisted-info)
query (lib/card->underlying-query metadata-providerable card)]
- ;; log the query at this point, it's useful for some purposes
- (log/debugf "Fetched query from Card %s:\n%s" card-id (u/cprint-to-str (select-keys query [:stages :parameters])))
+ (log/debugf "Fetched query from Card %s" card-id)
(cond-> query
;; This will be applied, if still appropriate, by the persistence middleware
persisted?
@@ -262,10 +261,10 @@
(not= table-id original-table-id))
(do
(log/errorf (str "Sandboxes can only include columns from the original Table (%d),"
- " query included %s from Table %d. This is unsupported and may not"
+ " query included column %s from Table %d. This is unsupported and may not"
" work in the future.")
original-table-id
- (pr-str (:name sandbox-col))
+ (:id sandbox-col)
table-id)
true)
@@ -273,9 +272,9 @@
(not matching-table-col)
(do
(log/errorf (str "Sandboxes can only include columns from the original Table,"
- " but query included %s. This is unsupported and may not work in"
+ " but query included column %s. This is unsupported and may not work in"
" the future.")
- (pr-str (:name sandbox-col)))
+ (:id sandbox-col))
true)
:else
@@ -384,9 +383,7 @@
(sandbox-exposed-field-ids sandbox-query source-table)))
replacement-stages (cond-> new-source-stages
wrapper-stage (conj wrapper-stage))]
- (log/tracef "Applied Sandbox: replaced stage\n\n%s\n\nwith stages\n\n%s"
- (u/cprint-to-str stage)
- (u/cprint-to-str replacement-stages))
+ (log/trace "Applied Sandbox: replaced stage with sandboxed stages")
replacement-stages))
(mu/defn- apply-sandboxes :- ::lib.schema/query
diff --git a/enterprise/backend/src/metabase_enterprise/security_center/fetch.clj b/enterprise/backend/src/metabase_enterprise/security_center/fetch.clj
index cb343d63073..f1577e2c73a 100644
--- a/enterprise/backend/src/metabase_enterprise/security_center/fetch.clj
+++ b/enterprise/backend/src/metabase_enterprise/security_center/fetch.clj
@@ -145,7 +145,7 @@
(let [advisories (try
(fetch-advisories-from-store)
(catch Exception e
- (log/warn e "Error fetching advisories from MetaStore")))]
+ (log/warnf "Error fetching advisories from MetaStore: %s" (ex-message e))))]
(if (seq advisories)
(let [total (count advisories)
failures (reduce (fn [n advisory]
@@ -153,7 +153,7 @@
(upsert-advisory! advisory)
n
(catch Exception e
- (log/warnf e "Error upserting advisory %s" (:advisory_id advisory))
+ (log/warnf "Error upserting advisory %s: %s" (:advisory_id advisory) (ex-message e))
(inc n))))
0
advisories)
diff --git a/enterprise/backend/src/metabase_enterprise/security_center/matching.clj b/enterprise/backend/src/metabase_enterprise/security_center/matching.clj
index 82f9fc9cf7a..0a53fe4301c 100644
--- a/enterprise/backend/src/metabase_enterprise/security_center/matching.clj
+++ b/enterprise/backend/src/metabase_enterprise/security_center/matching.clj
@@ -92,7 +92,7 @@
(try
(boolean (seq (query-read-only! query)))
(catch Throwable e
- (log/warnf e "Matching query failed: %s" (pr-str query))
+ (log/warnf "Matching query failed: %s" (ex-message e))
:error))
(do
(log/warnf "No matching query for dialect %s or default" (name (mdb/db-type)))
@@ -161,7 +161,7 @@
(try
(evaluate-advisory! advisory instance-version)
(catch Exception e
- (log/warnf e "Error evaluating advisory %s" (:advisory_id advisory))
+ (log/warnf "Error evaluating advisory %s: %s" (:advisory_id advisory) (ex-message e))
(t2/update! :model/SecurityAdvisory (:id advisory)
{:match_status :error
:last_evaluated_at (mi/now)}))))))))
diff --git a/enterprise/backend/src/metabase_enterprise/security_center/metrics.clj b/enterprise/backend/src/metabase_enterprise/security_center/metrics.clj
index 8f9cd5149bb..e9693bec146 100644
--- a/enterprise/backend/src/metabase_enterprise/security_center/metrics.clj
+++ b/enterprise/backend/src/metabase_enterprise/security_center/metrics.clj
@@ -54,7 +54,7 @@
(when-let [epoch (last-sync-epoch-seconds)]
(analytics/set-gauge! :metabase-security-center/last-sync-timestamp-seconds epoch))
(catch Exception e
- (log/warn e "Failed to set :metabase-security-center/last-sync-timestamp-seconds metric")))
+ (log/warnf "Failed to set :metabase-security-center/last-sync-timestamp-seconds metric: %s" (ex-message e))))
(try
(let [counts (vulnerable-counts)]
(doseq [label vulnerable-advisory-labels]
@@ -62,4 +62,4 @@
label
(get counts label 0))))
(catch Exception e
- (log/warn e "Failed to set :metabase-security-center/vulnerable-advisories metric"))))
+ (log/warnf "Failed to set :metabase-security-center/vulnerable-advisories metric: %s" (ex-message e)))))
diff --git a/enterprise/backend/src/metabase_enterprise/security_center/task/sync_advisories.clj b/enterprise/backend/src/metabase_enterprise/security_center/task/sync_advisories.clj
index 3eba542c350..1a029f65baf 100644
--- a/enterprise/backend/src/metabase_enterprise/security_center/task/sync_advisories.clj
+++ b/enterprise/backend/src/metabase_enterprise/security_center/task/sync_advisories.clj
@@ -52,8 +52,8 @@
(try
(notification/notify-advisory! advisory)
(catch Exception e
- (log/warnf e "Failed to send repeat notification for advisory %s"
- (:advisory_id advisory))))))
+ (log/warnf "Failed to send repeat notification for advisory %s: %s"
+ (:advisory_id advisory) (ex-message e))))))
;;; ----------------------------------------- Sync + evaluate + notify -----------------------------------------------
@@ -66,15 +66,15 @@
(fetch/sync-advisories!)
(settings/security-center-last-synced-at! (t/offset-date-time))
(catch Exception e
- (log/warn e "Error fetching advisories from HM")))
+ (log/warnf "Error fetching advisories from HM: %s" (ex-message e))))
(try
(matching/evaluate-all-advisories!)
(catch Exception e
- (log/warn e "Error re-evaluating advisories")))
+ (log/warnf "Error re-evaluating advisories: %s" (ex-message e))))
(try
(send-repeat-notifications!)
(catch Exception e
- (log/warn e "Error sending repeat notifications")))
+ (log/warnf "Error sending repeat notifications: %s" (ex-message e))))
(metrics/refresh-metrics!)))
(task/defjob ^{:doc "Periodically fetch and re-evaluate security advisories."
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/core.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/core.clj
index 3e16252b003..d18d18b30ae 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/core.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/core.clj
@@ -68,7 +68,7 @@
(semantic.pgvector-api/ensure-active-hnsw-index! (semantic.env/get-pgvector-datasource!)
(semantic.env/get-index-metadata))
(catch Throwable t
- (log/error t "Failed to build HNSW index for semantic search"))
+ (log/errorf "Failed to build HNSW index for semantic search: %s" (ex-message t)))
(finally
(reset! hnsw-index-build-running? false)))))
nil)
@@ -127,7 +127,7 @@
(into [] (comp (map t2.realize/realize)
(take total-limit))))
(catch Throwable t
- (log/warn t "Semantic search fallback errored, ignoring")
+ (log/warnf "Semantic search fallback errored, ignoring: %s" (ex-message t))
[]))
fallback-results (take total-limit fallback-results)
_ (analytics/observe! :metabase-search/semantic-fallback-results-usage (count fallback-results))
@@ -135,7 +135,7 @@
deduped-results (m/distinct-by (juxt :model :id) combined-results)]
(take total-limit deduped-results)))))
(catch Exception e
- (log/error e "Error executing semantic search, falling back to appdb")
+ (log/errorf "Error executing semantic search, falling back to appdb: %s" (ex-message e))
(let [fallback (fallback-engine)]
(analytics/inc! :metabase-search/semantic-error-fallback {:fallback-engine fallback})
(if fallback
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/db/datasource.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/db/datasource.clj
index a816698d2d6..bb543f0927f 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/db/datasource.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/db/datasource.clj
@@ -243,7 +243,8 @@
(jdbc/execute! tx [(str "CREATE SCHEMA IF NOT EXISTS " (quoted/postgres app-db-schema))])))
true
(catch Exception e
- (log/debug e "Semantic search: the application database user cannot provision the pgvector store")
+ (log/debugf "Semantic search: the application database user cannot provision the pgvector store: %s"
+ (ex-message e))
false)))
(defn check-app-db-pgvector-support
@@ -312,8 +313,9 @@
false))
(catch Exception e
(reset! probe-cooldown-timer (u/start-timer))
- (log/warn e (str "Semantic search: pgvector support check on the application database failed;"
- " will retry after the cooldown."))
+ (log/warn (str "Semantic search: pgvector support check on the application database failed;"
+ " will retry after the cooldown:")
+ (ex-message e))
false))))))))
(defn pgvector-mode
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/db/migration/impl.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/db/migration/impl.clj
index 05f09f64400..615a857823e 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/db/migration/impl.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/db/migration/impl.clj
@@ -173,7 +173,7 @@
:location [:like (str "/" root-id "/%")]))]
[coll-id root-type])
(catch Exception e
- (log/warn e "Skipping Library forest backfill — appdb lookup failed")
+ (log/warnf "Skipping Library forest backfill — appdb lookup failed: %s" (ex-message e))
{})))
(defn- add-root-collection-type-column!
@@ -239,7 +239,7 @@
(catch Exception e
(when-not config/is-test?
(throw e))
- (log/warn e "Skipping semantic table curation backfill — appdb unavailable (test)")
+ (log/warnf "Skipping semantic table curation backfill — appdb unavailable (test): %s" (ex-message e))
nil)))
(defn- official-collection-dashboard-ids
@@ -259,7 +259,7 @@
(catch Exception e
(when-not config/is-test?
(throw e))
- (log/warn e "Skipping semantic dashboard curation backfill — appdb unavailable (test)")
+ (log/warnf "Skipping semantic dashboard curation backfill — appdb unavailable (test): %s" (ex-message e))
nil)))
(defn- index-empty?
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/embedders.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/embedders.clj
index 13621700db2..5a9165bb6a6 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/embedders.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/embedders.clj
@@ -106,7 +106,7 @@
:table-name (-> state :index :table-name)
:model (-> state :index :embedding-model)}))
(catch Throwable t
- (log/debug t "Semantic-search index not available; search-index embedder will return {}"))))
+ (log/debugf "Semantic-search index not available; search-index embedder will return {}: %s" (ex-message t)))))
(defn search-index-embedder
"Embedder that reads vectors from the active semantic-search pgvector index. The indexed text
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/embedding.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/embedding.clj
index fbf5524aeab..509471f96f1 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/embedding.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/embedding.clj
@@ -109,8 +109,7 @@
(> text-measure threshold)
(do
(log/warn
- (format "Skipping text that exceeds maximum measure per batch: %s"
- (str (subs text 0 (min 10 (count text))) "..."))
+ "Skipping text that exceeds maximum measure per batch"
{:measure text-measure :threshold threshold})
acc)
@@ -203,7 +202,7 @@
;; :continue so an unexpected action error can't wedge the agent for the process lifetime.
(agent nil
:error-mode :continue
- :error-handler (fn [_agent e] (log/error e "Embedder circuit hook runner errored"))))
+ :error-handler (fn [_agent e] (log/errorf "Embedder circuit hook runner errored: %s" (ex-message e)))))
(defn- on-embedder-circuit-state-change!
"Run the registered [[embedder-circuit-state-change-hooks]] off the failsafe callback thread -- one
@@ -227,7 +226,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/error e "Embedder circuit state-change hook failed")))))))
+ (log/errorf "Embedder circuit state-change hook failed: %s" (ex-message e))))))))
(defn- new-embedder-circuit-breaker []
(dh.cb/circuit-breaker
@@ -371,7 +370,7 @@
:embedding)]
(first (validate-embeddings! [embedding] 1 vector-dimensions)))
(catch Exception e
- (log/error e "Failed to generate Ollama embedding for text of length:" (count text))
+ (log/error "Failed to generate Ollama embedding for text of length" (count text) ":" (ex-message e))
(throw e))))
(defn- ollama-pull-model [model-name]
@@ -382,7 +381,7 @@
{:headers {"Content-Type" "application/json"}
:body (json/encode {:model model-name})}))
(catch Exception e
- (log/error e "Failed to pull embedding model")
+ (log/errorf "Failed to pull embedding model: %s" (ex-message e))
(throw e))))
;; Ollama is not used in production. Token tracking is not implemented.
@@ -488,7 +487,7 @@
(semantic.models.token-tracking/record-tokens model-name (:type opts) total-tokens))
embeddings)
(catch ConnectException e
- (log/error e (str "Failed to connect to " provider) {:endpoint endpoint})
+ (log/error (str "Failed to connect to " provider ": " (ex-message e)) {:endpoint endpoint})
(throw (ex-info (str provider " unavailable (connection refused)")
{:status 502 :endpoint endpoint}
e)))
@@ -496,7 +495,7 @@
;; The breaker transition already logs the outage once. Fast-failed calls while it remains open are
;; expected and can be frequent, so do not emit a redundant error for every guarded request.
(when-not (= :embedder/circuit-open (:cause (ex-data e)))
- (log/error e (str "Failed to generate " provider " embeddings")
+ (log/error (str "Failed to generate " provider " embeddings: " (ex-message e))
{:documents (count texts) :tokens (count-tokens-batch texts)}))
(throw e))))
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/embedding_health.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/embedding_health.clj
index f189f0436bf..c706588a1fe 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/embedding_health.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/embedding_health.clj
@@ -21,7 +21,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/debug e "Embedding service health probe failed")
+ (log/debugf "Embedding service health probe failed: %s" (ex-message e))
{:reachable? false, :error (ex-message e)})))
(def ^:private embedding-service-reachable?*
@@ -87,7 +87,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/debug e "Embedding service circuit recovery probe failed"))
+ (log/debugf "Embedding service circuit recovery probe failed: %s" (ex-message e)))
(finally
(swap! recovery-state assoc :running? false)))
;; A still-untrusted breaker needs another delayed trial even when no user traffic or health consumer runs.
@@ -107,7 +107,7 @@
(schedule-recovery! recover-circuit!)
(catch Exception e
(swap! recovery-state assoc :running? false)
- (log/error e "Failed to schedule embedding service circuit recovery"))))
+ (log/errorf "Failed to schedule embedding service circuit recovery: %s" (ex-message e)))))
nil)
(defn- clear-probe-cache-on-recovery! [state]
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/health.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/health.clj
index 5796b7bd2a5..14f43626796 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/health.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/health.clj
@@ -140,7 +140,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/debug e "semantic active-index lookup failed for a metric collector")
+ (log/debugf "semantic active-index lookup failed for a metric collector: %s" (ex-message e))
nil))))
(def ^:private active-index
@@ -295,4 +295,4 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/warn e "Failed to report semantic repair metrics")))))
+ (log/warnf "Failed to report semantic repair metrics: %s" (ex-message e))))))
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/index.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/index.clj
index 3c45443f7f4..1fbbb173b3f 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/index.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/index.clj
@@ -222,7 +222,7 @@
(->> (index-size connectable table-name)
(analytics/set-gauge! :metabase-search/semantic-index-size))
(catch Exception e
- (log/warn e "Failed to set :metabase-search/semantic-index-size metric"))))
+ (log/warnf "Failed to set :metabase-search/semantic-index-size metric: %s" (ex-message e)))))
(defn- batch-update!
[connectable table-name records->sql documents]
@@ -335,9 +335,7 @@
(if embedding
(map #(assoc % :embedding embedding) (get text->docs text))
(when-let [docs (get text->docs text)]
- (log/warn "No embedding found for" (count docs) "documents with searchable text:"
- {:searchable_text text
- :document_count (count docs)}))))
+ (log/warn "No embedding found for" (count docs) "documents"))))
text->embedding)]
(batch-update!
connectable
@@ -1164,7 +1162,7 @@
{:strategy strategy :plan-node (or (:node-type scan) "unknown")} 1)
(assoc scan :prefilter-pool-size pool))
(catch Exception e
- (log/warn e "Failed to record vector-search instrumentation")
+ (log/warnf "Failed to record vector-search instrumentation: %s" (ex-message e))
nil)))
(defn- time-waterfall
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/indexer.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/indexer.clj
index 2c823dc279e..6619b52824a 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/indexer.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/indexer.clj
@@ -181,7 +181,7 @@
(log/debugf "Processed %d gate documents successfully in normal mode for index %s" (count gate-docs) (:table-name index))
(catch InterruptedException ie (throw ie))
(catch Throwable t
- (log/debug t "Indexing failure caught in normal mode")
+ (log/debugf "Indexing failure caught in normal mode: %s" (ex-message t))
(log/warnf "Indexing failed in normal mode for index %s, marking as stalled: %s" (:table-name index) (.getMessage t))
(mark-stalled! pgvector index-metadata index)
(throw t)))
@@ -476,5 +476,5 @@
(analytics/inc! :metabase-search/semantic-indexer-loop-ms (u/since-ms loop-start-time)))
(catch InterruptedException ie (throw ie))
(catch Throwable t
- (log/errorf t "An exception was caught during the indexing loop for index %s" (:table-name metadata-row))
+ (log/errorf "An exception was caught during the indexing loop for index %s: %s" (:table-name metadata-row) (ex-message t))
(throw t)))))))
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/pgvector_api.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/pgvector_api.clj
index 3abebe30f75..c80c7819e2b 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/pgvector_api.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/pgvector_api.clj
@@ -17,7 +17,6 @@
[metabase-enterprise.semantic-search.repair :as semantic.repair]
[metabase-enterprise.semantic-search.settings :as semantic.settings]
[metabase-enterprise.semantic-search.util :as semantic.util]
- [metabase.util :as u]
[metabase.util.log :as log]
[next.jdbc :as jdbc])
(:import
@@ -60,7 +59,7 @@
(semantic.index/create-index-table-if-not-exists! tx index)
(semantic.dlq/create-dlq-table-if-not-exists! tx index-metadata index-id)
(when-not active
- (log/infof "Configured model does not match active index, switching to new index %s" (u/pprint-to-str index))
+ (log/infof "Configured model does not match active index, switching to new index %s" (pr-str index))
(semantic.index-metadata/activate-index! tx index-metadata index-id))
index))
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/repair.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/repair.clj
index 122071bd44a..178a4e94647 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/repair.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/repair.clj
@@ -134,8 +134,8 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/errorf e "Error counting stale orphans in index table %s against repair table %s"
- index-table-name repair-table-name)
+ (log/errorf "Error counting stale orphans in index table %s against repair table %s: %s"
+ index-table-name repair-table-name (ex-message e))
nil)))
(defn- create-repair-table!
@@ -156,7 +156,7 @@
(sql/format :quoted true)))
(log/infof "Cleaned up repair table: %s" repair-table-name)
(catch Exception e
- (log/warnf e "Failed to drop repair table: %s" repair-table-name))))
+ (log/warnf "Failed to drop repair table %s: %s" repair-table-name (ex-message e)))))
(defn- repair-table-name
"Generates a unique name for a repair table with timestamp for cleanup, qualified like the index tables
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_cleanup.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_cleanup.clj
index 0e14ac1efe3..6e3e20c4a8a 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_cleanup.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_cleanup.clj
@@ -204,7 +204,7 @@
(when (pos? deleted-count)
(log/infof "Cleaned up %d old tombstone records from gate table" deleted-count)))))
(catch Exception e
- (log/error e "Failed to clean up tombstone records from gate table"))))
+ (log/errorf "Failed to clean up tombstone records from gate table: %s" (ex-message e)))))
(defn- drop-index-table!
"Drops one stale/orphaned index table, isolating failures: one undroppable table (e.g. one with a
@@ -220,10 +220,10 @@
(if (= "42P01" (.getSQLState e))
(do (log/infof "Skipping %s semantic search index %s: table no longer exists" kind table-name)
:missing)
- (do (log/warnf e "Failed to drop %s semantic search index %s" kind table-name)
+ (do (log/warnf "Failed to drop %s semantic search index %s: %s" kind table-name (ex-message e))
:failed)))
(catch Exception e
- (log/warnf e "Failed to drop %s semantic search index %s" kind table-name)
+ (log/warnf "Failed to drop %s semantic search index %s: %s" kind table-name (ex-message e))
:failed)))
(defn- cleanup-stale-indexes!
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_repair.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_repair.clj
index f699e1e34d0..eef162fb4e3 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_repair.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/task/index_repair.clj
@@ -35,7 +35,7 @@
(catch Exception e
;; Invalidate the shared snapshot when the producing job fails.
(semantic.health/report-repair-metrics! nil)
- (log/error e "Failed to complete semantic search index repair"))))
+ (log/errorf "Failed to complete semantic search index repair: %s" (ex-message e)))))
(task/defjob ^{DisallowConcurrentExecution true
:doc "Runs repair-index! to maintain semantic search consistency"}
diff --git a/enterprise/backend/src/metabase_enterprise/semantic_search/task/metric_collector.clj b/enterprise/backend/src/metabase_enterprise/semantic_search/task/metric_collector.clj
index 8eb519ddc92..0b8f376e68e 100644
--- a/enterprise/backend/src/metabase_enterprise/semantic_search/task/metric_collector.clj
+++ b/enterprise/backend/src/metabase_enterprise/semantic_search/task/metric_collector.clj
@@ -78,7 +78,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/error e "Semantic search metric collector errored")))
+ (log/errorf "Semantic search metric collector errored: %s" (ex-message e))))
;; Registered collectors self-gate, so refreshing them is a cheap no-op when their feature is off.
;; Keep this outside the try: ordinary failures continue here, while interruption and fatal errors exit.
(search.index-health/refresh-search-index-metrics!))
diff --git a/enterprise/backend/src/metabase_enterprise/serialization/api.clj b/enterprise/backend/src/metabase_enterprise/serialization/api.clj
index 5ba8af2f0d3..3993580d7fe 100644
--- a/enterprise/backend/src/metabase_enterprise/serialization/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/serialization/api.clj
@@ -160,7 +160,7 @@
:dst (.getPath dst)
:count cnt
:files (.listFiles dst)})))
- (log/infof "In total %s entries unpacked, detected source dir: %s" cnt (.getName path))
+ (log/infof "In total %s entries unpacked, source dir detected" cnt)
(serdes/with-cache
(-> (v2.ingest/ingest-yaml (.getPath path))
(v2.load/load-metabase! {:continue-on-error continue-on-error
diff --git a/enterprise/backend/src/metabase_enterprise/serialization/v2/dependency_validation.clj b/enterprise/backend/src/metabase_enterprise/serialization/v2/dependency_validation.clj
index facc4d9f1a5..3c1e10295ac 100644
--- a/enterprise/backend/src/metabase_enterprise/serialization/v2/dependency_validation.clj
+++ b/enterprise/backend/src/metabase_enterprise/serialization/v2/dependency_validation.clj
@@ -9,7 +9,6 @@
Historically this was the collection-id, Card-only \"escape analysis\"; it is now a general dependency-satisfaction
check driven by [[metabase.models.serialization/serialization-dependencies]]."
(:require
- [clojure.string :as str]
[medley.core :as m]
[metabase-enterprise.serialization.v2.models :as serdes.models]
[metabase.models.serialization :as serdes]
@@ -21,16 +20,12 @@
(defn- collection-label [coll-id]
(if coll-id
- (let [collection (t2/hydrate (t2/select-one :model/Collection :id coll-id) :ancestors)
- names (->> (conj (:ancestors collection) collection)
- (map :name)
- (str/join " > "))]
- (format "%d: %s" coll-id names))
+ (str coll-id)
"[no collection]"))
(defn- entity-label [{:keys [model id]}]
- (let [entity (t2/select-one [model :collection_id :name] :id id)]
- (format "%s %d (%s from collection %s)" (name model) id (:name entity) (collection-label (:collection_id entity)))))
+ (let [entity (t2/select-one [model :collection_id] :id id)]
+ (format "%s %d (from collection %s)" (name model) id (collection-label (:collection_id entity)))))
(defn- resize-batch
[[model batch]]
diff --git a/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj b/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj
index bafa40b24a1..41c9dc98f2b 100644
--- a/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj
+++ b/enterprise/backend/src/metabase_enterprise/serialization/v2/load.clj
@@ -87,7 +87,7 @@
(when-let [entity (serdes/load-find-local path)]
((t2/select-pks-fn entity) entity))
(catch Exception e
- (log/debugf e "Could not look up local id for %s while building load error data" (serdes/log-path-str path))
+ (log/debugf "Could not look up local id for %s while building load error data: %s" (serdes/log-path-str path) (ex-message e))
nil)))
(defn- path-error-data [error-type expanding path]
diff --git a/enterprise/backend/src/metabase_enterprise/serialization/v2/storage/tar.clj b/enterprise/backend/src/metabase_enterprise/serialization/v2/storage/tar.clj
index 25494d75383..368a925bcc7 100644
--- a/enterprise/backend/src/metabase_enterprise/serialization/v2/storage/tar.clj
+++ b/enterprise/backend/src/metabase_enterprise/serialization/v2/storage/tar.clj
@@ -42,8 +42,7 @@
(let [resolved (storage.util/resolve-storage-path ctx entity)
path (entry-path dirname resolved)
content (.getBytes ^String (yaml-content entity) "UTF-8")]
- (log/trace "Storing" {:path (serdes/log-path-str (:serdes/meta entity))
- :file path})
+ (log/trace "Storing" {:path (serdes/log-path-str (:serdes/meta entity))})
(put-entry! tar path content)
(:serdes/meta entity)))
diff --git a/enterprise/backend/src/metabase_enterprise/sso/api/sso.clj b/enterprise/backend/src/metabase_enterprise/sso/api/sso.clj
index a3f221c17ab..be1f830cb28 100644
--- a/enterprise/backend/src/metabase_enterprise/sso/api/sso.clj
+++ b/enterprise/backend/src/metabase_enterprise/sso/api/sso.clj
@@ -67,7 +67,7 @@
(try
(sso.i/sso-post request)
(catch Throwable e
- (log/error e "Error logging in")
+ (log/errorf "Error logging in: %s" (ex-message e))
(sso-error-page e :in))))
;; ------------------------------ Single Logout aka SLO ------------------------------
@@ -147,7 +147,7 @@
(throw (ex-info "SAML Single Logout is not enabled, request forbidden."
{:status-code 403})))
(catch Throwable e
- (log/error e "Error handling SLO")
+ (log/errorf "Error handling SLO: %s" (ex-message e))
(sso-error-page e :out))))
;; Key schema that excludes `/` so /:key does not greedily match /:key/callback
@@ -164,7 +164,7 @@
(try
(oidc-integration/sso-initiate provider-key request)
(catch Throwable e
- (log/error e "Error initiating OIDC SSO")
+ (log/errorf "Error initiating OIDC SSO: %s" (ex-message e))
(throw e))))
;; GET /auth/sso/:key/callback
@@ -177,5 +177,5 @@
(try
(oidc-integration/sso-callback provider-key request)
(catch Throwable e
- (log/error e "Error handling OIDC callback")
+ (log/errorf "Error handling OIDC callback: %s" (ex-message e))
(throw e))))
diff --git a/enterprise/backend/src/metabase_enterprise/sso/integrations/saml.clj b/enterprise/backend/src/metabase_enterprise/sso/integrations/saml.clj
index 9f38f5c20aa..761a8850ade 100644
--- a/enterprise/backend/src/metabase_enterprise/sso/integrations/saml.clj
+++ b/enterprise/backend/src/metabase_enterprise/sso/integrations/saml.clj
@@ -214,7 +214,7 @@
(throw (ex-info (or (str (:message login-result)) "SAML authentication failed")
{:status-code 401}))))
(catch Throwable e
- (log/error e "SAML response validation failed")
+ (log/errorf "SAML response validation failed: %s" (ex-message e))
(throw (ex-info (tru "Unable to log in: SAML response validation failed")
{:status-code 401}
e))))))
diff --git a/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj b/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj
index 6ebc3858407..8680e2b29e7 100644
--- a/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj
+++ b/enterprise/backend/src/metabase_enterprise/sso/integrations/sso_utils.clj
@@ -71,7 +71,7 @@
(= (.getHost redirect) our-host)))
redirect-url)
(catch Exception e
- (log/error e "Invalid redirect URL")
+ (log/errorf "Invalid redirect URL: %s" (ex-message e))
(throw (ex-info (tru "Invalid redirect URL")
{:status-code 400
:redirect-url redirect-url})))))
@@ -98,7 +98,7 @@
(keep (fn [[key value]]
(cond
(or (map? value) (nil? value))
- (log/warnf "Dropping attribute '%s' with non-stringable value: %s" (name key) value)
+ (log/warnf "Dropping attribute '%s' with non-stringable value" (name key))
(str/starts-with? (name key) "@")
(log/warnf "Dropping attribute '%s', keys beginning with `@` are reserved" (name key))
diff --git a/enterprise/backend/src/metabase_enterprise/sso/providers/jwt.clj b/enterprise/backend/src/metabase_enterprise/sso/providers/jwt.clj
index ec221847ef7..fbbe7c1d4fe 100644
--- a/enterprise/backend/src/metabase_enterprise/sso/providers/jwt.clj
+++ b/enterprise/backend/src/metabase_enterprise/sso/providers/jwt.clj
@@ -122,12 +122,12 @@
:jwt-data jwt-data
:provider-id email})
(catch clojure.lang.ExceptionInfo e
- (log/errorf e "JWT authentication failed: %s" (.getMessage e))
+ (log/errorf "JWT authentication failed: %s" (.getMessage e))
{:success? false
:error (or (:error (ex-data e)) :authentication-failed)
:message (.getMessage e)})
(catch Exception e
- (log/errorf e "Unexpected error during JWT authentication: %s" (.getMessage e))
+ (log/errorf "Unexpected error during JWT authentication: %s" (.getMessage e))
{:success? false
:error :server-error
:message "An unexpected error occurred during authentication"}))))
diff --git a/enterprise/backend/src/metabase_enterprise/sso/providers/saml.clj b/enterprise/backend/src/metabase_enterprise/sso/providers/saml.clj
index df8576eace9..6c83e768d4f 100644
--- a/enterprise/backend/src/metabase_enterprise/sso/providers/saml.clj
+++ b/enterprise/backend/src/metabase_enterprise/sso/providers/saml.clj
@@ -93,7 +93,7 @@
:redirect-url (get-in response [:headers "location"])
:message "Redirecting to SAML provider"})
(catch Throwable e
- (log/errorf e "Error generating SAML request: %s" (.getMessage e))
+ (log/errorf "Error generating SAML request: %s" (.getMessage e))
{:success? false
:error :saml-request-generation-failed
:message (str (tru "Error generating SAML request"))}))
@@ -141,12 +141,12 @@
:user-attributes user-attributes}
:provider-id email})
(catch clojure.lang.ExceptionInfo e
- (log/errorf e "SAML authentication failed: %s" (.getMessage e))
+ (log/errorf "SAML authentication failed: %s" (.getMessage e))
{:success? false
:error (or (:error (ex-data e)) :authentication-failed)
:message (.getMessage e)})
(catch Exception e
- (log/errorf e "Unexpected error during SAML authentication: %s" (.getMessage e))
+ (log/errorf "Unexpected error during SAML authentication: %s" (.getMessage e))
{:success? false
:error :server-error
:message (str (tru "Unable to log in: SAML response validation failed"))}))))
diff --git a/enterprise/backend/src/metabase_enterprise/sso/settings.clj b/enterprise/backend/src/metabase_enterprise/sso/settings.clj
index 54790307aaf..1fd5b1fa3dc 100644
--- a/enterprise/backend/src/metabase_enterprise/sso/settings.clj
+++ b/enterprise/backend/src/metabase_enterprise/sso/settings.clj
@@ -64,7 +64,7 @@ using, this usually looks like `https://your-org-name.example.com` or `https://e
(try
(instance? java.security.cert.X509Certificate (saml/->X509Certificate idp-cert-str))
(catch Throwable e
- (log/error e "Error parsing SAML identity provider certificate")
+ (log/errorf "Error parsing SAML identity provider certificate: %s" (ex-message e))
(throw
(Exception. (tru "Invalid identity provider certificate. Certificate should be a base-64 encoded string."))))))
diff --git a/enterprise/backend/src/metabase_enterprise/support_access_grants/models/support_access_grant_log.clj b/enterprise/backend/src/metabase_enterprise/support_access_grants/models/support_access_grant_log.clj
index 1f2d416442d..1b97cea3e57 100644
--- a/enterprise/backend/src/metabase_enterprise/support_access_grants/models/support_access_grant_log.clj
+++ b/enterprise/backend/src/metabase_enterprise/support_access_grants/models/support_access_grant_log.clj
@@ -60,6 +60,6 @@
(catch Exception e
;; If the support user is somehow the last admin, we can't remove superuser via model hooks.
;; Sessions and auth identities are still cleaned up below, preventing further access.
- (log/warnf e "Could not remove superuser from support user %d" support-user-id)))
+ (log/warnf "Could not remove superuser from support user %d: %s" support-user-id (ex-message e))))
(t2/update! :model/AuthIdentity :id [:in auth-identity-ids] {:expires_at revoked-at})
(t2/delete! :model/Session :user_id support-user-id))))))
diff --git a/enterprise/backend/src/metabase_enterprise/transforms/core.clj b/enterprise/backend/src/metabase_enterprise/transforms/core.clj
index edaca1a670b..af43f09920a 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms/core.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms/core.clj
@@ -21,7 +21,7 @@
(try
(t2/update! (t2/table-name :model/Transform) id {:table_dependencies (json/encode (vec raw-deps))})
(catch Throwable e
- (log/warnf e "Failed to cache table-dependencies for transform %s" id)))))
+ (log/warnf "Failed to cache table-dependencies for transform %s: %s" id (ex-message e))))))
(defenterprise transform-metered-as
"Return the meter bucket a new transform run of the given source-type counts toward,
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_inspector/context.clj b/enterprise/backend/src/metabase_enterprise/transforms_inspector/context.clj
index 015edcdbc47..a1b870931e6 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_inspector/context.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_inspector/context.clj
@@ -41,7 +41,7 @@
table-ids (lib/all-source-table-ids query)]
(table-ids->source-info table-ids))
(catch Exception e
- (log/warn e "Failed to extract sources from MBQL transform")
+ (log/warnf "Failed to extract sources from MBQL transform: %s" (ex-message e))
nil)))
(defmethod extract-sources :native
@@ -56,7 +56,7 @@
table-ids (keep :table deps)]
(table-ids->source-info table-ids))
(catch Exception e
- (log/warn e "Failed to extract sources from native transform")
+ (log/warnf "Failed to extract sources from native transform: %s" (ex-message e))
nil)))
(defmethod extract-sources :python
@@ -67,7 +67,7 @@
table-ids (keep :table_id normalized)]
(table-ids->source-info table-ids))
(catch Exception e
- (log/warn e "Failed to extract sources from Python transform")
+ (log/warnf "Failed to extract sources from Python transform: %s" (ex-message e))
nil)))
(defmethod extract-sources :default
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj b/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj
index c1cc0b9493d..3e24d889a30 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_inspector/query_analysis.clj
@@ -228,7 +228,7 @@
:join-structure (extract-native-join-structure ast table->id driver)
:visited-fields (resolve-native-visited-fields driver native-query)})))
(catch Exception e
- (log/warn e "Failed to analyze native SQL query")
+ (log/warnf "Failed to analyze native SQL query: %s" (ex-message e))
nil)))
;;; -------------------------------------------------- Unified Analysis --------------------------------------------------
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_python/base.clj b/enterprise/backend/src/metabase_enterprise/transforms_python/base.clj
index 5778dbe5e4b..fad7e49299e 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_python/base.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_python/base.clj
@@ -131,7 +131,7 @@
source-table-name table-name})
(transforms-base.u/drop-table! driver db-id temp-table-name)
(catch Exception e
- (log/error e "Failed to transfer data using rename-tables strategy")
+ (log/errorf "Failed to transfer data using rename-tables strategy: %s" (ex-message e))
(try
(transforms-base.u/drop-table! driver db-id source-table-name)
(catch Exception _))
@@ -147,7 +147,7 @@
(transforms-base.u/drop-table! driver db-id table-name)
(driver/rename-table! driver db-id source-table-name table-name)
(catch Exception e
- (log/error e "Failed to transfer data using create-drop-rename strategy")
+ (log/errorf "Failed to transfer data using create-drop-rename strategy: %s" (ex-message e))
(try
(transforms-base.u/drop-table! driver db-id source-table-name)
(catch Exception _))
@@ -161,7 +161,7 @@
(transforms-base.u/drop-table! driver db-id table-name)
(create-table-and-insert-data! driver db-id (table-schema table-name metadata indexes) data-source)
(catch Exception e
- (log/error e "Failed to transfer data using drop-create fallback strategy")
+ (log/errorf "Failed to transfer data using drop-create fallback strategy: %s" (ex-message e))
(throw e))))
(defn- upsert-with-merge-strategy!
@@ -317,7 +317,7 @@
(finally
(.delete temp-file))))
(catch Exception e
- (log/error e "Failed to create resulting table")
+ (log/errorf "Failed to create resulting table: %s" (ex-message e))
(throw (ex-info "Failed to create the resulting table"
{:transform-message (or (:transform-message (ex-data e))
(i18n/tru "Failed to create the resulting table"))}
@@ -378,7 +378,7 @@
ch))
start-ms (u/start-timer)]
(log! message-log (i18n/tru "Executing Python transform"))
- (log/info "Executing Python transform" transform-id "with target" (pr-str target))
+ (log/info "Executing Python transform" transform-id)
(let [result (run-python-transform-impl! transform db effective-run-id cancel-chan message-log
{:with-stage-timing-fn with-stage-timing-fn
:source-range-params source-range-params})]
@@ -410,7 +410,7 @@
:else
(do
- (log/error e "Error executing Python transform")
+ (log/errorf "Error executing Python transform: %s" (ex-message e))
{:status :failed
:error e
:logs (str logs "\n" error-message)})))))))
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_python/execute.clj b/enterprise/backend/src/metabase_enterprise/transforms_python/execute.clj
index e2ace811569..9bdc7f4c453 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_python/execute.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_python/execute.clj
@@ -62,12 +62,12 @@
(recur))
:else
(do
- (log/warnf "Unexpected status polling for logs %s %s, run-id: %s" status body run-id)
+ (log/warnf "Unexpected status polling for logs %s, run-id: %s" status run-id)
(log/debug "Exiting due to poll error")))))))
(catch SocketException se (when-not (= "Closed by interrupt" (ex-message se)) (throw se)))
(catch InterruptedException _)
(catch Throwable e
- (log/errorf e "An exception was caught during msg update loop, run-id: %s" run-id))))
+ (log/errorf "An exception was caught during msg update loop, run-id: %s: %s" run-id (ex-message e)))))
(defn- open-python-message-update-future! ^Closeable [run-id message-log]
(if (app-db/in-transaction?)
@@ -142,5 +142,5 @@
(transforms-base.u/complete-execution! transform {})
{:run_id run-id :result result}))))))
(catch Throwable t
- (log/error t "Error executing Python transform")
+ (log/errorf "Error executing Python transform: %s" (ex-message t))
(throw t))))
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_python/python_runner.clj b/enterprise/backend/src/metabase_enterprise/transforms_python/python_runner.clj
index 23c3b2aedd0..4fd602ea6fb 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_python/python_runner.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_python/python_runner.clj
@@ -255,8 +255,8 @@
[server-url run-id]
(python-runner-request server-url :post "/cancel" {:body (json/encode {:request_id run-id})
:async? true}
- #_success #(log/debug %)
- #_failure #(log/error %)))
+ #_success (fn [_] (log/debug "Python runner cancel request completed"))
+ #_failure #(log/errorf "Python runner cancel request failed: %s" (ex-message %))))
(defn- safe-delete
"Safely delete a file."
diff --git a/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj b/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj
index 09b8dadf76e..29911dca72f 100644
--- a/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj
+++ b/enterprise/backend/src/metabase_enterprise/transforms_python/s3.clj
@@ -214,7 +214,7 @@
(try
(.deleteObject s3-client (delete-object-request bucket-name key))
(catch Exception e
- (log/debugf e "Error deleting s3 object %s" key)
+ (log/debugf "Error deleting s3 object %s: %s" key (ex-message e))
;; Ignore deletion errors - object might not exist, or we might not have permissions
;; NOTE: we plan to put general retention on the bucket so that objects will eventually be deleted
nil)))
diff --git a/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj b/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj
index 4d89895497f..5c6e7d4ad90 100644
--- a/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/sso/integrations/jwt_test.clj
@@ -1016,8 +1016,8 @@
"array_attr" "item1,item2"}
(t2/select-one-fn :jwt_attributes :model/User :email "[email protected]"))))
(testing "warning messages are logged for non-stringable values"
- (is (some #(re-find #"Dropping attribute 'object_attr' with non-stringable value: \{:nested \"value\"\}" %) (map :message (jwt-log-messages))))
- (is (some #(re-find #"Dropping attribute 'null_attr' with non-stringable value: null" %) (map :message (jwt-log-messages)))))
+ (is (some #(re-find #"Dropping attribute 'object_attr' with non-stringable value" %) (map :message (jwt-log-messages))))
+ (is (some #(re-find #"Dropping attribute 'null_attr' with non-stringable value" %) (map :message (jwt-log-messages)))))
(testing "warning messages are logged for `@`-prefixed keys"
(is (some #(re-find #"Dropping attribute '@attribute', keys beginning with `@` are reserved" %) (map :message (jwt-log-messages)))))
(testing "no warning for valid string attribute"
diff --git a/frontend/src/metabase/static-viz/lib/svg.ts b/frontend/src/metabase/static-viz/lib/svg.ts
index 93ad3522758..27318aff7ea 100644
--- a/frontend/src/metabase/static-viz/lib/svg.ts
+++ b/frontend/src/metabase/static-viz/lib/svg.ts
@@ -1,3 +1,25 @@
+import Color from "color";
+
+const FUNCTIONAL_COLOR_ATTRIBUTE_REGEX = /="((?:hsla?|rgba?)\([^")]*\))"/g;
+
+/**
+ * Batik (the backend SVG rasterizer) only understands CSS2 color syntax and
+ * rejects elements with functional color notations like `hsl()`/`hsla()`.
+ * Colors resolved through the static rendering context are already hex, but
+ * anything that bypasses it would break rendering, so rewrite any leftover
+ * functional color in an attribute value to hex (dropping alpha, same as
+ * `getHexColor`).
+ */
+export const replaceFunctionalColors = (svgString: string) => {
+ return svgString.replace(FUNCTIONAL_COLOR_ATTRIBUTE_REGEX, (match, value) => {
+ try {
+ return `="${Color(value).hex()}"`;
+ } catch {
+ return match;
+ }
+ });
+};
+
const transformSvgForOutline = (svgString: string) => {
const regex =
/<text([^>]*fill="([^"]+)"[^>]*stroke="([^"]+)"[^>]*)>(.*?)<\/text>/g;
@@ -44,8 +66,9 @@ export const sanitizeSvgForBatik = (
return svgString;
}
- return [transformSvgForOutline, patchDominantBaseline].reduce(
- (currSVGString, transform) => transform(currSVGString),
- svgString,
- );
+ return [
+ transformSvgForOutline,
+ patchDominantBaseline,
+ replaceFunctionalColors,
+ ].reduce((currSVGString, transform) => transform(currSVGString), svgString);
};
diff --git a/frontend/src/metabase/static-viz/lib/svg.unit.spec.ts b/frontend/src/metabase/static-viz/lib/svg.unit.spec.ts
index e8a519c1695..438f1e34e5a 100644
--- a/frontend/src/metabase/static-viz/lib/svg.unit.spec.ts
+++ b/frontend/src/metabase/static-viz/lib/svg.unit.spec.ts
@@ -1,4 +1,4 @@
-import { patchDominantBaseline } from "./svg";
+import { patchDominantBaseline, replaceFunctionalColors } from "./svg";
const OUTER_TEXT = "outer-text";
const G_ELEM = "g-elem";
@@ -49,6 +49,22 @@ const SVG_STR = `<svg width="500" height="500">
</svg>
`;
+describe("replaceFunctionalColors", () => {
+ it("should rewrite hsl/hsla/rgb/rgba attribute values to hex", () => {
+ const svg = `<svg><text fill="hsla(0, 0%, 100%, 0.95)" stroke="hsl(208, 95%, 42%)">a</text><rect fill="rgba(255, 255, 255, 0.5)" stroke="rgb(80, 158, 227)"/></svg>`;
+
+ expect(replaceFunctionalColors(svg)).toBe(
+ `<svg><text fill="#FFFFFF" stroke="#0572D1">a</text><rect fill="#FFFFFF" stroke="#509EE3"/></svg>`,
+ );
+ });
+
+ it("should leave hex colors, keywords, and text content alone", () => {
+ const svg = `<svg><text fill="#509ee3" stroke="none">hsla(0, 0%, 100%, 0.95)</text></svg>`;
+
+ expect(replaceFunctionalColors(svg)).toBe(svg);
+ });
+});
+
describe("patchDominantBaseline", () => {
it(`should add "dy='0.5em'" to all text nodes with "dominant-baseline='central'`, () => {
const patchedSvgStr = patchDominantBaseline(SVG_STR);
diff --git a/modules/drivers/athena/src/metabase/driver/athena.clj b/modules/drivers/athena/src/metabase/driver/athena.clj
index 73e263ba329..eb7ecb611b2 100644
--- a/modules/drivers/athena/src/metabase/driver/athena.clj
+++ b/modules/drivers/athena/src/metabase/driver/athena.clj
@@ -165,8 +165,7 @@
(try
(u.date/with-time-zone-same-instant t results-timezone)
(catch Throwable _
- (log/warnf "Failed to construct ZonedDateTime from `%s` using `%s` timezone."
- (pr-str t)
+ (log/warnf "Failed to construct ZonedDateTime using `%s` timezone."
(pr-str results-timezone))
t))))))
@@ -358,11 +357,11 @@
"Workaround for avoiding the usage of 'advance' jdbc feature that are not implemented by the driver yet.
Such as prepare statement"
[database query]
- (log/infof "Running Athena query : '%s'..." query)
+ (log/info "Running Athena query...")
(try
(jdbc/query (sql-jdbc.conn/db->pooled-connection-spec database) (str/replace query ";" " ") {:raw? true})
(catch Exception e
- (log/error (u/format-color 'red "Failed to execute query: %s %s" query (.getMessage e))))))
+ (log/error (u/format-color 'red "Failed to execute query: %s" (.getMessage e))))))
(defn- describe-database->clj
"Workaround for wrong getColumnCount response by the driver (huh?)"
@@ -472,7 +471,7 @@
(describe-table-fields-with-nested-fields database schema table-name)
(describe-table-fields-without-nested-fields driver schema table-name columns)))
(catch Throwable e
- (log/errorf e "Error retrieving fields for DB %s.%s" schema table-name)
+ (log/errorf "Error retrieving fields for DB %s.%s: %s" schema table-name (ex-message e))
(throw e)))))
;; Because describe-table-fields might fail, we catch the error here and return an empty set of columns
diff --git a/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk.clj b/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk.clj
index 0e047269ef9..8db77324aec 100644
--- a/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk.clj
+++ b/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk.clj
@@ -138,7 +138,7 @@
;; check whether we can connect by seeing whether listing datasets succeeds
(let [[success? datasets] (try [true (list-datasets details)]
(catch Exception e
- (log/error e "Exception caught in :bigquery-cloud-sdk can-connect?")
+ (log/errorf "Exception caught in :bigquery-cloud-sdk can-connect?: %s" (ex-message e))
[false nil]))]
(cond
(not success?)
@@ -474,7 +474,7 @@
:where [:in :c.table_name table-names]
:order-by [:c.table_name]})
(catch Throwable e
- (log/warnf e "error in describe-fields for dataset: %s" dataset-id)))]
+ (log/warnf "error in describe-fields for dataset %s: %s" dataset-id (ex-message e))))]
(eduction
(partition-by :table_name)
(mapcat #(describe-dataset-table dataset-id %))
@@ -494,7 +494,7 @@
:from [[(information-schema-table project-id dataset-id "TABLES") :t]]
:order-by [:table_name]}))
(catch Throwable e
- (log/warnf e "error in list-table-names for dataset: %s" dataset-id))))
+ (log/warnf "error in list-table-names for dataset %s: %s" dataset-id (ex-message e)))))
(defmethod driver/describe-fields :bigquery-cloud-sdk
[driver database & {:keys [schema-names table-names]}]
@@ -834,7 +834,7 @@
(let [acc' (try
(rf acc (.next it))
(catch Throwable e
- (log/errorf e "error in reducible-bigquery-results! %d rows" n)
+ (log/errorf "error in reducible-bigquery-results! %d rows: %s" n (ex-message e))
(throw e)))]
(recur page it acc' (inc n)))
@@ -862,7 +862,7 @@
(.cancel client job-id)
(catch Throwable e
;; Just log exception if it can't be cancelled.
- (log/debugf e "Could not cancel job-id: %s" job-id)))
+ (log/debugf "Could not cancel job-id %s: %s" job-id (ex-message e))))
^Schema schema (some-> page .getSchema)
parsers (some-> schema get-field-parsers)
columns (for [column (some-> schema .getFields fields->metabase-field-info)]
@@ -920,7 +920,7 @@
:cancel (try
(.cancel client job-id)
(catch Throwable t
- (log/warnf t "Couldn't cancel job %s" job-id))
+ (log/warnf "Couldn't cancel job %s: %s" job-id (ex-message t)))
(finally
(throw-cancelled sql parameters)))
:ready (bigquery-execute-response result job client respond cancel-chan)))))
@@ -1264,7 +1264,7 @@
(doall
(for [query queries]
(let [[sql params] (if (string? query) [query] query)
- _ (log/debugf "Executing BigQuery DDL: %s" sql)
+ _ (log/debug "Executing BigQuery DDL")
job-config (-> (QueryJobConfiguration/newBuilder sql)
(bigquery.params/set-parameters! params)
(.setUseLegacySql false)
@@ -1273,7 +1273,7 @@
{:rows-affected (or (and table-result (.getTotalRows table-result))
0)})))
(catch Exception e
- (log/error e "Error executing BigQuery DDL")
+ (log/errorf "Error executing BigQuery DDL: %s" (ex-message e))
(throw e)))))
(defmethod driver/drop-transform-target! [:bigquery-cloud-sdk :table]
diff --git a/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/params.clj b/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/params.clj
index a8d565d2220..d8d91c22c6d 100644
--- a/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/params.clj
+++ b/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/params.clj
@@ -74,7 +74,7 @@
(defn- query-parameter ^QueryParameterValue [value]
(let [param (->QueryParameterValue value)]
- (log/tracef "Set parameter ^%s %s -> %s" (some-> value class .getCanonicalName) (pr-str value) (pr-str param))
+ (log/tracef "Set parameter of class %s" (some-> value class .getCanonicalName))
param))
(defn set-parameters!
diff --git a/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/query_processor.clj b/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/query_processor.clj
index 8b0a4541387..2eff2b9ee8f 100644
--- a/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/query_processor.clj
+++ b/modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk/query_processor.clj
@@ -166,7 +166,7 @@
(defn- parse-timestamp-str [timezone-id s]
;; Timestamp strings either come back as ISO-8601 strings or Unix timestamps in seconds, e.g. "1.3963104E9"
- (log/tracef "Parse timestamp string '%s' (default timezone ID = %s)" s timezone-id)
+ (log/tracef "Parsing timestamp string (default timezone ID = %s)" timezone-id)
(if-let [seconds (u/ignore-exceptions (Double/parseDouble s))]
(let [full-seconds (long seconds)
;; BigQuery timestamps have microsecond precision
@@ -381,8 +381,7 @@
(contains? #{:date :time :datetime :timestamp} target-type)
(do
- (log/tracef "Coercing %s (temporal type = %s) to %s"
- (binding [*print-meta* true] (pr-str x))
+ (log/tracef "Coercing expression (temporal type = %s) to %s"
(pr-str (temporal-type x))
target-type)
(let [expr (if-let [report-zone (when (or (= current-type :timestamp)
@@ -907,13 +906,13 @@
(into [tag] (map reconcile-temporal-types) args)
(if-let [target-type (some temporal-type args)]
(do
- (log/tracef "Coercing args in %s to temporal type %s" (binding [*print-meta* true] (pr-str clause)) target-type)
+ (log/tracef "Coercing args in %s clause to temporal type %s" tag target-type)
(u/prog1 (into [tag]
(map (partial ->temporal-type target-type))
args)
(when (or (not= clause <>)
(not= (meta clause) (meta <>)))
- (log/tracef "Coerced -> %s" (binding [*print-meta* true] (pr-str <>))))))
+ (log/trace "Coerced args to temporal type"))))
clause)))
(doseq [filter-type [:between := :!= :> :>= :< :<=]]
diff --git a/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj b/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj
index ee829ad0478..bc543fb02e7 100644
--- a/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj
+++ b/modules/drivers/clickhouse/src/metabase/driver/clickhouse.clj
@@ -181,7 +181,7 @@
(when (.next rset)
(.getBoolean rset 1))))))
(catch Throwable e
- (log/error e "An exception during ClickHouse connectivity check")
+ (log/errorf "An exception during ClickHouse connectivity check: %s" (ex-message e))
false))
;; During normal usage, fall back to the default implementation
(sql-jdbc.conn/can-connect? driver details)))
diff --git a/modules/drivers/mongo/src/metabase/driver/mongo.clj b/modules/drivers/mongo/src/metabase/driver/mongo.clj
index d3d3ae10131..1f72fdd3917 100644
--- a/modules/drivers/mongo/src/metabase/driver/mongo.clj
+++ b/modules/drivers/mongo/src/metabase/driver/mongo.clj
@@ -589,7 +589,6 @@
(encode-mongo parsed))
(catch Throwable e
(log/errorf "Unexpected error while prettifying Mongo BSON query: %s" (ex-message e))
- (log/debugf e "Query:\n%s" native-form)
native-form)))
(defmethod driver/create-table! :mongo
diff --git a/modules/drivers/mongo/src/metabase/driver/mongo/execute.clj b/modules/drivers/mongo/src/metabase/driver/mongo/execute.clj
index b0b89eb11a4..9d5cd6038c6 100644
--- a/modules/drivers/mongo/src/metabase/driver/mongo/execute.clj
+++ b/modules/drivers/mongo/src/metabase/driver/mongo/execute.clj
@@ -199,7 +199,7 @@
(.next cursor))
{row-col-names :row
unescaped-col-names :unescaped} (result-col-names native-query query (row-keys first-row))]
- (log/tracef "Renaming columns in results %s -> %s" (pr-str row-col-names) (pr-str unescaped-col-names))
+ (log/tracef "Renaming %d columns in results" (count row-col-names))
(respond (result-metadata unescaped-col-names)
(if-not first-row
[]
diff --git a/modules/drivers/mongo/src/metabase/driver/mongo/parameters.clj b/modules/drivers/mongo/src/metabase/driver/mongo/parameters.clj
index 3fd7af41491..d64638a512c 100644
--- a/modules/drivers/mongo/src/metabase/driver/mongo/parameters.clj
+++ b/modules/drivers/mongo/src/metabase/driver/mongo/parameters.clj
@@ -11,11 +11,9 @@
[metabase.query-processor.parameters.dates :as params.dates]
[metabase.query-processor.parameters.operators :as params.ops]
[metabase.query-processor.parameters.values :as params.values]
- [metabase.util :as u]
[metabase.util.date-2 :as u.date]
[metabase.util.i18n :refer [tru]]
[metabase.util.json :as json]
- [metabase.util.log :as log]
[metabase.util.malli :as mu]
[metabase.util.performance :as perf :refer [get-in]])
(:import
@@ -227,9 +225,7 @@
(defn- parse-and-substitute [param->value x]
(if-not (string? x)
x
- (u/prog1 (substitute param->value (lib/parse-parameters x false))
- (when-not (= x <>)
- (log/debugf "Substituted %s -> %s" (pr-str x) (pr-str <>))))))
+ (substitute param->value (lib/parse-parameters x false))))
(mu/defn substitute-native-parameters :- ::lib.schema/stage.native
"Implementation of [[metabase.driver/substitute-native-parameters]] for MongoDB."
diff --git a/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj b/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj
index b894bc43730..ba7643d9eff 100644
--- a/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj
+++ b/modules/drivers/mongo/src/metabase/driver/mongo/query_processor.clj
@@ -1708,8 +1708,7 @@ function(bin) {
(defn- log-aggregation-pipeline [form]
(when-not driver-api/*disable-qp-logging*
- (log/tracef "\nMongo aggregation pipeline:\n%s\n"
- (u/pprint-to-str 'green (perf/postwalk #(if (symbol? %) (symbol (name %)) %) form)))))
+ (log/tracef "Compiled Mongo aggregation pipeline with %d stage(s)" (count form))))
(defn simple-mbql->native
"Compile a simple (non-nested) MBQL query."
diff --git a/modules/drivers/oracle/src/metabase/driver/oracle.clj b/modules/drivers/oracle/src/metabase/driver/oracle.clj
index 35a62f03d04..611da5b8926 100644
--- a/modules/drivers/oracle/src/metabase/driver/oracle.clj
+++ b/modules/drivers/oracle/src/metabase/driver/oracle.clj
@@ -681,7 +681,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting result set fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting result set fetch direction to FETCH_FORWARD: %s" (ex-message e))))
(sql-jdbc.execute/set-parameters! driver stmt params)
stmt
(catch Throwable e
@@ -698,7 +698,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting result set fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting result set fetch direction to FETCH_FORWARD: %s" (ex-message e))))
stmt
(catch Throwable e
(.close stmt)
diff --git a/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj b/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj
index bfd9fd5d6c4..d11b9ec52a9 100644
--- a/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj
+++ b/modules/drivers/presto-jdbc/src/metabase/driver/presto_jdbc.clj
@@ -574,7 +574,7 @@
implementation."
[driver conn catalog schema]
(let [sql (describe-schema-sql driver catalog schema)]
- (log/tracef "Running statement in describe-schema: %s" sql)
+ (log/tracef "Running statement in describe-schema for %s.%s" catalog schema)
(into #{} (comp (filter (fn [{table-name :table}]
(have-select-privilege? driver conn schema table-name)))
(map (fn [{table-name :table}]
@@ -587,7 +587,7 @@
implementation."
[driver conn catalog]
(let [sql (describe-catalog-sql driver catalog)]
- (log/tracef "Running statement in all-schemas: %s" sql)
+ (log/tracef "Running statement in all-schemas for catalog %s" catalog)
(into []
(map (fn [{:keys [schema]}]
(when-not (contains? excluded-schemas schema)
@@ -623,7 +623,7 @@
nil
(fn [^Connection conn]
(let [sql (describe-table-sql driver catalog schema table-name)]
- (log/tracef "Running statement in describe-table: %s" sql)
+ (log/tracef "Running statement in describe-table for %s.%s.%s" catalog schema table-name)
{:schema schema
:name table-name
:fields (into
@@ -661,7 +661,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting prepared statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting prepared statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
(sql-jdbc.execute/set-parameters! driver stmt params)
stmt
(catch Throwable e
@@ -677,7 +677,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
stmt))
(defn- pooled-conn->presto-conn
@@ -703,7 +703,7 @@
(try
(.setReadOnly conn read-only?)
(catch Throwable e
- (log/debugf e "Error setting connection read-only to %s" (pr-str read-only?)))))))
+ (log/debugf "Error setting connection read-only to %s: %s" (pr-str read-only?) (ex-message e)))))))
(defmethod sql-jdbc.execute/do-with-connection-with-options :presto-jdbc
[driver db-or-id-or-spec options f]
diff --git a/modules/drivers/redshift/src/metabase/driver/redshift.clj b/modules/drivers/redshift/src/metabase/driver/redshift.clj
index 5e507293515..a76788a7f74 100644
--- a/modules/drivers/redshift/src/metabase/driver/redshift.clj
+++ b/modules/drivers/redshift/src/metabase/driver/redshift.clj
@@ -497,7 +497,7 @@
(try
(.setHoldability conn ResultSet/CLOSE_CURSORS_AT_COMMIT)
(catch Throwable e
- (log/debug e "Error setting default holdability for connection"))))
+ (log/debugf "Error setting default holdability for connection: %s" (ex-message e)))))
(f conn))))
(defn- prepare-statement ^PreparedStatement [^Connection conn sql]
diff --git a/modules/drivers/snowflake/src/metabase/driver/snowflake.clj b/modules/drivers/snowflake/src/metabase/driver/snowflake.clj
index b271cfdf044..4404ab7217f 100644
--- a/modules/drivers/snowflake/src/metabase/driver/snowflake.clj
+++ b/modules/drivers/snowflake/src/metabase/driver/snowflake.clj
@@ -167,7 +167,7 @@
(keep (fn [param]
(let [key-val (str/split param #"=")]
(if-not (= 2 (count key-val))
- (log/warnf "Invalid Snowflake connection URI parameter: '%s'" param)
+ (log/warn "Invalid Snowflake connection URI parameter")
(let [[k v] key-val]
[(u/upper-case-en (URLDecoder/decode ^String k "UTF-8"))
(URLDecoder/decode ^String v "UTF-8")])))))
@@ -817,7 +817,7 @@
;; The Snowflake JDBC driver may throw for unsupported column types (e.g. UUID) during
;; DatabaseMetaData.getColumns() iteration. Fall back to SELECT * metadata which doesn't
;; hit the same code path. See #71595.
- (log/warnf e "Error reading JDBC metadata for table %s, falling back to SELECT * metadata" (:name table))
+ (log/warnf "Error reading JDBC metadata for table %s, falling back to SELECT * metadata: %s" (:name table) (ex-message e))
(mapv fix-base-type
(fallback-fields-metadata driver conn table database))))))
@@ -861,7 +861,7 @@
first
some?)
(catch SnowflakeSQLException e
- (log/warn e "Failed to check if table is dynamic")
+ (log/warnf "Failed to check if table is dynamic: %s" (ex-message e))
;; query will fail if schema doesn't exist
false)))
diff --git a/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj b/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj
index ec71e5431ae..a3d8e1fc5bc 100644
--- a/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj
+++ b/modules/drivers/sqlserver/src/metabase/driver/sqlserver.clj
@@ -968,7 +968,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
stmt
(catch Throwable e
(.close stmt)
diff --git a/modules/drivers/starburst/src/metabase/driver/starburst.clj b/modules/drivers/starburst/src/metabase/driver/starburst.clj
index f3635dff98c..562ff518914 100644
--- a/modules/drivers/starburst/src/metabase/driver/starburst.clj
+++ b/modules/drivers/starburst/src/metabase/driver/starburst.clj
@@ -457,8 +457,8 @@
;; included in trino-jdbc. We check the vendor-specific error code instead.
;; See HiveMetadata.java and UnknownTableTypeException.java in trinodb/trino
(when (= 133001 (.getErrorCode e))
- (log/debugf e "Table %s.%s is not accessible through this catalog (mixed catalog table type)"
- table-schema table-name))
+ (log/debugf "Table %s.%s is not accessible through this catalog (mixed catalog table type): %s"
+ table-schema table-name (ex-message e)))
false)))
(defn- describe-schema
@@ -508,7 +508,7 @@
[[schema name] comment])))
(jdbc/reducible-result-set rs {})))))
(catch Throwable e
- (log/debug e "Failed to read table comments from system.metadata.table_comments")
+ (log/debugf "Failed to read table comments from system.metadata.table_comments: %s" (ex-message e))
{}))))
(defmethod driver/describe-database* :starburst
@@ -607,7 +607,7 @@
(try
(.setReadOnly conn true)
(catch Throwable e
- (log/warn e "Error setting starburst connection to read-only")))
+ (log/warnf "Error setting starburst connection to read-only: %s" (ex-message e))))
;; as with statement and prepared-statement, cannot set holdability on the connection level
conn
(catch Throwable e
@@ -791,7 +791,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting prepared statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting prepared statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
(if (.useExplicitPrepare ^TrinoConnection (.unwrap conn TrinoConnection))
(proxy-prepared-statement driver conn stmt params)
(proxy-optimized-prepared-statement driver conn stmt params))
@@ -808,7 +808,7 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
(proxy [java.sql.Statement] []
(execute [sql]
(try
diff --git a/modules/drivers/vertica/src/metabase/driver/vertica.clj b/modules/drivers/vertica/src/metabase/driver/vertica.clj
index 958759e6469..4c0ace36a3b 100644
--- a/modules/drivers/vertica/src/metabase/driver/vertica.clj
+++ b/modules/drivers/vertica/src/metabase/driver/vertica.clj
@@ -294,7 +294,7 @@
(try (set (jdbc/query (sql-jdbc.conn/db->pooled-connection-spec database)
["SELECT TABLE_SCHEMA AS \"schema\", TABLE_NAME AS \"name\" FROM V_CATALOG.VIEWS;"]))
(catch Throwable e
- (log/error e "Failed to fetch materialized views for this database"))))
+ (log/errorf "Failed to fetch materialized views for this database: %s" (ex-message e)))))
(defmethod driver/describe-database* :vertica
[driver database]
@@ -317,7 +317,7 @@
(fn read-time []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs %d) [TIME] -> %s -> %s" i s t)
+ (log/tracef "(.getString rs %d) [TIME]" i)
t))))
(defmethod sql-jdbc.execute/read-column-thunk [:vertica Types/TIME_WITH_TIMEZONE]
@@ -325,7 +325,7 @@
(fn read-time-with-timezone []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs %d) [TIME_WITH_TIMEZONE] -> %s -> %s" i s t)
+ (log/tracef "(.getString rs %d) [TIME_WITH_TIMEZONE]" i)
t))))
;; for some reason vertica `TIMESTAMP WITH TIME ZONE` columns still come back as `Type/TIMESTAMP`, which seems like a
@@ -337,7 +337,7 @@
(fn read-timestamp []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s timezone)]
- (log/tracef "(.getString rs %d) [TIME_WITH_TIMEZONE] -> %s -> %s" i s t)
+ (log/tracef "(.getString rs %d) [TIME_WITH_TIMEZONE]" i)
t)))))
(defmethod sql.qp/->honeysql [:vertica ::sql.qp/cast-to-text]
diff --git a/resources/python-sources/sql_tools.py b/resources/python-sources/sql_tools.py
index a12f883dac4..1f799f6f4d7 100644
--- a/resources/python-sources/sql_tools.py
+++ b/resources/python-sources/sql_tools.py
@@ -1,7 +1,13 @@
import json
+import logging
import re
import sqlglot
+
+# sqlglot's parser warnings quote raw chunks of the SQL being parsed ("... contains unsupported
+# syntax. Falling back to parsing as a 'Command'."); silence them so customer SQL never reaches
+# stderr/server logs.
+logging.getLogger("sqlglot").setLevel(logging.CRITICAL)
import sqlglot.lineage as lineage
import sqlglot.optimizer as optimizer
import sqlglot.optimizer.qualify as qualify
diff --git a/src/metabase/actions/actions.clj b/src/metabase/actions/actions.clj
index f0215b4db44..d05c82fc30a 100644
--- a/src/metabase/actions/actions.clj
+++ b/src/metabase/actions/actions.clj
@@ -59,9 +59,9 @@
(methodical/defmethod perform-action!* :around :default
[action context inputs]
- (log/tracef "In action %s\nScope: %s\nInvocation stack:%s\nInputs: %s" action (:scope context) (:invocation-stack context) (pr-str inputs))
+ (log/tracef "In action %s\nScope: %s\nInvocation stack:%s" action (:scope context) (:invocation-stack context))
(u/prog1 (next-method action context inputs)
- (log/tracef "Out action %s: %s" action (pr-str <>))))
+ (log/tracef "Out action %s" action)))
(defn- known-implicit-actions
"Set of all known legacy actions."
@@ -187,7 +187,6 @@
(log/debug "Started perform action")
(actions.events/publish-action-invocation! action-kw context-before inputs)
(try
- (log/tracef "perform action inputs: %s" (pr-str inputs))
(u/prog1 (perform-action!* action-kw context-before inputs)
(let [{context-after :context, :keys [outputs]} <>]
(doseq [k [:invocation-id :invocation-stack :user-id]]
@@ -205,7 +204,7 @@
info (with-meta info (merge (meta info) {:exception e}))]
;; Need to think about how we learn about already performed effects this way, since we don't get a context.
(actions.events/publish-action-failure! action-kw context-before msg info)
- (log/error e "Failed to perform action")
+ (log/errorf "Failed to perform action: %s" (ex-message e))
(throw e))))))))
(defn perform-nested-action!
@@ -240,11 +239,6 @@
(assert table-id "Id cannot be nil")
(cached-database (:db_id (cached-value [:table-by-db-ids table-id] #(t2/select-one [:model/Table :db_id] table-id)))))
-(defn- log-before-after
- [level context before after]
- (log/logf level "%s %s => %s" context before after)
- after)
-
(mu/defn- check-permissions
[policy :- :keyword
arg-maps :- [:sequential [:or
@@ -281,8 +275,7 @@
(= "data-editing" (namespace action-kw)) :data-editing
:else :ad-hoc-invocation))
spec (actions.args/action-arg-map-schema action-kw)
- arg-maps (log-before-after :trace "normalize map" arg-maps
- (map (partial actions.args/normalize-action-arg-map action-kw) arg-maps))
+ arg-maps (map (partial actions.args/normalize-action-arg-map action-kw) arg-maps)
_ (actions.args/validate-inputs! action-kw arg-maps)
errors (for [arg-map arg-maps
:when (not (mr/validate spec arg-map))]
diff --git a/src/metabase/actions/execution.clj b/src/metabase/actions/execution.clj
index cc786467fa7..daf40ece3d5 100644
--- a/src/metabase/actions/execution.clj
+++ b/src/metabase/actions/execution.clj
@@ -35,14 +35,13 @@
[:model_id ::lib.schema.id/card]
[:dataset_query ::lib.schema/native-only-query]]
request-parameters]
- (log/tracef "Executing action\n\n%s" (u/pprint-to-str action))
+ (log/tracef "Executing action for model %d" model-id)
(driver.conn/with-write-connection
(try
(let [parameters (for [parameter (:parameters action)]
(assoc parameter :value (get request-parameters (:id parameter))))
query (-> query
(assoc :parameters parameters))]
- (log/debugf "Query (before preprocessing):\n\n%s" (u/pprint-to-str query))
(binding [qp.perms/*card-id* model-id]
(qp/execute-write-query! query)))
(catch Throwable e
@@ -75,7 +74,7 @@
:http
(http-action/execute-http-action! action request-parameters))
(catch Exception e
- (log/error e "Error executing action.")
+ (log/errorf "Error executing action: %s" (ex-message e))
(if-let [ed (ex-data e)]
(let [ed (cond-> ed
(and (nil? (:status-code ed))
diff --git a/src/metabase/actions/http_action.clj b/src/metabase/actions/http_action.clj
index 94d8c7df34e..1f6dbfef033 100644
--- a/src/metabase/actions/http_action.clj
+++ b/src/metabase/actions/http_action.clj
@@ -4,7 +4,6 @@
[clojure.string :as str]
[metabase.lib.core :as lib]
[metabase.query-processor.error-type :as qp.error-type]
- [metabase.util :as u]
[metabase.util.i18n :refer [tru]]
[metabase.util.json :as json]
[metabase.util.log :as log]
@@ -77,7 +76,7 @@
{\"bird_type\" \"Steller's Jay\"})
;; -> \"https://example.com/?filter=Steller's Jay\""
[parsed-template param->value]
- (log/tracef "Substituting params\n%s\nin template\n%s" (u/pprint-to-str param->value) (u/pprint-to-str parsed-template))
+ (log/trace "Substituting params in template")
(let [[sql missing] (try
(substitute* param->value parsed-template false)
(catch Throwable e
@@ -86,7 +85,6 @@
:params param->value
:parsed-query parsed-template}
e))))]
- (log/tracef "=>%s" sql)
(when (seq missing)
(throw (ex-info (tru "Cannot call the service: missing required parameters: {0}" (str/join ", " (set missing)))
{:type qp.error-type/missing-required-parameter
@@ -144,7 +142,7 @@
(select-keys [:body :headers :status])
(update :body json/decode))
error (json/decode (apply-json-query response (or (:error_handle action) ".status >= 400")))]
- (log/trace "Response before handle:" response)
+ (log/trace "Response status before handle:" (:status response))
(if error
{:status 400
:headers {"Content-Type" "application/json"}
diff --git a/src/metabase/activity_feed/events/recent_views.clj b/src/metabase/activity_feed/events/recent_views.clj
index 7e4af0d85cc..3adbd9e654e 100644
--- a/src/metabase/activity_feed/events/recent_views.clj
+++ b/src/metabase/activity_feed/events/recent_views.clj
@@ -21,7 +21,7 @@
user-id (or user-id api/*current-user-id*)]
(recent-views/update-users-recent-views! user-id :model/Dashboard model-id :view))
(catch Throwable e
- (log/warnf e "Failed to process recent_views event: %s" topic))))
+ (log/warnf "Failed to process recent_views event %s: %s" topic (ex-message e)))))
(derive ::table-read :metabase/event)
(derive :event/table-read ::table-read)
@@ -39,7 +39,7 @@
user-id (or user-id api/*current-user-id*)]
(recent-views/update-users-recent-views! user-id :model/Table model-id :view)))
(catch Throwable e
- (log/warnf e "Failed to process recent_views event: %s" topic)))))
+ (log/warnf "Failed to process recent_views event %s: %s" topic (ex-message e))))))
(derive ::card-query-event :metabase/event)
(derive :event/card-query ::card-query-event)
@@ -55,7 +55,7 @@
(not (t2/select-one-fn :document_id :model/Card :id card-id)))
(recent-views/update-users-recent-views! user-id :model/Card card-id :view)))
(catch Throwable e
- (log/warnf e "Failed to process recent_views event: %s" topic))))
+ (log/warnf "Failed to process recent_views event %s: %s" topic (ex-message e)))))
(derive ::card-create-with-result-metadata :metabase/event)
(derive :event/card-create-with-result-metadata ::card-create-with-result-metadata)
@@ -66,7 +66,7 @@
(try
(recent-views/update-users-recent-views! (or user-id api/*current-user-id*) :model/Card card-id :view)
(catch Throwable e
- (log/warnf e "Failed to process recent_views event: %s" topic))))
+ (log/warnf "Failed to process recent_views event %s: %s" topic (ex-message e)))))
(derive ::legacy-card-event :metabase/event)
;; in practice, updating or creating a card will immediately trigger a card-read
@@ -82,7 +82,7 @@
(try
(recent-views/update-users-recent-views! user-id :model/Card object-id :view)
(catch Throwable e
- (log/warnf e "Failed to process recent_views event: %s" topic))))))
+ (log/warnf "Failed to process recent_views event %s: %s" topic (ex-message e)))))))
(derive ::collection-touch-event :metabase/event)
(derive :event/collection-touch ::collection-touch-event)
@@ -93,4 +93,4 @@
(try
(recent-views/update-users-recent-views! (or user-id api/*current-user-id*) :model/Collection collection-id :view)
(catch Throwable e
- (log/warnf e "Failed to process recent_views event: %s" topic))))
+ (log/warnf "Failed to process recent_views event %s: %s" topic (ex-message e)))))
diff --git a/src/metabase/activity_feed/models/recent_views.clj b/src/metabase/activity_feed/models/recent_views.clj
index fe90c4a7824..998ff87e7c3 100644
--- a/src/metabase/activity_feed/models/recent_views.clj
+++ b/src/metabase/activity_feed/models/recent_views.clj
@@ -593,7 +593,7 @@
item
(when-not config/is-prod?
(log/errorf (colorize/red "Invalid recent view item: %s reason: %s")
- (pr-str item)
+ (pr-str (select-keys item [:id :model]))
(me/humanize (mr/explain Item item))))))
(mu/defn get-recents
diff --git a/src/metabase/agent_lib/representations/repair.clj b/src/metabase/agent_lib/representations/repair.clj
index 649802ba2d0..d9762889ff9 100644
--- a/src/metabase/agent_lib/representations/repair.clj
+++ b/src/metabase/agent_lib/representations/repair.clj
@@ -2262,8 +2262,8 @@
cols (lib/returned-columns lib-q)]
(column-descriptors cols))
(catch Exception e
- (log/debugf e "[repr-repair] mini-resolve of stages[0..%d] failed; skipping cross-stage type inference for stage %d"
- (dec stage-idx) stage-idx)
+ (log/debugf "[repr-repair] mini-resolve of stages[0..%d] failed; skipping cross-stage type inference for stage %d: %s"
+ (dec stage-idx) stage-idx (ex-message e))
nil)))
(defn- strip-surrounding-double-quotes
@@ -2385,8 +2385,8 @@
cols (lib/returned-columns lib-q)]
(column-descriptors cols))
(catch Exception e
- (log/debugf e "[repr-repair] source-card resolve of stage %d failed; skipping field-type inference"
- stage-idx)
+ (log/debugf "[repr-repair] source-card resolve of stage %d failed; skipping field-type inference: %s"
+ stage-idx (ex-message e))
nil)))))
(defn- infer-source-card-field-types*
diff --git a/src/metabase/agent_lib/representations/resolve.clj b/src/metabase/agent_lib/representations/resolve.clj
index 39028f68539..27cfb4a272d 100644
--- a/src/metabase/agent_lib/representations/resolve.clj
+++ b/src/metabase/agent_lib/representations/resolve.clj
@@ -259,5 +259,5 @@
(try
(export-query metadata-provider pmbql-query content-store)
(catch Exception e
- (log/warn e "Failed to export pMBQL query to portable representations; omitting from LLM payload")
+ (log/warnf "Failed to export pMBQL query to portable representations; omitting from LLM payload: %s" (ex-message e))
nil)))))
diff --git a/src/metabase/ai_tracing/log.clj b/src/metabase/ai_tracing/log.clj
index e8230f74a28..8f8acb47407 100644
--- a/src/metabase/ai_tracing/log.clj
+++ b/src/metabase/ai_tracing/log.clj
@@ -102,5 +102,5 @@
;; `Exception`, not `Throwable`, so JVM `Error`s and `InterruptedException` still propagate —
;; this runs in the span's `finally`, often on a tool virtual thread.
(catch Exception t
- (log/warn t "ai-tracing: failed to serialize/emit eval span"))))
+ (log/warnf "ai-tracing: failed to serialize/emit eval span: %s" (ex-message t)))))
nil)
diff --git a/src/metabase/analytics/api.clj b/src/metabase/analytics/api.clj
index 844b03535ab..96cd887bafe 100644
--- a/src/metabase/analytics/api.clj
+++ b/src/metabase/analytics/api.clj
@@ -40,4 +40,4 @@
:observe (prometheus/observe! metric labels (or amount 1))
:clear (prometheus/clear! metric))
(catch Exception e
- (log/warnf e "Failed to record internal analytics event %s %s" op metric)))))
+ (log/warnf "Failed to record internal analytics event %s %s: %s" op metric (ex-message e))))))
diff --git a/src/metabase/analytics/api/proxy.clj b/src/metabase/analytics/api/proxy.clj
index be362eee364..fcff4eb3347 100644
--- a/src/metabase/analytics/api/proxy.clj
+++ b/src/metabase/analytics/api/proxy.clj
@@ -40,5 +40,5 @@
:body (:body response)})
(catch Exception e
;; 502 is retryable by the tracker; a fake 2xx would silently drop the event.
- (log/errorf e "analytics-proxy failed forwarding to %s" collector-url)
+ (log/errorf "analytics-proxy failed forwarding to %s: %s" collector-url (ex-message e))
{:status 502 :body nil}))))
diff --git a/src/metabase/analytics/metaplow.clj b/src/metabase/analytics/metaplow.clj
index 8816b0710da..784f6e817d8 100644
--- a/src/metabase/analytics/metaplow.clj
+++ b/src/metabase/analytics/metaplow.clj
@@ -101,7 +101,7 @@
:connection-manager @connection-manager})
(catch Throwable e
(analytics/inc! :metabase-metaplow/errors {:stage :send-event!})
- (log/warn e "Connection failure sending Metaplow event")
+ (log/warnf "Connection failure sending Metaplow event: %s" (ex-message e))
{:status -1})))
(defn- retryable-response?
@@ -123,7 +123,7 @@
:sent
(catch Throwable e
(analytics/inc! :metabase-metaplow/errors {:stage :send-event-with-retries!})
- (log/warn e "Error sending Metaplow event")
+ (log/warnf "Error sending Metaplow event: %s" (ex-message e))
:error)))
(defonce ^:private
@@ -171,7 +171,7 @@
(enqueue! (build-payload schema data))
(catch Throwable e
(analytics/inc! :metabase-metaplow/errors {:stage :track-event!})
- (log/warn e "Error queueing Metaplow event")
+ (log/warnf "Error queueing Metaplow event: %s" (ex-message e))
false))))))
(comment
diff --git a/src/metabase/analytics/prometheus.clj b/src/metabase/analytics/prometheus.clj
index 40ebcd305bd..b6a3390ea6e 100644
--- a/src/metabase/analytics/prometheus.clj
+++ b/src/metabase/analytics/prometheus.clj
@@ -199,7 +199,7 @@
(swap! pull-collector-last-runs assoc id now)
(f)))
(catch Throwable e
- (log/warn e "Error running pull collector" id)))))
+ (log/warn "Error running pull collector" id (ex-message e))))))
[])]
(delay
(collector/named
@@ -991,7 +991,7 @@
(alter-var-root #'system (constantly nil))
(log/info "Prometheus web-server shut down")
(catch Exception e
- (log/warn e "Error stopping prometheus web-server")))))))
+ (log/warnf "Error stopping prometheus web-server: %s" (ex-message e))))))))
(defn observe!
"Call iapetos.core/observe on the metric in the global registry.
diff --git a/src/metabase/analytics/quartz.clj b/src/metabase/analytics/quartz.clj
index 1ff8bc20ab5..584245ff40f 100644
--- a/src/metabase/analytics/quartz.clj
+++ b/src/metabase/analytics/quartz.clj
@@ -33,7 +33,7 @@
:job-name (.. ctx getJobDetail getKey toString)}]
(analytics/inc! :metabase-tasks/quartz-tasks-executed tags))
(catch Throwable e
- (log/error e "Failed to record Prometheus metric for Quartz job completion"))))))
+ (log/errorf "Failed to record Prometheus metric for Quartz job completion: %s" (ex-message e)))))))
;; +----------------------------------------------------------------------------------------------------------------+
;; | Trigger Listener |
@@ -84,7 +84,7 @@
{:state state}
count))
(catch Throwable e
- (log/error e "Failed to record Prometheus metrics for Quartz trigger completion"))))))
+ (log/errorf "Failed to record Prometheus metrics for Quartz trigger completion: %s" (ex-message e)))))))
(defn add-listeners-to-scheduler!
"Add triggers to the quartz scheduler, must be initialized before adding."
diff --git a/src/metabase/analytics/sdk.clj b/src/metabase/analytics/sdk.clj
index 640fc4c07ce..dde9487ac3a 100644
--- a/src/metabase/analytics/sdk.clj
+++ b/src/metabase/analytics/sdk.clj
@@ -153,7 +153,7 @@
"embedding-simple" (analytics/inc! :metabase-embedding-simple/response {:status (str status)})
;; Known client, but a response-code counter tells us nothing actionable about data apps - so no metric.
"data-app" nil
- (log/infof "Unknown client. client: %s" sdk-client)))
+ (log/info "Unknown client.")))
(defn embedding-context?
"Should we track this request as being made by an embedding client?"
diff --git a/src/metabase/analytics/snowplow.clj b/src/metabase/analytics/snowplow.clj
index 394c79d244d..fe4e5c41897 100644
--- a/src/metabase/analytics/snowplow.clj
+++ b/src/metabase/analytics/snowplow.clj
@@ -164,5 +164,5 @@
(track-event-impl! tracker event)
true)
(catch Throwable e
- (log/errorf e "Error sending Snowplow analytics event for schema %s" schema)
+ (log/errorf "Error sending Snowplow analytics event for schema %s: %s" schema (ex-message e))
false))))))
diff --git a/src/metabase/analytics/stats.clj b/src/metabase/analytics/stats.clj
index 0d80f5f4318..703ed9ee6d4 100644
--- a/src/metabase/analytics/stats.clj
+++ b/src/metabase/analytics/stats.clj
@@ -530,7 +530,7 @@
(try
(http/post metabase-usage-url {:form-params stats, :content-type :json, :throw-entire-message? true})
(catch Throwable e
- (log/error e "Sending usage stats FAILED"))))
+ (log/errorf "Sending usage stats FAILED: %s" (ex-message e)))))
(defn- in-docker?
"Is the current Metabase process running in a Docker container?
diff --git a/src/metabase/analytics/task/send_anonymous_stats.clj b/src/metabase/analytics/task/send_anonymous_stats.clj
index 26213a9c2d9..f6de6b65355 100644
--- a/src/metabase/analytics/task/send_anonymous_stats.clj
+++ b/src/metabase/analytics/task/send_anonymous_stats.clj
@@ -18,7 +18,7 @@
;; TODO: add in additional request params if anonymous tracking is enabled
(analytics/phone-home-stats!)
(catch Throwable e
- (log/error e "Error sending anonymous usage stats")))))
+ (log/errorf "Error sending anonymous usage stats: %s" (ex-message e))))))
(def ^:private job-key "metabase.task.anonymous-stats.job")
(def ^:private trigger-key "metabase.task.anonymous-stats.trigger")
diff --git a/src/metabase/analyze/fingerprint/fingerprinters.clj b/src/metabase/analyze/fingerprint/fingerprinters.clj
index 9d74897b423..1a8ce98ca85 100644
--- a/src/metabase/analyze/fingerprint/fingerprinters.clj
+++ b/src/metabase/analyze/fingerprint/fingerprinters.clj
@@ -78,7 +78,7 @@
`(if sync-util/*log-exceptions-and-continue?*
(try ~form
(catch Throwable e#
- (metabase.util.log/warn e# ~msg)
+ (metabase.util.log/warn ~msg (ex-message e#))
(~action-on-exception e#)))
~form))
diff --git a/src/metabase/analyze/query_results.clj b/src/metabase/analyze/query_results.clj
index cfbee6872f1..1f11b960cf1 100644
--- a/src/metabase/analyze/query_results.clj
+++ b/src/metabase/analyze/query_results.clj
@@ -60,7 +60,7 @@
(try
(maybe-infer-semantic-type (col->ResultColumnMetadata col))
(catch Throwable e
- (log/errorf e "Error generating insights for column: %s" col)
+ (log/errorf "Error generating insights for column %s: %s" (pr-str (:name col)) (ex-message e))
col)))]
(redux/post-complete
(redux/juxt
diff --git a/src/metabase/api/common.clj b/src/metabase/api/common.clj
index 6e07698fe3a..2a7e99a8ed2 100644
--- a/src/metabase/api/common.clj
+++ b/src/metabase/api/common.clj
@@ -339,7 +339,7 @@
(try
(check-403 (mi/can-read? obj))
(catch clojure.lang.ExceptionInfo e
- (log/error e "Read permissions failure")
+ (log/errorf "Read permissions failure: %s" (ex-message e))
(events/publish-event! :event/read-permission-failure {:user-id *current-user-id*
:object obj
:has-access false})
diff --git a/src/metabase/api/docs.clj b/src/metabase/api/docs.clj
index 98622583ea4..010f891977c 100644
--- a/src/metabase/api/docs.clj
+++ b/src/metabase/api/docs.clj
@@ -46,7 +46,7 @@
(json/encode-to (sort-keys spec) (io/writer file) {:pretty true})
(log/info "OpenAPI specification written to" openapi-file-path))
(catch Throwable e
- (log/error e "Failed to write OpenAPI specification to file"))))
+ (log/errorf "Failed to write OpenAPI specification to file: %s" (ex-message e)))))
(defonce ^:private openapi-regen-state
(atom {:executing? false
@@ -77,7 +77,7 @@
;; Check if more requests came in while we were working
(recur)))
(catch Throwable e
- (log/error e "Error regenerating OpenAPI specification"))
+ (log/errorf "Error regenerating OpenAPI specification: %s" (ex-message e)))
(finally
(swap! openapi-regen-state assoc :executing? false))))))
@@ -91,7 +91,7 @@
(with-open [f (io/reader file)]
(json/decode+kw f))))
(catch Throwable e
- (log/error e "Failed to read OpenAPI specification from file")
+ (log/errorf "Failed to read OpenAPI specification from file: %s" (ex-message e))
nil)))
(defn- index-handler
diff --git a/src/metabase/api/macros.clj b/src/metabase/api/macros.clj
index 053eca8a43f..8426ee8ce53 100644
--- a/src/metabase/api/macros.clj
+++ b/src/metabase/api/macros.clj
@@ -794,7 +794,7 @@
{:api.docs/request-rebuild
(requiring-resolve 'metabase.api.docs/request-spec-regeneration!)})
(catch Throwable e
- (log/debug e "Failed to publish api-handler-update event"))))))
+ (log/debugf "Failed to publish api-handler-update event: %s" (ex-message e)))))))
(defn- quote-parsed-args
"Quote the appropriate parts of the parsed [[defendpoint]] args (body and param bindings) so they can be emitted in
diff --git a/src/metabase/api/routes/common.clj b/src/metabase/api/routes/common.clj
index 858961cc6d3..da99856e4eb 100644
--- a/src/metabase/api/routes/common.clj
+++ b/src/metabase/api/routes/common.clj
@@ -27,7 +27,7 @@
[handler]
(fn [request respond _raise]
(let [raise (fn [e]
- (log/warn e "Exception in API call")
+ (log/warnf "Exception in API call: %s" (ex-message e))
(if (= 404 (:status-code (ex-data e)))
(respond {:status 404, :body (deferred-tru "Not found.")})
(respond {:status 400, :body (deferred-tru "An error occurred.")})))]
@@ -43,7 +43,7 @@
[handler]
(fn [request respond _raise]
(let [raise (fn [^Throwable e]
- (log/error e "Exception in API call")
+ (log/errorf "Exception in API call: %s" (ex-message e))
(respond {:status 400, :body (ex-message e)}))]
(try
(handler request respond raise)
diff --git a/src/metabase/api_routes/events.clj b/src/metabase/api_routes/events.clj
index f38f73f124b..390deba0439 100644
--- a/src/metabase/api_routes/events.clj
+++ b/src/metabase/api_routes/events.clj
@@ -22,4 +22,4 @@
(rebuild-fn routes/routes)
(log/debug "No build function provided to rebuild OpenAPI docs"))
(catch Throwable e
- (log/debug e "Failed to trigger OpenAPI regeneration"))))
+ (log/debugf "Failed to trigger OpenAPI regeneration: %s" (ex-message e)))))
diff --git a/src/metabase/app_db/connection.clj b/src/metabase/app_db/connection.clj
index e6496400b0a..55d3dfc13e4 100644
--- a/src/metabase/app_db/connection.clj
+++ b/src/metabase/app_db/connection.clj
@@ -191,7 +191,7 @@
*after-commit-callbacks* nil]
(doseq [thunk @callbacks]
;; the transaction already committed; a failing callback must not unwind it
- (try (thunk) (catch Throwable t (log/error t "after-commit callback failed"))))
+ (try (thunk) (catch Throwable t (log/errorf "after-commit callback failed: %s" (ex-message t)))))
(reset! callbacks [])))
(defn- discard-callbacks-after!
@@ -254,7 +254,7 @@
(try
(.setAutoCommit connection true)
(catch Throwable t
- (log/warn t "Failed to reset the connection's autocommit flag to true")))))
+ (log/warnf "Failed to reset the connection's autocommit flag to true: %s" (ex-message t))))))
(thunk))))
(comment
diff --git a/src/metabase/app_db/custom_migrations.clj b/src/metabase/app_db/custom_migrations.clj
index 1ca8956e058..0e53c8f2685 100644
--- a/src/metabase/app_db/custom_migrations.clj
+++ b/src/metabase/app_db/custom_migrations.clj
@@ -125,7 +125,7 @@
(try
(json/decode s keywordize-keys?)
(catch Throwable e
- (log/error e "Error parsing JSON")
+ (log/errorf "Error parsing JSON: %s" (ex-message e))
s))
s))
@@ -142,8 +142,8 @@
(catch Throwable e
(if (or (encryption/possibly-encrypted-string? decrypted)
(encryption/possibly-encrypted-bytes? decrypted))
- (log/error e "Could not decrypt encrypted field! Have you forgot to set MB_ENCRYPTION_SECRET_KEY?")
- (log/error e "Error parsing JSON")) ; same message as in `json-out`
+ (log/errorf "Could not decrypt encrypted field! Have you forgot to set MB_ENCRYPTION_SECRET_KEY?: %s" (ex-message e))
+ (log/errorf "Error parsing JSON: %s" (ex-message e))) ; same message as in `json-out`
v))))
;;; +----------------------------------------------------------------------------------------------------------------+
diff --git a/src/metabase/app_db/jdbc_protocols.clj b/src/metabase/app_db/jdbc_protocols.clj
index 9b09a758ffe..6640fb683be 100644
--- a/src/metabase/app_db/jdbc_protocols.clj
+++ b/src/metabase/app_db/jdbc_protocols.clj
@@ -158,7 +158,7 @@
(.getObject rs i LocalTime)
(catch Throwable _
(when-let [s (.getString rs i)]
- (log/tracef "Error in Postgres JDBC driver reading TIME value, fetching as string '%s'" s)
+ (log/trace "Error in Postgres JDBC driver reading TIME value, fetching as string")
(u.date/parse s))))
;; H2 & MySQL work as expected
diff --git a/src/metabase/app_db/liquibase.clj b/src/metabase/app_db/liquibase.clj
index 471a009f0be..4afbb4f4467 100644
--- a/src/metabase/app_db/liquibase.clj
+++ b/src/metabase/app_db/liquibase.clj
@@ -227,7 +227,7 @@
(when (= (mdb.connection/db-type) :h2)
(force-release-locks! liquibase))
(catch Exception e
- (log/error e "Unable to release the Liquibase lock")))))
+ (log/errorf "Unable to release the Liquibase lock: %s" (ex-message e))))))
(defn- lock-service ^LockService [^Liquibase liquibase]
(.getLockService (LockServiceFactory/getInstance) (.getDatabase liquibase)))
@@ -589,7 +589,7 @@
(let [change-listener (proxy [liquibase.changelog.visitor.AbstractChangeExecListener] []
(rollbackFailed [^ChangeSet change-set _dbchangelog _db ^Exception e]
(swap! error-ids conj (.getId change-set))
- (log/errorf e "Error rolling back migration %s" (.getId change-set))))]
+ (log/errorf "Error rolling back migration %s: %s" (.getId change-set) (ex-message e))))]
(AbstractRollbackCommandStep/doRollback lb-db
changelog-file
nil
diff --git a/src/metabase/app_db/query.clj b/src/metabase/app_db/query.clj
index 5383196c3a8..70c019adfe8 100644
--- a/src/metabase/app_db/query.clj
+++ b/src/metabase/app_db/query.clj
@@ -24,7 +24,6 @@
[honey.sql :as sql]
[metabase.app-db.format :as app-db.format]
[metabase.util :as u]
- [metabase.util.log :as log]
[metabase.util.malli :as mu]
[metabase.util.malli.schema :as ms]
[toucan2.core :as t2]
@@ -115,9 +114,6 @@
(throw (ex-info (str "Error compiling Honey SQL: " (ex-message e))
{:honey-sql honey-sql}
e))))]
- (log/tracef "Compiled SQL:\n%s\nparameters: %s"
- (app-db.format/format-sql (first sql-args))
- (pr-str (rest sql-args)))
sql-args))
;;; TODO -- we should mark this deprecated and tell people to use [[toucan2.core/query]] directly instead
diff --git a/src/metabase/app_db/setup.clj b/src/metabase/app_db/setup.clj
index 3cfe612ab26..25f80d4146c 100644
--- a/src/metabase/app_db/setup.clj
+++ b/src/metabase/app_db/setup.clj
@@ -198,7 +198,7 @@
NOTE: the encryption-check setting is not managed like most settings with 'defsetting' so we can manage checking the raw values in the database"
[]
(let [raw (try (t2/select-one-fn :value :setting :key "encryption-check")
- (catch Throwable e (log/warn e "Error checking encryption status, assuming unencrypted")))
+ (catch Throwable e (log/warnf "Error checking encryption status, assuming unencrypted: %s" (ex-message e))))
looks-encrypted (not= raw "unencrypted")]
(log/debug "Checking encryption configuration")
(when-not (nil? raw)
diff --git a/src/metabase/app_db/update_h2.clj b/src/metabase/app_db/update_h2.clj
index a0cf7382631..6b19ff74afe 100644
--- a/src/metabase/app_db/update_h2.clj
+++ b/src/metabase/app_db/update_h2.clj
@@ -104,5 +104,5 @@
(try
(update! jdbc-url)
(catch Exception e
- (log/error e "Failed to update H2 database:")
+ (log/errorf "Failed to update H2 database: %s" (ex-message e))
(throw e)))))))
diff --git a/src/metabase/audit_app/task/truncate_audit_tables.clj b/src/metabase/audit_app/task/truncate_audit_tables.clj
index b24607a193e..bfea6734d7d 100644
--- a/src/metabase/audit_app/task/truncate_audit_tables.clj
+++ b/src/metabase/audit_app/task/truncate_audit_tables.clj
@@ -59,7 +59,7 @@
(log/infof "%s cleanup successful, %d rows were deleted" table-name total-rows-deleted)
(log/infof "%s cleanup successful, no rows were deleted" table-name)))))
(catch Throwable e
- (log/errorf e "%s cleanup failed" table-name)))))))
+ (log/errorf "%s cleanup failed: %s" table-name (ex-message e))))))))
(defenterprise audit-models-to-truncate
"List of models to truncate. OSS implementation only truncates `query_execution` table."
diff --git a/src/metabase/auth_identity/providers/emailed_secret.clj b/src/metabase/auth_identity/providers/emailed_secret.clj
index b42dbfc4104..78b5622350d 100644
--- a/src/metabase/auth_identity/providers/emailed_secret.clj
+++ b/src/metabase/auth_identity/providers/emailed_secret.clj
@@ -172,7 +172,7 @@
:error :invalid-token
:message "Invalid token format"})
(catch Exception e
- (log/error e "Unexpected error during reset token verification")
+ (log/errorf "Unexpected error during reset token verification: %s" (ex-message e))
{:success? false
:error :server-error
:message "An unexpected error occurred during token verification"}))))
diff --git a/src/metabase/auth_identity/providers/password.clj b/src/metabase/auth_identity/providers/password.clj
index b74f8a7c70a..d569f82697e 100644
--- a/src/metabase/auth_identity/providers/password.clj
+++ b/src/metabase/auth_identity/providers/password.clj
@@ -61,7 +61,7 @@
:error :invalid-credentials
:message \"...\"}"
[_provider {:keys [email password] :as _request}]
- (log/debugf "Authenticating with password provider for email: %s" email)
+ (log/debug "Authenticating with password provider")
(cond
(not email)
diff --git a/src/metabase/channel/api/slack.clj b/src/metabase/channel/api/slack.clj
index 09e99bb1e98..cc158cfae44 100644
--- a/src/metabase/channel/api/slack.clj
+++ b/src/metabase/channel/api/slack.clj
@@ -218,7 +218,7 @@
:app_id)
(catch Exception e
;; bots.info requires users:read scope which may not be present
- (log/warn e "Failed to fetch app_id from bots.info (may require users:read scope)")
+ (log/warnf "Failed to fetch app_id from bots.info (may require users:read scope): %s" (ex-message e))
nil)))
scopes-header (get-in auth-response [:metabase.channel.slack/headers "x-oauth-scopes"])
actual-scopes (if (str/blank? scopes-header)
diff --git a/src/metabase/channel/email.clj b/src/metabase/channel/email.clj
index 61375683b9b..8ef7fe19472 100644
--- a/src/metabase/channel/email.clj
+++ b/src/metabase/channel/email.clj
@@ -57,8 +57,7 @@
(throttle/check email-throttler true))
(catch Exception _e
(log/warn "Email throttling is enabled and the number of recipients exceeds the rate limit per second. Skip throttling."
- {:email-subject (:subject email)
- :recipients (count recipients)
+ {:recipients (count recipients)
:max-recipients throttle-threshold})))))))
(defn partition-recipients
@@ -212,7 +211,7 @@
(try
(send-email-retrying! msg-args)
(catch Throwable e
- (log/warn e "Failed to send email")
+ (log/warnf "Failed to send email: %s" (ex-message e))
{::error e})))
(def ^:private SMTPSettings
@@ -245,7 +244,7 @@
(.connect transport host port user pass)))
{::error nil}
(catch Throwable e
- (log/error e "Error testing SMTP connection")
+ (log/errorf "Error testing SMTP connection: %s" (ex-message e))
{::error e})))
(def ^:private email-security-order [:tls :starttls :ssl])
diff --git a/src/metabase/channel/email/messages.clj b/src/metabase/channel/email/messages.clj
index f86216f0530..0bed31e534f 100644
--- a/src/metabase/channel/email/messages.clj
+++ b/src/metabase/channel/email/messages.clj
@@ -397,7 +397,7 @@
:message (channel.template/render template-name template-context)
:bcc? bcc?})
(catch Exception e
- (log/errorf e "Failed to send message to '%s' with subject '%s'" (str/join ", " recipients) subject))))))
+ (log/errorf "Failed to send message to %d recipient(s): %s" (count recipients) (ex-message e)))))))
(defn- send-email!
"Sends an email on a background thread, returning a future."
diff --git a/src/metabase/channel/impl/email.clj b/src/metabase/channel/impl/email.clj
index 5ef86aa6acd..4278dd21aed 100644
--- a/src/metabase/channel/impl/email.clj
+++ b/src/metabase/channel/impl/email.clj
@@ -135,7 +135,7 @@
:email/handlebars-text
(do
- (log/debugf "Rendering user-provided template body=%s" (pr-str (:body details)))
+ (log/debug "Rendering user-provided template body")
(handlebars/render-string (:body details) payload))
(do
@@ -296,7 +296,7 @@
:content (.. temp-file toURI toURL)
:description (format "PDF of dashboard '%s'" (or dashboard-name "dashboard"))})
(catch Throwable e
- (log/error e "Error rendering dashboard subscription PDF; skipping PDF attachment")
+ (log/errorf "Error rendering dashboard subscription PDF; skipping PDF attachment: %s" (ex-message e))
nil)))
(mu/defmethod channel/render-notification [:channel/email :notification/dashboard] :- [:sequential EmailMessage]
@@ -328,7 +328,7 @@
(when-not attachment_only
(conj html-contents (html content)))])
(catch Throwable e
- (log/error e "Error rendering dashboard subscription part; substituting error placeholder")
+ (log/errorf "Error rendering dashboard subscription part; substituting error placeholder: %s" (ex-message e))
[merged-attachments
result-attachments
(when-not attachment_only
diff --git a/src/metabase/channel/impl/slack.clj b/src/metabase/channel/impl/slack.clj
index cc984bd1ccf..e989f21e76a 100644
--- a/src/metabase/channel/impl/slack.clj
+++ b/src/metabase/channel/impl/slack.clj
@@ -57,7 +57,7 @@
(format "*%s*\n%s" (:name parameter) (shared.params/value-string parameter (system/site-locale)))
attachment-text-length-limit)
(catch Throwable e
- (log/errorf e "Error rendering filter %s; skipping it" (:name parameter)))))
+ (log/errorf "Error rendering filter %s; skipping it: %s" (:id parameter) (ex-message e)))))
(defn- parameter-fields
[parameters]
@@ -161,7 +161,7 @@
(try
(slack/upload-file-to-channel! (:bytes pdf) (:filename pdf) channel (:comment pdf))
(catch Throwable e
- (log/error e "Error sharing dashboard subscription PDF to Slack; posting summary without the PDF")
+ (log/errorf "Error sharing dashboard subscription PDF to Slack; posting summary without the PDF: %s" (ex-message e))
(when (:comment pdf)
(slack/post-chat-message! {:channel channel :text (:comment pdf)}))))))
@@ -275,7 +275,7 @@
(or "dashboard")
(str ".pdf"))})
(catch Throwable e
- (log/error e "Error rendering dashboard subscription PDF for Slack; skipping PDF attachment")
+ (log/errorf "Error rendering dashboard subscription PDF for Slack; skipping PDF attachment: %s" (ex-message e))
nil)))
(mu/defmethod channel/render-notification [:channel/slack :notification/dashboard] :- [:sequential SlackMessage]
@@ -298,7 +298,7 @@
(try
(part->sections! all-params part)
(catch Throwable e
- (log/error e "Error rendering dashboard subscription part for Slack; substituting error placeholder")
+ (log/errorf "Error rendering dashboard subscription part for Slack; substituting error placeholder: %s" (ex-message e))
[(text->markdown-section (str (tru "An error occurred while displaying this card.")))])))
(:dashboard_parts payload))]
flatten
diff --git a/src/metabase/channel/models/channel.clj b/src/metabase/channel/models/channel.clj
index 827dd66a3af..b7648e702fb 100644
--- a/src/metabase/channel/models/channel.clj
+++ b/src/metabase/channel/models/channel.clj
@@ -150,21 +150,12 @@
[channel-template]
(mu/validate-throw ::ChannelTemplate channel-template))
-(defn- user-provided-template?
- "Returns true if the template details represent a user-provided inline template (handlebars-text)
- as opposed to a built-in resource template."
- [details]
- (= :email/handlebars-text (keyword (:type details))))
-
(defn- log-template-change!
"Log template creation or update with relevant details for observability."
[action {:keys [channel_type details] :as _instance}]
(let [template-type (keyword (:type details))]
- (if (user-provided-template? details)
- (log/infof "ChannelTemplate %s: channel_type=%s template_type=%s user_id=%s body=%s"
- (name action) channel_type template-type api/*current-user-id* (pr-str (:body details)))
- (log/infof "ChannelTemplate %s: channel_type=%s template_type=%s user_id=%s"
- (name action) channel_type template-type api/*current-user-id*))
+ (log/infof "ChannelTemplate %s: channel_type=%s template_type=%s user_id=%s"
+ (name action) channel_type template-type api/*current-user-id*)
(analytics/inc! (case action
:create :metabase-notification/template-create
:update :metabase-notification/template-update)
diff --git a/src/metabase/channel/render/body.clj b/src/metabase/channel/render/body.clj
index f25fac11753..8b485593b29 100644
--- a/src/metabase/channel/render/body.clj
+++ b/src/metabase/channel/render/body.clj
@@ -740,7 +740,7 @@
(when-let [content (pivot-table-content card dashcard data)]
{:content content :attachments nil})
(catch Throwable e
- (log/warn e "Failed to render pivot table; falling back to a flat table")
+ (log/warnf "Failed to render pivot table; falling back to a flat table: %s" (ex-message e))
nil))
;; Native pivots, field-ref splits, or assembly errors degrade to the existing flat table.
(render :table render-type timezone-id card dashcard data)))
diff --git a/src/metabase/channel/render/card.clj b/src/metabase/channel/render/card.clj
index 632d1583007..ebcdef16e18 100644
--- a/src/metabase/channel/render/card.clj
+++ b/src/metabase/channel/render/card.clj
@@ -138,14 +138,14 @@
(defn detect-pulse-chart-type
"Determine the pulse (visualization) type of a `card`, e.g. `:scalar` or `:bar`."
- [{display-type :display card-name :name :as card} maybe-dashcard {:keys [cols rows] :as data}]
+ [{display-type :display :as card} maybe-dashcard {:keys [cols rows] :as data}]
(let [col-sample-count (delay (count (take 3 cols)))
row-sample-count (delay (count (take 2 rows)))
display-type (or (render.util/visualizer-display-type maybe-dashcard) display-type)
map-type (map-chart-type display-type card maybe-dashcard data)]
(letfn [(chart-type [tyype reason & args]
(log/tracef "Detected chart type %s for Card %s because %s"
- tyype (pr-str card-name) (apply format reason args))
+ tyype (:id card) (apply format reason args))
tyype)]
(cond
(or (empty? rows)
@@ -228,10 +228,10 @@
(:card-error data)
(do
- (log/error e "Pulse card query error")
+ (log/errorf "Pulse card query error: %s" (ex-message e))
(body/render :card-error nil nil nil nil nil))
:else (do
- (log/error e "Pulse card render error")
+ (log/errorf "Pulse card render error: %s" (ex-message e))
(body/render :render-error nil nil nil nil nil)))))))
(mu/defn error-rendered-part :- ::body/RenderedPartCard
diff --git a/src/metabase/channel/render/maps.clj b/src/metabase/channel/render/maps.clj
index 16ad63b0ed8..6ae043a72cb 100644
--- a/src/metabase/channel/render/maps.clj
+++ b/src/metabase/channel/render/maps.clj
@@ -110,7 +110,7 @@
(try
(fetch-tile* template z x y)
(catch Throwable e
- (log/warn e "Failed to fetch map tile")
+ (log/warnf "Failed to fetch map tile: %s" (ex-message e))
nil)))
;;; ------------------------------------------------ color (HCL) ------------------------------------------------
@@ -260,7 +260,7 @@
(.toByteArray out))
;; Return nil on failure so the caller can degrade to a table rather than email a blank/partial map.
(catch Throwable e
- (log/warn e "Failed to render map")
+ (log/warnf "Failed to render map: %s" (ex-message e))
nil)
(finally
(.dispose g)))))
diff --git a/src/metabase/channel/render/pdf.clj b/src/metabase/channel/render/pdf.clj
index 6653a2eba05..b1824603709 100644
--- a/src/metabase/channel/render/pdf.clj
+++ b/src/metabase/channel/render/pdf.clj
@@ -1401,7 +1401,7 @@
#(draw-markdown-in-cell! doc cs x top-y cell-w % (:align-h cell) (:align-v cell) (:text cell)))
nil)
(catch Throwable e
- (log/error e "Error rendering dashboard PDF cell; substituting placeholder")
+ (log/errorf "Error rendering dashboard PDF cell; substituting placeholder: %s" (ex-message e))
(draw-text-block! cs (font/face :regular) 10.0 nil x top-y cell-w cell-h
"[Unable to render this card]")))))
(finally
@@ -1513,7 +1513,7 @@
(try
(run! #(some-> % :result :data :rows notification.payload/cleanup!) parts)
(catch Throwable e
- (log/warn e "Error cleaning up temp files for dashboard PDF"))))))))))
+ (log/warnf "Error cleaning up temp files for dashboard PDF: %s" (ex-message e)))))))))))
(defn render-dashboard-to-pdf-file
"Convenience wrapper for the REPL: render the dashboard to PDF and write it to `path`."
diff --git a/src/metabase/channel/render/png.clj b/src/metabase/channel/render/png.clj
index f9004ab236c..3de8f847872 100644
--- a/src/metabase/channel/render/png.clj
+++ b/src/metabase/channel/render/png.clj
@@ -182,5 +182,5 @@
(write-image! "png" os))
(.toByteArray os)))
(catch Throwable e
- (log/error e "Error rendering Pulse")
+ (log/errorf "Error rendering Pulse: %s" (ex-message e))
(throw e)))))
diff --git a/src/metabase/channel/render/style.clj b/src/metabase/channel/render/style.clj
index d3d7ad0a891..e73fa479eb4 100644
--- a/src/metabase/channel/render/style.clj
+++ b/src/metabase/channel/render/style.clj
@@ -200,7 +200,7 @@
" "
(trs "This is a known issue with certain JVMs. See {0} and for more details."
"https://github.com/metabase/metabase/issues/7986"))]
- (log/error e message)
+ (log/error message (ex-message e))
(throw (ex-info message {} e))))))
(defonce ^{:doc "Makes custom fonts available to Java so that CSSBox can render them."
diff --git a/src/metabase/channel/render/util.clj b/src/metabase/channel/render/util.clj
index f314a80d507..94f7beb8e30 100644
--- a/src/metabase/channel/render/util.clj
+++ b/src/metabase/channel/render/util.clj
@@ -235,7 +235,7 @@
:let [value-str (try
(shared.params/value-string param locale)
(catch Throwable e
- (log/errorf e "Error rendering filter %s; skipping it" name)))]
+ (log/errorf "Error rendering filter %s; skipping it: %s" (:id param) (ex-message e))))]
:when value-str]
[:div
{:style (style/style {:margin-bottom "4px"})}
diff --git a/src/metabase/channel/shared.clj b/src/metabase/channel/shared.clj
index 1bc5a256c8b..21572214bcb 100644
--- a/src/metabase/channel/shared.clj
+++ b/src/metabase/channel/shared.clj
@@ -78,7 +78,7 @@
(subs s 1))]
(format "Run %s %s" s (schedule-timezone)))
(catch Exception e
- (log/errorf e "Failed to parse cron expression: %s" cron-string)
+ (log/errorf "Failed to parse cron expression %s: %s" cron-string (ex-message e))
nil)))
(defn friendly-cron-description
diff --git a/src/metabase/channel/slack.clj b/src/metabase/channel/slack.clj
index 73d40f5af43..6a75849fe2f 100644
--- a/src/metabase/channel/slack.clj
+++ b/src/metabase/channel/slack.clj
@@ -64,7 +64,7 @@
(channel.settings/unobfuscated-slack-app-token))]
(when token
(let [url (str "https://slack.com/api/" (name endpoint))
- _ (log/tracef "Slack API request: %s %s" (pr-str url) (pr-str request))
+ _ (log/tracef "Slack API request: %s" (pr-str url))
request (m/deep-merge
{:headers {:authorization (str "Bearer\n" token)}
:as :stream
@@ -324,7 +324,7 @@
(try
(POST "conversations.join" {:query-params {:channel channel-id}})
(catch Throwable e
- (log/warnf e "Could not join Slack channel %s; a file share may fail" channel-id))))
+ (log/warnf "Could not join Slack channel %s; a file share may fail: %s" channel-id (ex-message e)))))
(def ^:private slack-user-id-pattern
"Slack user IDs start with U (people) or W (Enterprise Grid). They are rejected by `files.completeUploadExternal`'s
diff --git a/src/metabase/channel/template/handlebars.clj b/src/metabase/channel/template/handlebars.clj
index c7d3c926559..5257006918d 100644
--- a/src/metabase/channel/template/handlebars.clj
+++ b/src/metabase/channel/template/handlebars.clj
@@ -68,7 +68,7 @@
(log/debug "Reloading handlebars default helpers")
(handlebars-helper/register-helpers @default-hbs new-default-helpers)
(catch Exception e
- (log/warn e "Error reloading default helpers"))))))
+ (log/warnf "Error reloading default helpers: %s" (ex-message e)))))))
(defn valid-template-name?
"True iff `template-name` is a well-formed relative template name: non-blank,
diff --git a/src/metabase/cmd/copy.clj b/src/metabase/cmd/copy.clj
index a3e646a0433..cf2725d7b88 100644
--- a/src/metabase/cmd/copy.clj
+++ b/src/metabase/cmd/copy.clj
@@ -176,7 +176,7 @@
(let [{:keys [cols vals]} (objects->columns+values target-db-type chunkk)]
(jdbc/insert-multi! target-db-conn-spec table-name cols vals {:transaction? false}))
(catch SQLException e
- (log/error (with-out-str (jdbc/print-sql-exception-chain e)))
+ (log/errorf "Error inserting chunk: %s" (ex-message e))
(throw e))))
(def ^:dynamic *copy-h2-database-details*
@@ -354,7 +354,6 @@
(let [save-point (.setSavepoint conn)]
(try
(letfn [(add-batch! [^String sql]
- (log/debug (u/colorize :yellow sql))
(.addBatch stmt sql))]
;; do these in reverse order so child rows get deleted before parents
(doseq [table-name (map t2/table-name (reverse entities))]
diff --git a/src/metabase/cmd/core.clj b/src/metabase/cmd/core.clj
index 6ba4504459f..b507f9103dd 100644
--- a/src/metabase/cmd/core.clj
+++ b/src/metabase/cmd/core.clj
@@ -90,7 +90,7 @@
(println "Dump complete")
(system-exit! 0))
(catch Throwable e
- (log/error e "Failed to dump application database to H2 file")
+ (log/errorf "Failed to dump application database to H2 file: %s" (ex-message e))
(system-exit! 1))))
(defn ^:command reset-password
@@ -218,7 +218,7 @@
(log/info "Encryption key rotation OK.")
(system-exit! 0)
(catch Throwable e
- (log/error e "ERROR ROTATING KEY.")
+ (log/errorf "ERROR ROTATING KEY: %s" (ex-message e))
(system-exit! 1))))
(defn ^:command remove-encryption
@@ -234,7 +234,7 @@
(log/info "Encryption removed OK.")
(system-exit! 0)
(catch Throwable e
- (log/error e "ERROR REMOVING ENCRYPTION.")
+ (log/errorf "ERROR REMOVING ENCRYPTION: %s" (ex-message e))
(system-exit! 1))))
;;; ------------------------------------------------ Validate Commands ----------------------------------------------
diff --git a/src/metabase/core/core.clj b/src/metabase/core/core.clj
index 19b5de88d22..9eb2a7f66f5 100644
--- a/src/metabase/core/core.clj
+++ b/src/metabase/core/core.clj
@@ -134,7 +134,7 @@
(try
(.handle original-handler sig)
(catch Exception e
- (log/errorf e "Error calling original signal handler for SIG%s" signal-name)))))))
+ (log/errorf "Error calling original signal handler for SIG%s: %s" signal-name (ex-message e))))))))
(defn- init-signal-logging!
"Set up signal handlers to log system signals like SIGTERM, SIGINT, etc."
@@ -155,13 +155,13 @@
(catch IllegalArgumentException e
(log/debugf "Ignoring invalid signal SIG%s: %s" signal-name (.getMessage e)))
(catch Exception e
- (log/warnf e "Failed to register signal handler for SIG%s" signal-name))))))
+ (log/warnf "Failed to register signal handler for SIG%s: %s" signal-name (ex-message e)))))))
(defn- init!*
"General application initialization function which should be run once at application startup."
[]
(log/infof "Starting Metabase version %s ..." config/mb-version-string)
- (log/infof "System info:\n %s" (u/pprint-to-str (u.system-info/system-info)))
+ (log/infof "System info:\n %s" (pr-str (u.system-info/system-info)))
(perf/maybe-enable-monitoring!)
(init-signal-logging!)
(init-status/set-progress! 0.1)
@@ -271,7 +271,7 @@
(when (config/config-bool :mb-jetty-join)
(.join (server/instance)))
(catch Throwable e
- (log/error e "Metabase Initialization FAILED")
+ (log/errorf "Metabase Initialization FAILED: %s" (ex-message e))
(System/exit 1))))
(defn- run-cmd [cmd init-fn args]
diff --git a/src/metabase/core/perf.clj b/src/metabase/core/perf.clj
index d8f65c378a5..a5f11c8a0c4 100644
--- a/src/metabase/core/perf.clj
+++ b/src/metabase/core/perf.clj
@@ -125,7 +125,7 @@
(reset! recording-atom new-recording)
(log/infof "Performance info written to: %s" (str output-file)))
(catch Throwable e
- (log/warn e "Error during rolling performance dump"))))
+ (log/warnf "Error during rolling performance dump: %s" (ex-message e)))))
interval-minutes
interval-minutes
TimeUnit/MINUTES)
@@ -159,7 +159,7 @@
(start-periodic-dump! recording output-path (save-rate-minutes 5))
(log/infof "Performance monitoring started. Output file: %s" (str output-path)))))))
(catch Throwable e
- (log/warn e "Failed to start performance monitoring"))))
+ (log/warnf "Failed to start performance monitoring: %s" (ex-message e)))))
(defn stop-monitoring!
"Stops and closes the JFR recording if one is active."
@@ -180,4 +180,4 @@
(reset! recording-atom nil)
(log/info "Performance monitoring stopped")
(catch Throwable e
- (log/warn e "Error stopping performance monitoring")))))
+ (log/warnf "Error stopping performance monitoring: %s" (ex-message e))))))
diff --git a/src/metabase/dashboards_rest/api.clj b/src/metabase/dashboards_rest/api.clj
index 6650ec5ab3a..06eccaabf07 100644
--- a/src/metabase/dashboards_rest/api.clj
+++ b/src/metabase/dashboards_rest/api.clj
@@ -233,7 +233,7 @@
[(qp.util/query-hash query)
(qp.util/query-hash (assoc query :constraints (qp.constraints/default-query-constraints)))]
(catch Throwable e
- (log/errorf e "Error hashing query %s: %s" (pr-str query) (ex-message e))
+ (log/errorf "Error hashing query: %s" (ex-message e))
nil))))
(defn- dashcard->query-hashes
diff --git a/src/metabase/data_studio/api/table.clj b/src/metabase/data_studio/api/table.clj
index 289557ccf8b..dd9dd251b47 100644
--- a/src/metabase/data_studio/api/table.clj
+++ b/src/metabase/data_studio/api/table.clj
@@ -159,8 +159,8 @@
(doseq [table tables]
(log/info (u/format-color :green "Table '%s' is now visible. Resyncing." (:name table)))
(sync/sync-table! table))
- (log/warn (u/format-color :red "Cannot connect to database '%s' in order to sync unhidden tables"
- (:name database))))))))))
+ (log/warn (u/format-color :red "Cannot connect to database %s in order to sync unhidden tables"
+ (:id database))))))))))
(defn- maybe-sync-unhidden-tables!
[existing-tables {:keys [data_layer] :as body}]
@@ -246,7 +246,7 @@
(driver.u/can-connect-with-details? (:engine database) (:details database) :throw-exceptions))
nil
(catch Throwable e
- (log/warn (u/format-color :red "Cannot connect to database '%s' in order to sync tables" (:name database)))
+ (log/warn (u/format-color :red "Cannot connect to database %s in order to sync tables" (:id database)))
(throw (ex-info (ex-message e) {:status-code 422})))))
(doseq [table tables]
(sync-schema-async! table api/*current-user-id*))))
diff --git a/src/metabase/documents/view_log.clj b/src/metabase/documents/view_log.clj
index 0442db30f97..4a2c945892d 100644
--- a/src/metabase/documents/view_log.clj
+++ b/src/metabase/documents/view_log.clj
@@ -39,7 +39,7 @@
:updated_at :updated_at} ;; setting last_viewed_at should not update the updated_at column
:where [:in :id (keys document-id->timestamp)]}))
(catch Exception e
- (log/error e "Failed to update document last_viewed_at")))))
+ (log/errorf "Failed to update document last_viewed_at: %s" (ex-message e))))))
(def ^:private update-document-last-viewed-at-queue
(delay (grouper/start!
@@ -68,4 +68,4 @@
;; Update recent views alongside existing view log functionality
(activity-feed/update-users-recent-views! user-id :model/Document object-id :view)
(catch Throwable e
- (log/warnf e "Failed to process document view event. %s" topic)))))
+ (log/warnf "Failed to process document view event. %s: %s" topic (ex-message e))))))
diff --git a/src/metabase/driver/events/driver_notifications.clj b/src/metabase/driver/events/driver_notifications.clj
index f962d795390..9f936aa44e1 100644
--- a/src/metabase/driver/events/driver_notifications.clj
+++ b/src/metabase/driver/events/driver_notifications.clj
@@ -31,4 +31,4 @@
(remove-irrelevant-data previous-database)))
(driver/notify-database-updated (:engine database) database)))
(catch Throwable e
- (log/warnf e "Failed to process driver notifications event. %s" topic))))
+ (log/warnf "Failed to process driver notifications event %s: %s" topic (ex-message e)))))
diff --git a/src/metabase/driver/events/report_timezone_updated.clj b/src/metabase/driver/events/report_timezone_updated.clj
index 4b08c6a3af0..d6959c726b5 100644
--- a/src/metabase/driver/events/report_timezone_updated.clj
+++ b/src/metabase/driver/events/report_timezone_updated.clj
@@ -22,7 +22,7 @@
(try
(driver/notify-database-updated driver database)
(catch Throwable e
- (log/errorf e "Failed to notify %s Database %s updated" driver id)))))
+ (log/errorf "Failed to notify %s Database %s updated: %s" driver id (ex-message e))))))
(methodical/defmethod driver-api/publish-event! ::event
"When the report-timezone Setting is updated, call [[metabase.driver/notify-database-updated]] for all Databases."
diff --git a/src/metabase/driver/impl.clj b/src/metabase/driver/impl.clj
index 6ac393a9430..c219d4167a9 100644
--- a/src/metabase/driver/impl.clj
+++ b/src/metabase/driver/impl.clj
@@ -76,7 +76,7 @@
(try
(apply classloader/require expected-ns require-options)
(catch Throwable e
- (log/error e "Error loading driver namespace")
+ (log/errorf "Error loading driver namespace: %s" (ex-message e))
(throw (Exception. (tru "Could not load {0} driver." driver) e))))))
(mu/defn load-driver-namespace-if-needed!
@@ -207,7 +207,6 @@
(doseq [parent (parents hierarchy driver)]
(initialize-if-needed! parent init-fn))
(log/info (u/format-color :yellow "Initializing driver %s..." driver))
- (log/debug "Reason:" (u/pprint-to-str :blue (drop 5 (u/filtered-stacktrace (Thread/currentThread)))))
(init-fn driver)
(swap! initialized-drivers conj driver))))))
diff --git a/src/metabase/driver/mysql/actions.clj b/src/metabase/driver/mysql/actions.clj
index 2fcbd3ed895..33987d62820 100644
--- a/src/metabase/driver/mysql/actions.clj
+++ b/src/metabase/driver/mysql/actions.clj
@@ -221,7 +221,7 @@
(sql.qp/format-honeysql driver select-hsql)))
(defmethod sql-jdbc.actions/select-created-row :mysql
- [driver create-hsql conn {:strs [insert_id] :as results}]
+ [driver create-hsql conn {:strs [insert_id]}]
(let [jdbc-spec {:connection conn}
table-components (-> create-hsql :insert-into :components)
pks (primary-keys driver jdbc-spec table-components)
@@ -230,5 +230,5 @@
select-sql-args
{:transaction? false, :keywordize? false})]
(if (next query-results)
- (log/warn "cannot identify row inserted by" create-hsql "using results" results)
+ (log/warn "cannot identify row inserted: select by primary key returned multiple rows")
(first query-results))))
diff --git a/src/metabase/driver/mysql/ddl.clj b/src/metabase/driver/mysql/ddl.clj
index 5a3ace42619..ce63bbb9de6 100644
--- a/src/metabase/driver/mysql/ddl.clj
+++ b/src/metabase/driver/mysql/ddl.clj
@@ -34,7 +34,7 @@
;; Our connection may be killed due to timeout, [[kill!]] will throw an appropriate exception
nil)
(catch Exception e
- (log/warn e)
+ (log/warn (ex-message e))
e))))))
(defn- kill! [conn pid]
@@ -97,7 +97,7 @@
(try
(sql.ddl/execute! conn [(sql.ddl/drop-table-sql database (:table_name persisted-info))])
(catch Exception e
- (log/warn e)
+ (log/warn (ex-message e))
(throw e)))))))
(defmethod ddl.i/check-can-persist :mysql
@@ -162,13 +162,13 @@
(loop [[[step stepfn undofn] & remaining] steps
undo-steps []]
(let [result (try (stepfn conn)
- (log/infof "Step %s was successful for db %s" step (:name database))
+ (log/infof "Step %s was successful for db %s" step (:id database))
::valid
(catch Exception e
- (log/warnf e "Error in `%s` while checking for model persistence permissions." step)
+ (log/warnf "Error in `%s` while checking for model persistence permissions: %s" step (ex-message e))
(try
(doseq [[undo-step undofn] (reverse undo-steps)]
- (log/warnf "Undoing step `%s` for db %s" undo-step (:name database))
+ (log/warnf "Undoing step `%s` for db %s" undo-step (:id database))
(undofn conn))
(catch Exception _e
(log/warn "Unable to rollback database check for model persistence")))
diff --git a/src/metabase/driver/postgres.clj b/src/metabase/driver/postgres.clj
index 2ca81c92e4a..5c7fe5cfe61 100644
--- a/src/metabase/driver/postgres.clj
+++ b/src/metabase/driver/postgres.clj
@@ -1031,7 +1031,7 @@
(parent-thunk)
(catch Throwable e
(let [s (.getString rs i)]
- (log/tracef e "Error in Postgres JDBC driver reading TIME value, fetching as string '%s'" s)
+ (log/tracef "Error in Postgres JDBC driver reading TIME value, fetching as string: %s" (ex-message e))
(u.date/parse s)))))))
;; The postgres JDBC driver cannot properly read MONEY columns — see https://github.com/pgjdbc/pgjdbc/issues/425. Work
diff --git a/src/metabase/driver/postgres/ddl.clj b/src/metabase/driver/postgres/ddl.clj
index f9b21ad15cc..682763716dd 100644
--- a/src/metabase/driver/postgres/ddl.clj
+++ b/src/metabase/driver/postgres/ddl.clj
@@ -60,7 +60,7 @@
(try
(sql.ddl/execute! conn [(sql.ddl/drop-table-sql database (:table_name persisted-info))])
(catch Exception e
- (log/warn e)
+ (log/warn (ex-message e))
(throw e)))))))
(defmethod ddl.i/check-can-persist :postgres
@@ -112,10 +112,10 @@
(set-statement-timeout! tx)
(loop [[[step stepfn] & remaining] steps]
(let [result (try (stepfn tx)
- (log/infof "Step %s was successful for db %s" step (:name database))
+ (log/infof "Step %s was successful for db %s" step (:id database))
::valid
(catch Exception e
- (log/warnf e "Error in `%s` while checking for model persistence permissions." step)
+ (log/warnf "Error in `%s` while checking for model persistence permissions: %s" step (ex-message e))
step))]
(cond (and (= result ::valid) remaining)
(recur remaining)
diff --git a/src/metabase/driver/sql.clj b/src/metabase/driver/sql.clj
index a17349b02e9..54a50453f0f 100644
--- a/src/metabase/driver/sql.clj
+++ b/src/metabase/driver/sql.clj
@@ -188,7 +188,7 @@
(driver/drop-table! driver (:id database) old-temp)
result)
(catch Exception e
- (log/error e "Failed to run transform using rename-tables strategy")
+ (log/errorf "Failed to run transform using rename-tables strategy: %s" (ex-message e))
(try (driver/drop-table! driver (:id database) new-temp) (catch Exception _))
(throw e)))))
@@ -202,7 +202,7 @@
(driver/rename-table! driver (:id database) tmp-table output-table)
result)
(catch Exception e
- (log/error e "Failed to run transform using create-drop-rename strategy")
+ (log/errorf "Failed to run transform using create-drop-rename strategy: %s" (ex-message e))
(try (driver/drop-table! driver (:id database) tmp-table) (catch Exception _))
(throw e)))))
@@ -212,7 +212,7 @@
(driver/drop-table! driver (:id database) output-table)
(create-table-and-insert-data! driver transform-details conn-spec)
(catch Exception e
- (log/error e "Failed to run transform using drop-create strategy")
+ (log/errorf "Failed to run transform using drop-create strategy: %s" (ex-message e))
(throw e))))
;; Follows similar logic to `transfer-file-to-db :table`
@@ -355,7 +355,7 @@
(sql-tools/is-single-stmt-of-type? driver (:native stage) stmt-type)]
(cond error
(do
- (log/warnf "Failed to parse native query: %s\n: Query: %s" error (:native stage))
+ (log/warnf "Failed to parse native query: %s" error)
(throw (ex-info (tru "Unable to parse native query. There might be something wrong with your query.")
{:type qp.error-type/invalid-query
:sql (:native stage)})))
diff --git a/src/metabase/driver/sql/parameters/substitute.clj b/src/metabase/driver/sql/parameters/substitute.clj
index b26c2db789f..916807bd1da 100644
--- a/src/metabase/driver/sql/parameters/substitute.clj
+++ b/src/metabase/driver/sql/parameters/substitute.clj
@@ -8,7 +8,6 @@
[metabase.lib.core :as lib]
[metabase.lib.schema.metadata :as lib.schema.metadata]
[metabase.query-processor.store :as qp.store]
- [metabase.util :as u]
[metabase.util.i18n :refer [tru]]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
@@ -140,7 +139,7 @@
[metadata-providerable :- ::lib.schema.metadata/metadata-providerable
parsed-query :- [:sequential :metabase.lib.parameters.parse/parsed-token]
param->value :- [:maybe [:map-of string? any?]]]
- (log/tracef "Substituting params\n%s\nin query:\n%s" (u/pprint-to-str param->value) (u/pprint-to-str parsed-query))
+ (log/tracef "Substituting %d params in query" (count param->value))
(let [[sql args missing] (try
(substitute* metadata-providerable param->value parsed-query false)
(catch Throwable e
@@ -149,7 +148,7 @@
:params param->value
:parsed-query parsed-query}
e))))]
- (log/tracef "=>%s\n%s" sql (pr-str args))
+ (log/tracef "Substituted %d params" (count args))
(when (seq missing)
(throw (ex-info (tru "Cannot run the query: missing required parameters: {0}" (set missing))
{:type driver-api/qp.error-type.missing-required-parameter
diff --git a/src/metabase/driver/sql/query_processor.clj b/src/metabase/driver/sql/query_processor.clj
index aaa6172b82e..5306dd6c3bc 100644
--- a/src/metabase/driver/sql/query_processor.clj
+++ b/src/metabase/driver/sql/query_processor.clj
@@ -866,7 +866,7 @@
:else honeysql-form)
(when-not (= <> honeysql-form)
- (log/tracef "Applied casting\n=>\n%s" (u/pprint-to-str <>))))))
+ (log/trace "Applied casting")))))
(defmethod ->honeysql [:sql :datetime]
[driver [_ value {:keys [mode]}]]
@@ -1041,9 +1041,7 @@
(or database-type effective-temporal-type) maybe-add-type-info
(:temporal-unit options) (apply-temporal-bucketing driver options)
(:binning options) (apply-binning options))
- (log/trace (binding [*print-meta* true]
- (format "Compiled field clause\n%s\n=>\n%s"
- (u/pprint-to-str field-clause) (u/pprint-to-str <>))))))
+ (log/trace "Compiled field clause")))
(catch Throwable e
(throw (ex-info (tru "Error compiling :field clause: {0}" (ex-message e))
{:clause field-clause}
@@ -2149,9 +2147,7 @@
(format-honeysql-2 driver dialect honeysql-form)
(catch Throwable e
(try
- (log/error e (u/format-color :red
- "Invalid HoneySQL form: %s\n%s"
- (ex-message e) (u/pprint-to-str honeysql-form)))
+ (log/error (u/format-color :red "Invalid HoneySQL form: %s" (ex-message e)))
(finally
(throw (ex-info (tru "Error compiling HoneySQL form: {0}" (ex-message e))
{:dialect dialect
@@ -2316,9 +2312,9 @@
(if (:lib/type query)
(binding [driver/*driver* driver]
(let [inner-query (preprocess driver query)]
- (log/tracef "Compiling MBQL query\n%s" (u/pprint-to-str 'magenta inner-query))
+ (log/trace "Compiling MBQL query")
(u/prog1 (compile-mbql driver inner-query)
- (log/debugf "\nHoneySQL Form: %s\n%s" (u/emoji "🍯") (u/pprint-to-str 'cyan <>))
+ (log/debug "Compiled HoneySQL form")
(driver-api/debug> (list '🍯 <>)))))
(let [metadata-provider (driver-api/metadata-provider)
database-id (if (:type query)
diff --git a/src/metabase/driver/sql/util.clj b/src/metabase/driver/sql/util.clj
index 765c0fae3ee..da972b928d6 100644
--- a/src/metabase/driver/sql/util.clj
+++ b/src/metabase/driver/sql/util.clj
@@ -78,7 +78,7 @@
:else
(do
- (log/errorf "Don't know how to alias %s, expected an h2x/identifier" (pr-str col))
+ (log/errorf "Don't know how to alias %s, expected an h2x/identifier" (class col))
[col col]))))
(defn select-clause-deduplicate-aliases
diff --git a/src/metabase/driver/sql_jdbc/actions.clj b/src/metabase/driver/sql_jdbc/actions.clj
index a7504608307..c56f7ff41e5 100644
--- a/src/metabase/driver/sql_jdbc/actions.clj
+++ b/src/metabase/driver/sql_jdbc/actions.clj
@@ -60,7 +60,7 @@
;; Catch errors in parse-sql-error and log them so more errors in the future don't break the entire action.
;; We'll still get the original unparsed error message.
(catch Throwable new-e
- (log/errorf new-e "Error parsing SQL error message %s: %s" (pr-str (ex-message e)) (ex-message new-e))
+ (log/errorf "Error parsing SQL error message %s: %s" (pr-str (ex-message e)) (ex-message new-e))
nil))))
(defn- do-with-auto-parse-sql-error
@@ -324,7 +324,7 @@
:table-id table-id}))))
(defn- row-delete!* [action database query]
- (log/tracef "Deleting %s" query)
+ (log/tracef "Deleting row for table %s" (-> query :query :source-table))
(let [db-id (u/the-id database)
table-id (-> query :query :source-table)
;; We'd error anyway, about not having a filter, but this fails earlier with a more explicit error
@@ -342,7 +342,6 @@
(query-rows-correct-name driver conn table-id)
first
(reset! row-before))
- (log/tracef "hsql: %s" (u/pprint-to-str delete-hsql))
(let [; TODO -- this should probably be using [[metabase.driver/execute-write-query!]]
rows-deleted (with-auto-parse-sql-exception driver database action
(first (jdbc/execute! {:connection conn} sql-args {:transaction? false})))]
@@ -377,7 +376,7 @@
(model-row-delete! action context inputs))
(defn- row-update!* [action database {:keys [update-row] :as query}]
- (log/tracef "updating %s" query)
+ (log/tracef "updating row for table %s" (get-in query [:query :source-table]))
(let [driver (:engine database)
db-id (u/the-id database)
table-id (get-in query [:query :source-table])
@@ -389,7 +388,6 @@
:where where}
(prepare-query driver action))
sql-args (sql.qp/format-honeysql driver update-hsql)]
- (log/tracef "hsql: %s" (u/pprint-to-str update-hsql))
(with-jdbc-transaction [conn db-id]
(let [table-id (-> query :query :source-table)
row-before (->> (prepare-query {:select [:*] :from from :where where} driver action)
@@ -450,11 +448,10 @@
(for [[col val] result]
[:= (keyword col) val]))))
select-sql-args (sql.qp/format-honeysql driver select-hsql)]
- (log/tracef ":model.row/create SELECT HoneySQL:\n\n%s" (u/pprint-to-str select-hsql))
(first (jdbc/query {:connection conn} select-sql-args {:identifiers identity, :transaction? false, :keywordize? false}))))
(defn- row-create!* [action database {:keys [create-row] :as query}]
- (log/tracef "creating %s" query)
+ (log/tracef "creating row for table %s" (get-in query [:query :source-table]))
(let [db-id (u/the-id database)
driver (:engine database)
table-id (get-in query [:query :source-table])
@@ -467,7 +464,6 @@
[(cast-values driver create-row db-id table-id)])}
(prepare-query driver action))
sql-args (sql.qp/format-honeysql driver create-hsql)]
- (log/tracef "hsql: %s" (u/pprint-to-str create-hsql))
(with-jdbc-transaction [conn db-id]
(let [table-id (-> query :query :source-table)
result (with-auto-parse-sql-exception driver database action
@@ -475,9 +471,7 @@
:identifiers identity
:transaction? false
:keywordize? false}))
- _ (log/tracef ":model.row/create INSERT returned\n\n%s" (u/pprint-to-str result))
row (first (correct-columns-name table-id [(select-created-row driver create-hsql conn result)]))]
- (log/tracef "created row: %s" (pr-str row))
{:table-id (-> query :query :source-table)
:db-id (u/the-id database)
:before nil
@@ -524,10 +518,9 @@
(try
;; Note that each row action takes care of reverting itself.
(let [result (do-nested-transaction (:engine database) conn #(proc action database query))]
- (log/tracef "perform result: %s" result)
[errors (conj results result)])
(catch Throwable e
- (log/error e)
+ (log/error (ex-message e))
[(conj errors (merge {:index row-index, :error (ex-message e)} (ex-data e)))
results]))))
rows)))
diff --git a/src/metabase/driver/sql_jdbc/connection/ssh_tunnel.clj b/src/metabase/driver/sql_jdbc/connection/ssh_tunnel.clj
index 4bf1e5c709b..1a86ba2b7ce 100644
--- a/src/metabase/driver/sql_jdbc/connection/ssh_tunnel.clj
+++ b/src/metabase/driver/sql_jdbc/connection/ssh_tunnel.clj
@@ -102,8 +102,8 @@
(SshdSocketAddress. "" 0)
(SshdSocketAddress. host port))
input-port (.. tracker getBoundAddress getPort)]
- (log/trace (u/format-color 'cyan "creating ssh tunnel (heartbeating every %d seconds) %s@%s:%s -L %s:%s:%s"
- hb-sec tunnel-user tunnel-host tunnel-port input-port host port))
+ (log/trace (u/format-color 'cyan "creating ssh tunnel (heartbeating every %d seconds) %s:%s -L %s:%s:%s"
+ hb-sec tunnel-host tunnel-port input-port host port))
[session tracker dedicated-client]))
(defn use-ssh-tunnel?
@@ -175,7 +175,7 @@
"Close a running tunnel session"
[details]
(when (and (use-ssh-tunnel? details) (ssh-tunnel-open? details))
- (log/tracef "Closing SSH tunnel: %s" (:tunnel-session details))
+ (log/trace "Closing SSH tunnel")
(.close ^ClientSession (:tunnel-session details)))
(when-let [^SshClient dedicated-client (:tunnel-client details)]
(.stop dedicated-client)))
diff --git a/src/metabase/driver/sql_jdbc/execute.clj b/src/metabase/driver/sql_jdbc/execute.clj
index 66dcfd0c029..0caf259df90 100644
--- a/src/metabase/driver/sql_jdbc/execute.clj
+++ b/src/metabase/driver/sql_jdbc/execute.clj
@@ -220,16 +220,16 @@
(when-let [format-string (sql-jdbc.execute.old/set-timezone-sql driver)]
(try
(let [sql (format format-string (str \' timezone-id \'))]
- (log/debugf "Setting %s database timezone with statement: %s" driver (pr-str sql))
+ (log/debugf "Setting %s database timezone to %s" driver timezone-id)
(try
(.setReadOnly conn false)
(catch Throwable e
- (log/debug e "Error setting connection to readwrite")))
+ (log/debugf "Error setting connection to readwrite: %s" (ex-message e))))
(with-open [stmt (.createStatement conn)]
(.execute stmt sql)
(log/tracef "Successfully set timezone for %s database to %s" driver timezone-id)))
(catch Throwable e
- (log/errorf e "Failed to set timezone '%s' for %s database" timezone-id driver))))))
+ (log/errorf "Failed to set timezone '%s' for %s database: %s" timezone-id driver (ex-message e)))))))
(defenterprise set-role-if-supported!
"OSS no-op implementation of `set-role-if-supported!`."
@@ -253,7 +253,7 @@
(try
(.setTransactionIsolation conn level)
(catch Throwable e
- (log/debugf e "Error setting transaction isolation level for %s database to %s" (name driver) level-name))))
+ (log/debugf "Error setting transaction isolation level for %s database to %s: %s" (name driver) level-name (ex-message e)))))
(seq more)
(recur more)))))
@@ -425,7 +425,7 @@
(log/trace (pr-str (list '.setReadOnly 'conn read-only?)))
(.setReadOnly conn read-only?)
(catch Throwable e
- (log/debugf e "Error setting connection readOnly to %s" (pr-str read-only?)))))
+ (log/debugf "Error setting connection readOnly to %s: %s" (pr-str read-only?) (ex-message e)))))
;; If this is (supposedly) a read-only connection, we would prefer enable auto-commit
;; so this IS NOT ran inside of a transaction, but without transaction the read-only
;; flag has no effect for most of the drivers.
@@ -439,7 +439,7 @@
(log/trace (pr-str '(.setAutoCommit conn true)))
(.setAutoCommit conn true)
(catch Throwable e
- (log/debug e "Error enabling connection autoCommit")))
+ (log/debugf "Error enabling connection autoCommit: %s" (ex-message e))))
;; Postgres/Redshift buffer the *entire* ResultSet unless autoCommit is false (then they use a server-side
;; cursor honoring the statement fetch size). So for streamed reads (`:stream?` -- sync metadata reads,
@@ -449,18 +449,18 @@
(log/trace (pr-str '(.setAutoCommit conn false)))
(.setAutoCommit conn false)
(catch Throwable e
- (log/debug e "Error setting connection autoCommit to false"))))
+ (log/debugf "Error setting connection autoCommit to false: %s" (ex-message e)))))
(try
;; setNetworkTimeout sets Socket.setSoTimeout() which releases from blocked socker reads.
;; This is necessary because .close() doesn't interrupt threads stuck in native socket reads
(.setNetworkTimeout conn @network-timeout-executor driver.settings/*network-timeout-ms*)
(catch Throwable e
- (log/debug e "Error setting network timeout for connection")))
+ (log/debugf "Error setting network timeout for connection: %s" (ex-message e))))
(try
(log/trace (pr-str '(.setHoldability conn ResultSet/CLOSE_CURSORS_AT_COMMIT)))
(.setHoldability conn ResultSet/CLOSE_CURSORS_AT_COMMIT)
(catch Throwable e
- (log/debug e "Error setting default holdability for connection")))))
+ (log/debugf "Error setting default holdability for connection: %s" (ex-message e))))))
(defmethod do-with-connection-with-options :sql-jdbc
[driver db-or-id-or-spec options f]
@@ -477,12 +477,12 @@
(defn- set-object
([^PreparedStatement prepared-statement, ^Integer index, object]
- (log/tracef "(set-object prepared-statement %d ^%s %s)" index (some-> object class .getName) (pr-str object))
+ (log/tracef "(set-object prepared-statement %d ^%s)" index (some-> object class .getName))
(.setObject prepared-statement index object))
([^PreparedStatement prepared-statement, ^Integer index, object, ^Integer target-sql-type]
- (log/tracef "(set-object prepared-statement %d ^%s %s java.sql.Types/%s)" index (some-> object class .getName)
- (pr-str object) (.getName (JDBCType/valueOf target-sql-type)))
+ (log/tracef "(set-object prepared-statement %d ^%s java.sql.Types/%s)" index (some-> object class .getName)
+ (.getName (JDBCType/valueOf target-sql-type)))
(.setObject prepared-statement index object target-sql-type)))
(defmethod set-parameter :default
@@ -538,7 +538,7 @@
(dorun
(map-indexed
(fn [i param]
- (log/tracef "Set param %d -> %s" (inc i) (pr-str param))
+ (log/tracef "Set param %d ^%s" (inc i) (some-> param class .getName))
(set-parameter driver stmt (inc i) param))
params)))
@@ -553,12 +553,12 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting prepared statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting prepared statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
(try
(when (zero? (.getFetchSize stmt))
(.setFetchSize stmt (driver.settings/sql-jdbc-fetch-size)))
(catch Throwable e
- (log/debug e "Error setting prepared statement fetch size to fetch-size")))
+ (log/debugf "Error setting prepared statement fetch size to fetch-size: %s" (ex-message e))))
(set-parameters! driver stmt params)
stmt
(catch Throwable e
@@ -575,12 +575,12 @@
(try
(.setFetchDirection stmt ResultSet/FETCH_FORWARD)
(catch Throwable e
- (log/debug e "Error setting statement fetch direction to FETCH_FORWARD")))
+ (log/debugf "Error setting statement fetch direction to FETCH_FORWARD: %s" (ex-message e))))
(try
(when (zero? (.getFetchSize stmt))
(.setFetchSize stmt (driver.settings/sql-jdbc-fetch-size)))
(catch Throwable e
- (log/debug e "Error setting statement fetch size to fetch-size")))
+ (log/debugf "Error setting statement fetch size to fetch-size: %s" (ex-message e))))
stmt
(catch Throwable e
(.close stmt)
@@ -610,7 +610,7 @@
(try
(u.connection/set-query-timeout! stmt (long (/ driver.settings/*query-timeout-ms* 1000)))
(catch Throwable e
- (log/debug e "Error setting statement query timeout")))))
+ (log/debugf "Error setting statement query timeout: %s" (ex-message e))))))
(defn- prepared-statement*
^PreparedStatement [driver conn sql params canceled-chan]
@@ -875,7 +875,7 @@
(log/warnf "Statemet's `.cancel` method is not supported by the `%s` driver."
(name driver)))
(catch Throwable e
- (log/info e "Statement cancelation failed.")))))))))))))
+ (log/infof "Statement cancelation failed: %s" (ex-message e))))))))))))))
(defn reducible-query
"Returns a reducible collection of rows as maps from `db` and a given SQL query. This is similar to [[jdbc/reducible-query]] but reuses the
@@ -1050,5 +1050,5 @@
(set! *resilient-connection-ctx* {:db db :conn conn})
conn)
(catch Throwable e
- (log/warn e "Failed obtaining a new resilient connection")
+ (log/warnf "Failed obtaining a new resilient connection: %s" (ex-message e))
connection)))))
diff --git a/src/metabase/driver/sql_jdbc/execute/legacy_impl.clj b/src/metabase/driver/sql_jdbc/execute/legacy_impl.clj
index 73911e23fc2..bcc21bb3bcd 100644
--- a/src/metabase/driver/sql_jdbc/execute/legacy_impl.clj
+++ b/src/metabase/driver/sql_jdbc/execute/legacy_impl.clj
@@ -23,40 +23,40 @@
(defmethod sql-jdbc.execute/set-parameter [::use-legacy-classes-for-read-and-set LocalDate]
[_ ^PreparedStatement ps ^Integer i t]
(let [t (t/sql-date t)]
- (log/tracef "(.setDate ps %d ^%s %s)" i (.getName (class t)) (pr-str t))
+ (log/tracef "(.setDate ps %d ^%s)" i (.getName (class t)))
(.setDate ps i t)))
(defmethod sql-jdbc.execute/set-parameter [::use-legacy-classes-for-read-and-set LocalDateTime]
[_ ^PreparedStatement ps ^Integer i t]
(let [t (t/sql-timestamp t)]
- (log/tracef "(.setTimestamp %d ^%s %s)" i (.getName (class t)) (pr-str t))
+ (log/tracef "(.setTimestamp %d ^%s)" i (.getName (class t)))
(.setTimestamp ps i t)))
(defmethod sql-jdbc.execute/set-parameter [::use-legacy-classes-for-read-and-set LocalTime]
[_ ^PreparedStatement ps ^Integer i t]
(let [t (t/sql-time t)]
- (log/tracef "(.setTime %d ^%s %s)" i (.getName (class t)) (pr-str t))
+ (log/tracef "(.setTime %d ^%s)" i (.getName (class t)))
(.setTime ps i t)))
(defmethod sql-jdbc.execute/set-parameter [::use-legacy-classes-for-read-and-set OffsetTime]
[_ ^PreparedStatement ps ^Integer i t]
(let [cal (Calendar/getInstance (TimeZone/getTimeZone (t/zone-id t)))
t (t/sql-time t)]
- (log/tracef "(.setTime %d ^%s %s <%s Calendar>)" i (.getName (class t)) (pr-str t) (.. cal getTimeZone getID))
+ (log/tracef "(.setTime %d ^%s <%s Calendar>)" i (.getName (class t)) (.. cal getTimeZone getID))
(.setTime ps i t cal)))
(defmethod sql-jdbc.execute/set-parameter [::use-legacy-classes-for-read-and-set OffsetDateTime]
[_ ^PreparedStatement ps ^Integer i t]
(let [cal (Calendar/getInstance (TimeZone/getTimeZone (t/zone-id t)))
t (t/sql-timestamp t)]
- (log/tracef "(.setTimestamp %d ^%s %s <%s Calendar>)" i (.getName (class t)) (pr-str t) (.. cal getTimeZone getID))
+ (log/tracef "(.setTimestamp %d ^%s <%s Calendar>)" i (.getName (class t)) (.. cal getTimeZone getID))
(.setTimestamp ps i t cal)))
(defmethod sql-jdbc.execute/set-parameter [::use-legacy-classes-for-read-and-set ZonedDateTime]
[_ ^PreparedStatement ps ^Integer i t]
(let [cal (Calendar/getInstance (TimeZone/getTimeZone (t/zone-id t)))
t (t/sql-timestamp t)]
- (log/tracef "(.setTimestamp %d ^%s %s <%s Calendar>)" i (.getName (class t)) (pr-str t) (.. cal getTimeZone getID))
+ (log/tracef "(.setTimestamp %d ^%s <%s Calendar>)" i (.getName (class t)) (.. cal getTimeZone getID))
(.setTimestamp ps i t cal)))
(defmethod sql-jdbc.execute/read-column-thunk [::use-legacy-classes-for-read-and-set Types/TIME]
@@ -64,7 +64,7 @@
(fn []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs i) [TIME] -> %s -> %s" (pr-str s) (pr-str t))
+ (log/trace "(.getString rs i) [TIME]")
t))))
(defmethod sql-jdbc.execute/read-column-thunk [::use-legacy-classes-for-read-and-set Types/TIME_WITH_TIMEZONE]
@@ -72,7 +72,7 @@
(fn []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs i) [TIME_WITH_TIMEZONE] -> %s -> %s" (pr-str s) (pr-str t))
+ (log/trace "(.getString rs i) [TIME_WITH_TIMEZONE]")
t))))
(defmethod sql-jdbc.execute/read-column-thunk [::use-legacy-classes-for-read-and-set Types/DATE]
@@ -80,7 +80,7 @@
(fn []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs i) [DATE] -> %s -> %s" (pr-str s) (pr-str t))
+ (log/trace "(.getString rs i) [DATE]")
t))))
(defmethod sql-jdbc.execute/read-column-thunk [::use-legacy-classes-for-read-and-set Types/TIMESTAMP]
@@ -88,7 +88,7 @@
(fn []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs i) [TIMESTAMP] -> %s -> %s" (pr-str s) (pr-str t))
+ (log/trace "(.getString rs i) [TIMESTAMP]")
t))))
(defmethod sql-jdbc.execute/read-column-thunk [::use-legacy-classes-for-read-and-set Types/TIMESTAMP_WITH_TIMEZONE]
@@ -96,7 +96,7 @@
(fn []
(when-let [s (.getString rs i)]
(let [t (u.date/parse s)]
- (log/tracef "(.getString rs i) [TIMESTAMP_WITH_TIMEZONE] -> %s -> %s" (pr-str s) (pr-str t))
+ (log/trace "(.getString rs i) [TIMESTAMP_WITH_TIMEZONE]")
t))))
(doseq [dispatch-val (keys (methods sql-jdbc.execute/read-column-thunk))
diff --git a/src/metabase/driver/sql_jdbc/sync/describe_database.clj b/src/metabase/driver/sql_jdbc/sync/describe_database.clj
index a2b03c23023..05eeb5ad38d 100644
--- a/src/metabase/driver/sql_jdbc/sync/describe_database.clj
+++ b/src/metabase/driver/sql_jdbc/sync/describe_database.clj
@@ -97,9 +97,8 @@
;; outer unrealized resultsets (like the [[all-schemas]] results) may get
;; unrecoverably closed
conn (sql-jdbc.execute/try-ensure-open-conn! driver outer-conn :force-context-local? true)]
- (log/debugf "have-select-privilege? sql-jdbc: Checking for SELECT privileges for %s with query\n%s"
- (pr-table table-schema table-name)
- (pr-str sql-args))
+ (log/debugf "have-select-privilege? sql-jdbc: Checking for SELECT privileges for %s"
+ (pr-table table-schema table-name))
(try
(log/debug "have-select-privilege? sql-jdbc: Attempt to execute probe query")
(execute-select-probe-query driver conn sql-args)
@@ -115,7 +114,7 @@
allow? (driver/query-canceled? driver e)]
(if allow?
(log/infof "%s: Assuming SELECT privileges: caught timeout exception" (pr-table table-schema table-name))
- (log/debugf e "%s: Assuming no SELECT privileges: caught exception" (pr-table table-schema table-name)))
+ (log/debugf "%s: Assuming no SELECT privileges: caught exception: %s" (pr-table table-schema table-name) (ex-message e)))
;; if the connection was closed this will throw an error and fail the sync loop so we prevent this error from
;; affecting anything higher
(try (when-not (.getAutoCommit conn)
diff --git a/src/metabase/driver/sql_jdbc/sync/describe_table.clj b/src/metabase/driver/sql_jdbc/sync/describe_table.clj
index 241fbb0e2f7..08ab438b694 100644
--- a/src/metabase/driver/sql_jdbc/sync/describe_table.clj
+++ b/src/metabase/driver/sql_jdbc/sync/describe_table.clj
@@ -398,13 +398,9 @@
(and table-names (empty? table-names)))
[]
(let [sql (describe-fields-sql driver (assoc args :details (driver.conn/effective-details db)))]
- (try
- (log/debugf "`describe-fields` sql query:\n```\n%s\n```\n`describe-fields` args:\n```\n%s\n```"
- (driver/prettify-native-form driver (first sql))
- (rest sql))
- ;; This overly defensive, but rather save than sorry.
- (catch Throwable _
- (log/error "Failed to prepare sql for log.")))
+ (log/debugf "`describe-fields` for schemas %s, tables %s"
+ (pr-str schema-names)
+ (pr-str table-names))
(eduction
(comp
(m/mapply describe-fields-pre-process-xf driver db args)
diff --git a/src/metabase/driver/util.clj b/src/metabase/driver/util.clj
index f7c6d714776..f37b5fda736 100644
--- a/src/metabase/driver/util.clj
+++ b/src/metabase/driver/util.clj
@@ -137,7 +137,7 @@
;; actually if we are going to `throw-exceptions` we'll rethrow the original but attempt to humanize the message
;; first
(catch Throwable e
- (log/error e "Failed to connect to Database")
+ (log/errorf "Failed to connect to Database: %s" (ex-message e))
(throw (if-let [humanized-message (some->> (u/all-ex-messages e)
(driver/humanize-connection-error-message driver))]
(let [error-data (cond
@@ -154,7 +154,7 @@
(try
(can-connect-with-details? driver details-map :throw-exceptions)
(catch Throwable e
- (log/error e "Failed to connect to database")
+ (log/errorf "Failed to connect to database: %s" (ex-message e))
false))))
;;; +----------------------------------------------------------------------------------------------------------------+
@@ -210,7 +210,7 @@
(u/with-timeout supports?-timeout-ms
(driver/database-supports? driver feature database))
(catch Throwable e
- (log/error e (u/format-color 'red "Failed to check feature '%s' for database '%s'" (u/qualified-name feature) (:name database)))
+ (log/error (u/format-color 'red "Failed to check feature '%s' for database %s: %s" (u/qualified-name feature) (:id database) (ex-message e)))
false)))
(def ^:private memoized-supports?*
@@ -367,7 +367,7 @@
(let [content (or placeholder
(try (getter)
(catch Throwable e
- (log/errorf e "Error invoking getter for connection property %s" (:name conn-prop)))))]
+ (log/errorf "Error invoking getter for connection property %s: %s" (:name conn-prop) (ex-message e)))))]
(when (string? content)
(-> conn-prop
(assoc :placeholder content)
@@ -378,7 +378,7 @@
[{:keys [check] :as conn-prop}]
(if (try (check)
(catch Throwable e
- (log/errorf e "Error invoking getter for connection property %s" (:name conn-prop))))
+ (log/errorf "Error invoking getter for connection property %s: %s" (:name conn-prop) (ex-message e))))
[(-> conn-prop
(assoc :type "section")
(dissoc :check))]
@@ -618,7 +618,7 @@
(->> (driver/connection-properties driver)
(connection-props-server->client driver))
(catch Throwable e
- (log/errorf e "Unable to determine connection properties for driver %s" driver)))]
+ (log/errorf "Unable to determine connection properties for driver %s: %s" driver (ex-message e))))]
;; TODO - maybe we should rename `details-fields` -> `connection-properties` on the FE as well?
(assoc! acc driver {:source {:type (driver-source (name driver))
:contact (driver/contact-info driver)}
diff --git a/src/metabase/embedding_rest/api/common.clj b/src/metabase/embedding_rest/api/common.clj
index 4424d81ceee..415ad3c066d 100644
--- a/src/metabase/embedding_rest/api/common.clj
+++ b/src/metabase/embedding_rest/api/common.clj
@@ -492,8 +492,7 @@
:param-slug searched-param-slug
:token-params slug-token-params}
e)]
- (log/errorf e "embedded card-param-values error\n%s"
- (u/pprint-to-str (u/all-ex-data e)))
+ (log/errorf "embedded card-param-values error for Card %s: %s" (u/the-id card) (ex-message e))
(throw e))))))
(defn card-param-remapped-value
@@ -537,8 +536,7 @@
:param-slug searched-param-slug
:token-params slug-token-params}
e)]
- (log/errorf e "embedded card-param-values error\n%s"
- (u/pprint-to-str (u/all-ex-data e)))
+ (log/errorf "embedded card-param-values error for Card %s: %s" (u/the-id card) (ex-message e))
(throw e))))))
(defn dashboard-param-values
@@ -595,7 +593,7 @@
:param-slug searched-param-slug
:token-params slug-token-params}
e)]
- (log/errorf e "Chain filter error\n%s" (u/pprint-to-str (u/all-ex-data e)))
+ (log/errorf "Chain filter error for Dashboard %s: %s" dashboard-id (ex-message e))
(throw e))))))
(defn dashboard-param-remapped-value
diff --git a/src/metabase/events/impl.clj b/src/metabase/events/impl.clj
index fe75cdb3e61..53277d833d8 100644
--- a/src/metabase/events/impl.clj
+++ b/src/metabase/events/impl.clj
@@ -89,12 +89,12 @@
[topic event]
(assert (not *compile-files*) "Calls to publish-event! are not allowed in the top level.")
(let [{:keys [object]} event]
- (log/debugf "Publishing %s event (name and id):\n\n%s"
+ (log/debugf "Publishing %s event (model and id): %s"
(u/colorize :yellow (pr-str topic))
- (u/pprint-to-str (let [model (mi/model object)]
- (cond-> (select-keys object [:name :id])
- model
- (assoc :model model))))))
+ (pr-str (let [model (mi/model object)]
+ (cond-> (select-keys object [:id])
+ model
+ (assoc :model model))))))
(assert (and (qualified-keyword? topic)
(isa? topic :metabase/event))
(format "Invalid event topic %s: events must derive from :metabase/event" (pr-str topic)))
diff --git a/src/metabase/formatter/datetime.clj b/src/metabase/formatter/datetime.clj
index 959cb85b78d..bf7fb3ee695 100644
--- a/src/metabase/formatter/datetime.clj
+++ b/src/metabase/formatter/datetime.clj
@@ -235,8 +235,7 @@
(try
(reformat-temporal-str timezone-id temporal-str date-format)
(catch Exception _
- (log/warnf "Could not format temporal string %s in time zone %s with format %s."
- temporal-str
+ (log/warnf "Could not format temporal string in time zone %s with format %s."
timezone-id
date-format)
temporal-str)))))
diff --git a/src/metabase/geojson/api.clj b/src/metabase/geojson/api.clj
index 0a03a649450..35c3aab2b72 100644
--- a/src/metabase/geojson/api.clj
+++ b/src/metabase/geojson/api.clj
@@ -104,8 +104,8 @@
:region_key region_key
:region_name region_name}
(catch Throwable e
- (log/warnf e "Failed to load custom GeoJSON for region %s from %s"
- (pr-str region-key) (pr-str url))
+ (log/warnf "Failed to load custom GeoJSON for region %s from %s: %s"
+ (pr-str region-key) (pr-str url) (ex-message e))
nil))))
(defn region-geojson
diff --git a/src/metabase/health_inspector/core.clj b/src/metabase/health_inspector/core.clj
index 98bce819804..51282b105a6 100644
--- a/src/metabase/health_inspector/core.clj
+++ b/src/metabase/health_inspector/core.clj
@@ -64,7 +64,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/error e "Health check errored" {:check check-name})
+ (log/error "Health check errored" {:check check-name} (ex-message e))
{:health 0, :message (str "Health check errored: " (ex-message e))})))
(defn report
diff --git a/src/metabase/indexed_entities/models/model_index.clj b/src/metabase/indexed_entities/models/model_index.clj
index eabacbbc1ed..9a2a929f451 100644
--- a/src/metabase/indexed_entities/models/model_index.clj
+++ b/src/metabase/indexed_entities/models/model_index.clj
@@ -96,7 +96,7 @@
:limit (inc max-indexed-values)}})
:data :rows (filter valid-tuples?))]
(catch Exception e
- (log/warnf e "Error fetching indexed values for model %s" (:id model))
+ (log/warnf "Error fetching indexed values for model %s: %s" (:id model) (ex-message e))
[(ex-message e) []]))))
(defn find-changes
@@ -157,8 +157,8 @@
"indexed")}))
(run! search/update! (t2/reducible-select :model/ModelIndexValue :model_index_id (:id model-index)))
(catch Exception e
- (log/errorf e "Error saving model-index values for model-index: %d, model: %d"
- (:id model-index) (:model_id model-index))
+ (log/errorf "Error saving model-index values for model-index: %d, model: %d: %s"
+ (:id model-index) (:model_id model-index) (ex-message e))
(t2/update! :model/ModelIndex (:id model-index)
{:state "error"
:error (ex-message e)
diff --git a/src/metabase/indexed_entities/task/index_values.clj b/src/metabase/indexed_entities/task/index_values.clj
index 20552fdda47..745e50b81d7 100644
--- a/src/metabase/indexed_entities/task/index_values.clj
+++ b/src/metabase/indexed_entities/task/index_values.clj
@@ -92,7 +92,7 @@
(catch ObjectAlreadyExistsException _e
(log/info (u/format-color :red "Index already present for model: %s" (:model_id model-index))))
(catch Exception e
- (log/warnf e "Error scheduling indexing for model: %s" (:model_id model-index))))))
+ (log/warnf "Error scheduling indexing for model: %s: %s" (:model_id model-index) (ex-message e))))))
(defn remove-indexing-job
"Public API to remove an indexing job on a model."
@@ -110,7 +110,7 @@
(keep #(get-in % [:data "model-index-id"]))
set)
(catch Exception e
- (log/warn e "Error fetching existing triggers from Quartz, will recreate all triggers")
+ (log/warnf "Error fetching existing triggers from Quartz, will recreate all triggers: %s" (ex-message e))
#{}))
missing-trigger-model-indexes (if (seq existing-trigger-model-index-ids)
(t2/select :model/ModelIndex :id [:not-in existing-trigger-model-index-ids])
@@ -122,9 +122,9 @@
(try
(add-indexing-job model-index)
(catch Exception e
- (log/errorf e "Error re-adding indexing job for model-index: %d" (:id model-index)))))))
+ (log/errorf "Error re-adding indexing job for model-index: %d: %s" (:id model-index) (ex-message e)))))))
(catch Exception e
- (log/error e "Error during model index trigger recreation"))))
+ (log/errorf "Error during model index trigger recreation: %s" (ex-message e)))))
(defn- job-init!
[]
diff --git a/src/metabase/indexes/reconcile.clj b/src/metabase/indexes/reconcile.clj
index 0606582265b..22d856eb66e 100644
--- a/src/metabase/indexes/reconcile.clj
+++ b/src/metabase/indexes/reconcile.clj
@@ -147,5 +147,5 @@
(try
(vec (driver/fetch-table-indexes (:engine database) database schema table-name))
(catch Throwable t
- (log/warnf t "fetch-table-indexes failed for %s.%s" schema table-name)
+ (log/warnf "fetch-table-indexes failed for %s.%s: %s" schema table-name (ex-message t))
nil)))
diff --git a/src/metabase/lib/convert.cljc b/src/metabase/lib/convert.cljc
index 3e7beb48d25..21070962aea 100644
--- a/src/metabase/lib/convert.cljc
+++ b/src/metabase/lib/convert.cljc
@@ -1,7 +1,7 @@
(ns metabase.lib.convert
(:refer-clojure :exclude [mapv some select-keys not-empty #?(:clj doseq) #?(:clj for)])
(:require
- [clojure.data :as data]
+ #?@(:cljs [[clojure.data :as data]])
[clojure.set :as set]
[clojure.string :as str]
[malli.error :as me]
@@ -75,10 +75,9 @@
:diff (first (data/diff almost-stage new-stage))})))
#?(:cljs (js/console.warn "Clean: Removing bad clause due to error!" error-location error-desc
(u/pprint-to-str (first (data/diff almost-stage new-stage))))
- :clj (log/warnf "Clean: Removing bad clause in %s due to error %s:\n%s"
+ :clj (log/warnf "Clean: Removing bad clause in %s due to error %s"
(u/colorize :yellow (pr-str error-location))
- (u/colorize :yellow error-desc)
- (u/colorize :red (u/pprint-to-str (first (data/diff almost-stage new-stage))))))
+ (u/colorize :yellow error-desc)))
(if (= new-stage almost-stage)
almost-stage
(recur new-stage (conj removals [error-type error-location]))))
@@ -278,7 +277,7 @@
:else
(recur (conj acc col) aggregation-index more)))
(catch #?(:clj Throwable :cljs :default) e
- (log/error e "Error adding :lib/source-uuid to cols")
+ (log/errorf "Error adding :lib/source-uuid to cols: %s" (ex-message e))
cols)))
(defmethod ->mbql5 :mbql.stage/mbql
diff --git a/src/metabase/lib/drill_thru.cljc b/src/metabase/lib/drill_thru.cljc
index b8bbc654885..1fde89e3ee9 100644
--- a/src/metabase/lib/drill_thru.cljc
+++ b/src/metabase/lib/drill_thru.cljc
@@ -29,7 +29,6 @@
[metabase.lib.schema :as lib.schema]
[metabase.lib.schema.drill-thru :as lib.schema.drill-thru]
[metabase.lib.schema.id :as lib.schema.id]
- [metabase.util :as u]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
[metabase.util.performance :refer [select-keys not-empty #?(:clj for)]]))
@@ -162,7 +161,6 @@
card-id :- [:maybe ::lib.schema.id/card]
drill :- ::lib.schema.drill-thru/drill-thru
& args]
- (log/debugf "Applying drill thru: %s"
- (u/pprint-to-str {:query query, :stage-number stage-number, :drill drill, :args args}))
+ (log/debugf "Applying drill thru: %s" (:type drill))
(let [{:keys [query stage-number]} (lib.query/wrap-native-query-with-mbql query stage-number card-id)]
(apply lib.drill-thru.common/drill-thru-method query stage-number drill args))))
diff --git a/src/metabase/lib/drill_thru/fk_details.cljc b/src/metabase/lib/drill_thru/fk_details.cljc
index 1436b3c6a93..824a8b20549 100644
--- a/src/metabase/lib/drill_thru/fk_details.cljc
+++ b/src/metabase/lib/drill_thru/fk_details.cljc
@@ -74,7 +74,7 @@
(when-let [fk-column-id (or (:fk-target-field-id column)
(do
(log/warnf "Cannot apply :fk-details drill because column is missing :fk-target-field-id: %s"
- (pr-str column))
+ (pr-str (:id column)))
nil))]
(when-let [fk-column (lib.metadata/field query fk-column-id)]
(when-let [fk-column-table (lib.metadata/table query (:table-id fk-column))]
diff --git a/src/metabase/lib/equality.cljc b/src/metabase/lib/equality.cljc
index d88dc9b17e3..6ad0854f5e4 100644
--- a/src/metabase/lib/equality.cljc
+++ b/src/metabase/lib/equality.cljc
@@ -293,9 +293,7 @@ are known to be the same."
(or (when-let [join-alias (:join-alias opts)]
(or (plausible-matches-for-name-with-join-alias join-alias ref-name columns)
;; if there's no match for a join then fall back to trying to match by ignoring the join alias.
- (do (log/warnf "Failed to find match for column %s with join alias %s, looking for match without join alias..."
- (pr-str ref-name)
- (pr-str join-alias))
+ (do (log/warn "Failed to find match for column with its join alias, looking for match without join alias...")
nil)))
(plausible-matches-for-name-no-join-alias ref-name columns)))
@@ -336,7 +334,7 @@ are known to be the same."
;; In all other cases, this is an ambiguous match.
#_(throw (ambiguous-match-error a-ref columns))
#?(:cljs (js/console.warn (ambiguous-match-error a-ref columns))
- :clj (log/warn (ambiguous-match-error a-ref columns)))))
+ :clj (log/warn (ex-message (ambiguous-match-error a-ref columns))))))
(defn- matching-col-with-fn [columns col-fn]
(let [matching-columns (filter col-fn columns)]
@@ -409,10 +407,11 @@ are known to be the same."
;; try again ignoring join alias.
(do
(when join-alias
- (#?(:cljs js/console.warn :clj log/warn)
- "Multiple plausible matches with the same :join-alias - more disambiguation needed"
- {:ref a-ref
- :matches matches}))
+ #?(:cljs (js/console.warn
+ "Multiple plausible matches with the same :join-alias - more disambiguation needed"
+ {:ref a-ref
+ :matches matches})
+ :clj (log/warn "Multiple plausible matches with the same :join-alias - more disambiguation needed")))
nil)))
(disambiguate-matches-ignoring-join-alias a-ref columns))))
@@ -606,7 +605,7 @@ are known to be the same."
(keep (fn [selected-col-or-ref]
(or (find-matching-column query stage-number selected-col-or-ref cols)
(do
- (log/warnf "[mark-selected-columns] failed to find match for %s" (pr-str selected-col-or-ref))
+ (log/warn "[mark-selected-columns] failed to find match for a selected column or ref")
nil))))
selected-columns-or-refs)]
(when-not (clojure.core/= (count selected-columns-or-refs) (count matching-selected-cols))
diff --git a/src/metabase/lib/expression.cljc b/src/metabase/lib/expression.cljc
index 92f845d44ad..b525284ecd4 100644
--- a/src/metabase/lib/expression.cljc
+++ b/src/metabase/lib/expression.cljc
@@ -66,17 +66,17 @@
stage-number :- :int
expression-name :- ::lib.schema.common/non-blank-string]
(or (maybe-resolve-expression query stage-number expression-name)
- (log/warnf "Expression %s does not exist in stage %d" (pr-str expression-name) (lib.util/canonical-stage-index query stage-number))
+ (log/warnf "Expression does not exist in stage %d" (lib.util/canonical-stage-index query stage-number))
(when-let [previous-stage-number (lib.util/previous-stage-number query stage-number)]
(u/prog1 (resolve-expression query previous-stage-number expression-name)
(when <>
- (log/warnf "Found expression %s in previous stage" (pr-str expression-name)))))
+ (log/warn "Found expression in previous stage"))))
(when (lib.util/first-stage? query stage-number)
(when-let [source-card (lib.metadata.calculation/primary-source-card query)]
(u/prog1 (resolve-expression (:dataset-query source-card) expression-name)
(when <>
- (log/warnf "Found expression %s in source card %d. Next time, use a :field name ref!"
- (pr-str expression-name) (:id source-card))))))
+ (log/warnf "Found expression in source card %d. Next time, use a :field name ref!"
+ (:id source-card))))))
(throw (ex-info (i18n/tru "No expression named {0}" (pr-str expression-name))
{:expression-name expression-name
:query query
diff --git a/src/metabase/lib/field.cljc b/src/metabase/lib/field.cljc
index 79c3ae04db5..5b8f26fb1b6 100644
--- a/src/metabase/lib/field.cljc
+++ b/src/metabase/lib/field.cljc
@@ -605,9 +605,8 @@
matching-ref (lib.equality/find-matching-ref column field-refs)]
(if matching-ref
(do
- (log/debugf "Column %s already included by ref %s, doing nothing and returning the original query"
- (pr-str (select-keys column [:id :lib/join-alias :lib/source-column-alias]))
- (pr-str matching-ref))
+ (log/debugf "Column %s already included by an existing ref, doing nothing and returning the original query"
+ (:id column))
query)
(let [column-ref (lib.ref/ref column)]
(lib.util/update-query-stage populated stage-number update :fields conj column-ref)))))
@@ -664,7 +663,7 @@
(when (and (empty? (:fields stage))
(not (#{:source/implicitly-joinable :source/joins} source)))
(log/warnf "[add-field] stage :fields is empty, which means everything will already be included; attempt to add %s will no-op"
- (pr-str ((some-fn :display-name :name) column))))
+ (:id column)))
(-> (case source
(:source/table-defaults
:source/card
@@ -685,9 +684,9 @@
(defn- remove-matching-ref [column refs]
(let [match (or (lib.equality/find-matching-ref column refs)
- (log/warnf "[remove-matching-ref] Failed to find match for column\n%s\nin refs:\n%s"
- (u/pprint-to-str column)
- (u/pprint-to-str refs)))]
+ (log/warnf "[remove-matching-ref] Failed to find match for column %s in %d refs"
+ (:id column)
+ (count refs)))]
(remove #(= % match) refs)))
(defn- exclude-field
@@ -703,7 +702,7 @@
;; If we couldn't find the field, return the original query unchanged.
(< (count new-fields) (count old-fields)) (lib.util/update-query-stage stage-number assoc :fields new-fields))
(when (= <> query)
- (log/errorf "[exclude-field] Failed to remove field %s, query is unchanged." (pr-str ((some-fn :display-name :name) column)))))))
+ (log/errorf "[exclude-field] Failed to remove field %s, query is unchanged." (:id column))))))
(defn- remove-field-from-join [query stage-number column]
(let [join (lib.join/resolve-join query stage-number (:lib/join-alias column))
diff --git a/src/metabase/lib/field/resolution.cljc b/src/metabase/lib/field/resolution.cljc
index 0d7b1e6ee16..483cbd52a56 100644
--- a/src/metabase/lib/field/resolution.cljc
+++ b/src/metabase/lib/field/resolution.cljc
@@ -119,10 +119,10 @@
(if <>
(log/debugf "Found match %s"
(pr-str (select-keys <> [:id :lib/desired-column-alias :lib/deduplicated-name])))
- (log/debugf "Failed to find match for %s. Found:\n%s"
+ (log/debugf "Failed to find match for %s. Found: %s"
(pr-str id-or-name)
- (u/pprint-to-str (map #(select-keys % [:id :lib/desired-column-alias :lib/deduplicated-name])
- previous-stage-cols)))))))
+ (pr-str (map #(select-keys % [:id :lib/desired-column-alias :lib/deduplicated-name])
+ previous-stage-cols)))))))
(def ^:private opts-propagated-keys
"Keys to copy non-nil values directly from `:field` opts into column metadata."
@@ -515,10 +515,10 @@
(m/find-first #(= (:id %) id-or-name) current-stage-metadata-columns))
(if <>
(log/debugf "Found match: %s" (pr-str (select-keys <> [:id :lib/source-column-alias :lib/deduplicated-name])))
- (log/debugf "Failed to find match for %s. Found:\n%s"
+ (log/debugf "Failed to find match for %s. Found: %s"
(pr-str id-or-name)
- (u/pprint-to-str (map #(select-keys % [:id :lib/source-column-alias :lib/deduplicated-name])
- current-stage-metadata-columns)))))))))
+ (pr-str (map #(select-keys % [:id :lib/source-column-alias :lib/deduplicated-name])
+ current-stage-metadata-columns)))))))))
(mu/defn- resolve-in-source-card-metadata :- [:maybe ::lib.metadata.calculation/visible-column]
[query :- ::lib.schema/query
diff --git a/src/metabase/lib/join.cljc b/src/metabase/lib/join.cljc
index 9c3a94f8e4f..0d684601571 100644
--- a/src/metabase/lib/join.cljc
+++ b/src/metabase/lib/join.cljc
@@ -180,7 +180,7 @@
;; this should not happen (and cannot happen in CLJ land)
;; but it does seem to happen in JS land with broken MLv1 queries
- (do (log/error "with-join-value should not be called with" (pr-str field-or-join))
+ (do (log/error "with-join-value should not be called with this type of value")
field-or-join)))
(mu/defn maybe-resolve-join :- [:maybe ::lib.schema.join/join]
@@ -371,10 +371,7 @@
(with-join-alias field-ref nil))]
(when-not (:metabase.lib.field.resolution/fallback-metadata? resolved)
resolved))
- (log/debugf "Failed to find matching column in join %s for ref %s, found:\n%s"
- (pr-str join-alias)
- (pr-str field-ref)
- (pr-str (map (juxt :id :lib/join-alias :lib/source-column-alias) cols))))]
+ (log/debug "Failed to find matching column in join for ref"))]
:when (and match
(not (false? (:active match))))]
diff --git a/src/metabase/lib/js/metadata.cljc b/src/metabase/lib/js/metadata.cljc
index db36d433a5e..2a0cf5761ca 100644
--- a/src/metabase/lib/js/metadata.cljc
+++ b/src/metabase/lib/js/metadata.cljc
@@ -146,10 +146,10 @@
(fn [object]
(try
(let [parsed (assoc (obj->clj xform object opts) :lib/type lib-type-name)]
- (log/debugf "Parsed metadata %s %s\n%s" object-type (:id parsed) (u/pprint-to-str parsed))
+ (log/debugf "Parsed metadata %s %s" object-type (:id parsed))
parsed)
(catch #?(:cljs js/Error :clj Exception) e
- (log/errorf e "Error parsing %s %s: %s" object-type (pr-str object) (ex-message e))
+ (log/errorf "Error parsing %s: %s" object-type (ex-message e))
nil)))))
(defmulti ^:private parse-objects
@@ -535,7 +535,7 @@
(try
(parse-objects object-type metadata)
(catch #?(:cljs js/Error :clj Exception) e
- (log/errorf e "Error parsing %s objects: %s" object-type (ex-message e))
+ (log/errorf "Error parsing %s objects: %s" object-type (ex-message e))
nil))))
(defn- card->metric-card
diff --git a/src/metabase/lib/metadata/calculation.cljc b/src/metabase/lib/metadata/calculation.cljc
index ed325b91932..7798ca62d0b 100644
--- a/src/metabase/lib/metadata/calculation.cljc
+++ b/src/metabase/lib/metadata/calculation.cljc
@@ -108,12 +108,7 @@
:cljs true ;; the linter complains when :cljs is not here(?)
:cljs-dev true
:cljs-release false)
- (log/warnf "Don't know how to calculate display name for %s. Add an impl for %s for %s"
- ;; TODO: (Braden 11/04/2025) This logic would make sense in [[metabase.util]].
- (let [s (pr-str x)]
- (if (> (count s) 2000)
- (str (subs s 0 1500) " ... " (subs s (- (count s) 500)))
- s))
+ (log/warnf "Don't know how to calculate display name. Add an impl for %s for %s"
`display-name-method
(lib.dispatch/dispatch-value x)))
(if (and (vector? x)
@@ -311,7 +306,7 @@
;; Throttled: a bulk caller such as a search reindex can hit this for many failing metric Cards,
;; so don't log every one.
(log/throttle (* 10 1000)
- (log/errorf e "Error calculating display name for query: %s" (ex-message e)))
+ (log/errorf "Error calculating display name for query: %s" (ex-message e)))
nil))))
(defmulti display-info-method
diff --git a/src/metabase/lib/metadata/result_metadata.cljc b/src/metabase/lib/metadata/result_metadata.cljc
index b2b8406f0e6..3e65a8a4740 100644
--- a/src/metabase/lib/metadata/result_metadata.cljc
+++ b/src/metabase/lib/metadata/result_metadata.cljc
@@ -132,7 +132,7 @@
;; meantime -- see
;; https://metaboat.slack.com/archives/C0645JP1W81/p1757457633926199?thread_ts=1757457374.178329&cid=C0645JP1W81
(do
- (log/error e)
+ (log/error (ex-message e))
(mapv merge-col
initial-cols
;; `util.perf/mapv` checks the `count` of all args, so it's NSFIS - Not Safe For Infinite Seqs.
@@ -177,8 +177,7 @@
(when-let [expr (try
(lib.expression/resolve-expression query expression-name)
(catch #?(:clj Throwable :cljs :default) e
- (log/error e "Column metadata has invalid :lib/expression-name (this was probably incorrectly propagated from a previous stage) (QUE-1342)")
- (log/debugf "In query:\n%s" (u/pprint-to-str query))
+ (log/errorf "Column metadata has invalid :lib/expression-name (this was probably incorrectly propagated from a previous stage) (QUE-1342): %s" (ex-message e))
nil))]
(match/match-one expr
[:convert-timezone _opts _expr source-tz & _]
diff --git a/src/metabase/lib/normalize.cljc b/src/metabase/lib/normalize.cljc
index 0d12da49574..f267beaad6d 100644
--- a/src/metabase/lib/normalize.cljc
+++ b/src/metabase/lib/normalize.cljc
@@ -8,7 +8,6 @@
[metabase.lib.schema.mbql-clause :as lib.schema.mbql-clause]
[metabase.lib.schema.metadata :as lib.schema.metadata]
[metabase.lib.util :as lib.util]
- [metabase.util :as u]
[metabase.util.i18n :as i18n]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
@@ -49,9 +48,8 @@
"If normalization errors somewhere, just log the error and return the partially-normalized result. Easier to debug
this way."
[error]
- (log/debugf "Error normalizing MBQL 5: %s\n%s"
- (pr-str (me/humanize (:explain error)))
- (u/pprint-to-str (dissoc error :explain)))
+ (log/debugf "Error normalizing MBQL 5: %s"
+ (pr-str (me/humanize (:explain error))))
(:value error))
(def ^:private ^:dynamic *error-fn*
diff --git a/src/metabase/lib/parse.cljc b/src/metabase/lib/parse.cljc
index 682043765ef..76ceab75476 100644
--- a/src/metabase/lib/parse.cljc
+++ b/src/metabase/lib/parse.cljc
@@ -3,9 +3,7 @@
(:refer-clojure :exclude [some empty? #?(:clj for)])
(:require
[clojure.string :as str]
- [metabase.util :as u]
[metabase.util.i18n :refer [tru]]
- [metabase.util.log :as log]
[metabase.util.performance :refer [some empty? #?(:clj for)]]))
(defn- combine-adjacent-strings
@@ -182,7 +180,4 @@
(let [tokenized (tokenize s handle-sql-comments)]
(if (= [s] tokenized)
[s]
- (do
- (log/tracef "Tokenized native query ->\n%s" (u/pprint-to-str tokenized))
- (u/prog1 (combine-adjacent-strings (first (parse-tokens* opts tokenized 0 0 false nil)))
- (log/tracef "Parsed native query ->\n%s" (u/pprint-to-str <>))))))))
+ (combine-adjacent-strings (first (parse-tokens* opts tokenized 0 0 false nil)))))))
diff --git a/src/metabase/lib/query.cljc b/src/metabase/lib/query.cljc
index 77727276af6..75590878365 100644
--- a/src/metabase/lib/query.cljc
+++ b/src/metabase/lib/query.cljc
@@ -439,8 +439,7 @@
{:query (query a-query card)
:stage-number -1}
(do
- (log/warn "Failed to wrap native query with MBQL; card not found" {:query a-query
- :card-id card-id})
+ (log/warn "Failed to wrap native query with MBQL; card not found" {:card-id card-id})
nil)))
{:query a-query
:stage-number stage-number}))
diff --git a/src/metabase/lib/remove_replace.cljc b/src/metabase/lib/remove_replace.cljc
index 19de08768a3..8fa16f6c16b 100644
--- a/src/metabase/lib/remove_replace.cljc
+++ b/src/metabase/lib/remove_replace.cljc
@@ -97,8 +97,8 @@
(if-let [new-column (some-> old-matching-column :lib/source-uuid source-uuid->new-column)]
(assoc &match 2 ((some-fn :lib/source-column-alias :name) new-column))
(do
- (log/warnf "Failed to match downstream ref %s against visible columns, ref is on stage %d at %s"
- &match stage-number &parents)
+ (log/warnf "Failed to match downstream ref against visible columns, ref is on stage %d at %s"
+ stage-number &parents)
&match)))))))
(defn update-stale-references
diff --git a/src/metabase/lib/swap.cljc b/src/metabase/lib/swap.cljc
index b10645dfb7e..bda4bbd7d83 100644
--- a/src/metabase/lib/swap.cljc
+++ b/src/metabase/lib/swap.cljc
@@ -7,11 +7,11 @@
[metabase.lib.util :as lib.util]
[metabase.util.log :as log]))
-(defn- swap-failure-no-match [stage target-clause]
- (log/warn "No matching clause in swap-clauses" target-clause stage))
+(defn- swap-failure-no-match [_stage _target-clause]
+ (log/warn "No matching clause in swap-clauses"))
-(defn- swap-failure-ambiguous [target-clause matches]
- (log/warn "Ambiguous match for clause in swap-clauses" target-clause matches))
+(defn- swap-failure-ambiguous [_target-clause matches]
+ (log/warnf "Ambiguous match for clause in swap-clauses (%d matches)" (count matches)))
(defn- uuid-match [stage target-clause]
(let [target-uuid (lib.options/uuid target-clause)
diff --git a/src/metabase/lib_be/models/transforms.clj b/src/metabase/lib_be/models/transforms.clj
index 5093f31e45f..0ffb4a73137 100644
--- a/src/metabase/lib_be/models/transforms.clj
+++ b/src/metabase/lib_be/models/transforms.clj
@@ -78,7 +78,7 @@
(fn [e]
(when strict?
(throw e))
- (log/errorf e "Error normalizing query %s" (pr-str query))
+ (log/errorf "Error normalizing query: %s" (ex-message e))
{}))))
(defn- transform-query-in [query]
@@ -101,7 +101,7 @@
{:query query})))
(normalize-query query)))
(fn [e]
- (log/errorf e "Error deserializing dataset_query from app DB: %s" (ex-message e))
+ (log/errorf "Error deserializing dataset_query from app DB: %s" (ex-message e))
{}))))
(def transform-query
diff --git a/src/metabase/llm/context.clj b/src/metabase/llm/context.clj
index 29cd8dbbd32..b044ff11022 100644
--- a/src/metabase/llm/context.clj
+++ b/src/metabase/llm/context.clj
@@ -77,7 +77,7 @@
(into #{} (map :id) matched-tables))
#{}))
(catch Exception e
- (log/warn e "Failed to extract tables from source SQL")
+ (log/warnf "Failed to extract tables from source SQL: %s" (ex-message e))
#{}))
#{}))
diff --git a/src/metabase/login_history/record.clj b/src/metabase/login_history/record.clj
index 0cfabd40859..51289f34271 100644
--- a/src/metabase/login_history/record.clj
+++ b/src/metabase/login_history/record.clj
@@ -27,7 +27,7 @@
(let [[info] (login-history/human-friendly-infos [history-record])]
(messages/send-login-from-new-device-email! info))
(catch Throwable e
- (log/error e "Error sending 'login from new device' notification email")))))))
+ (log/errorf "Error sending 'login from new device' notification email: %s" (ex-message e))))))))
(mu/defn record-login-history!
"Record login history for a user, and send them an email if this is their first time logging in from this device."
diff --git a/src/metabase/mcp/api.clj b/src/metabase/mcp/api.clj
index d32b865c3fe..7e2764b77a0 100644
--- a/src/metabase/mcp/api.clj
+++ b/src/metabase/mcp/api.clj
@@ -140,7 +140,7 @@
(jsonrpc-error id -32601 (str "Method not found: " method))
nil))
(catch Throwable e
- (log/error e "Error dispatching JSON-RPC method" method)
+ (log/error "Error dispatching JSON-RPC method" method (ex-message e))
(jsonrpc-error id -32603 (or (ex-message e) "Internal error")))))
(defn- dispatch-request
diff --git a/src/metabase/measures/models/measure.clj b/src/metabase/measures/models/measure.clj
index c1a69b2815a..2d3442084dc 100644
--- a/src/metabase/measures/models/measure.clj
+++ b/src/metabase/measures/models/measure.clj
@@ -161,7 +161,7 @@
(try
(assoc measure :definition (lib-be/normalize-query definition))
(catch Throwable e
- (log/error e "Error normalizing measure definition:" (ex-message e))
+ (log/errorf "Error normalizing measure definition: %s" (ex-message e))
measure))
measure))
@@ -176,7 +176,7 @@
(try
(lib/describe-top-level-key definition :aggregation)
(catch Throwable e
- (log/error e "Error calculating Measure description:" (ex-message e))
+ (log/errorf "Error calculating Measure description: %s" (ex-message e))
nil))))
(methodical/defmethod t2.hydrate/batched-hydrate [:model/Measure :definition_description]
diff --git a/src/metabase/metabot/agent/core.clj b/src/metabase/metabot/agent/core.clj
index 7342e692eee..19943ebf61f 100644
--- a/src/metabase/metabot/agent/core.clj
+++ b/src/metabase/metabot/agent/core.clj
@@ -17,7 +17,6 @@
[metabase.metabot.schema :as metabot.schema]
[metabase.metabot.scope :as scope]
[metabase.metabot.self :as self]
- [metabase.metabot.self.core :as self.core]
[metabase.metabot.tools :as tools]
[metabase.util :as u]
[metabase.util.json :as json]
@@ -566,7 +565,7 @@
(.write w (json/encode debug-log {:pretty true})))
(log/debug "Wrote debug log to" debug-log-file)
(catch Exception e
- (log/warn e "Failed to write debug log file")))))
+ (log/warnf "Failed to write debug log file: %s" (ex-message e))))))
(defn- debug-log-part
"Create a data part containing the complete debug log.
@@ -709,23 +708,23 @@
turn-result))
(catch Exception e
(analytics/inc! :metabase-metabot/agent-errors labels)
- (let [{:keys [api-error status provider body]} (ex-data e)
+ (let [{:keys [api-error status provider]} (ex-data e)
msg (ex-message e)]
(cond
(and api-error status)
- (log/errorf e "Agent loop API error: %s status=%s provider=%s body=%s"
- msg status provider (self.core/body-for-log body))
+ (log/errorf "Agent loop API error: %s status=%s provider=%s"
+ msg status provider)
api-error
- (log/errorf e "Agent loop API error: %s provider=%s" msg provider)
+ (log/errorf "Agent loop API error: %s provider=%s" msg provider)
;; ex-message can be nil/blank for exceptions thrown without a message
;; (e.g. (NullPointerException.)) — skip the colon when there's nothing to say.
(str/blank? msg)
- (log/error e "Agent loop error")
+ (log/error "Agent loop error")
:else
- (log/errorf e "Agent loop error: %s" msg)))
+ (log/errorf "Agent loop error: %s" msg)))
(rf init (error-part e)))
(finally
(analytics/observe! :metabase-metabot/agent-duration-ms labels (u/since-ms start-ms)))))))))))
diff --git a/src/metabase/metabot/agent/messages.clj b/src/metabase/metabot/agent/messages.clj
index ed630f1dde7..c2a29bee09f 100644
--- a/src/metabase/metabot/agent/messages.clj
+++ b/src/metabase/metabot/agent/messages.clj
@@ -33,7 +33,7 @@
(try
(json/decode+kw arguments)
(catch Exception e
- (log/warn e "Failed to decode tool call arguments" {:arguments arguments})
+ (log/warnf "Failed to decode tool call arguments: %s" (ex-message e))
arguments))
arguments))
diff --git a/src/metabase/metabot/agent/prompts.clj b/src/metabase/metabot/agent/prompts.clj
index 84444388bae..f6fccd34ffc 100644
--- a/src/metabase/metabot/agent/prompts.clj
+++ b/src/metabase/metabot/agent/prompts.clj
@@ -67,7 +67,7 @@
(try
(selmer/render template context)
(catch Exception e
- (log/error e "Error rendering system prompt template")
+ (log/errorf "Error rendering system prompt template: %s" (ex-message e))
;; Return template as-is on error
template)))
diff --git a/src/metabase/metabot/agent/user_context.clj b/src/metabase/metabot/agent/user_context.clj
index 832cd3309eb..ca3be09af60 100644
--- a/src/metabase/metabot/agent/user_context.clj
+++ b/src/metabase/metabot/agent/user_context.clj
@@ -42,7 +42,7 @@
:else
(.format DateTimeFormatter/ISO_LOCAL_DATE_TIME (OffsetDateTime/now)))
(catch Exception e
- (log/error e "Error formatting current time")
+ (log/errorf "Error formatting current time: %s" (ex-message e))
(.format DateTimeFormatter/ISO_LOCAL_DATE_TIME (OffsetDateTime/now)))))
;;; SQL Dialect Extraction
@@ -135,7 +135,7 @@
(te/lines preamble (format-fn structured-output))
(format-simple-entity entity)))
(catch Exception e
- (log/error e "Error fetching entity details for viewing context" {:type (:type entity) :id (:id entity)})
+ (log/error "Error fetching entity details for viewing context" {:type (:type entity) :id (:id entity)} (ex-message e))
(format-simple-entity entity))))
(defmethod format-entity "table"
@@ -354,7 +354,7 @@
(try
(format-entity item)
(catch Exception e
- (log/error e "Error formatting viewing context item:" (:type item))
+ (log/error "Error formatting viewing context item:" (:type item) (ex-message e))
"")))))
;;; Recent Views Formatting
@@ -387,7 +387,7 @@
:email email-address
:glossary glossary}))
(catch Exception e
- (log/error e "Error formatting current user info")
+ (log/errorf "Error formatting current user info: %s" (ex-message e))
nil)))
;;; Context Enrichment
diff --git a/src/metabase/metabot/api.clj b/src/metabase/metabot/api.clj
index e103c7229b6..29031c98ebd 100644
--- a/src/metabase/metabot/api.clj
+++ b/src/metabase/metabot/api.clj
@@ -247,10 +247,11 @@
;; the socket cleanly when this body fn returns. The error is fully
;; captured in the row via the `finally` below and in the log here.
(vreset! thrown t)
- (log/error t "Native agent stream failed"
+ (log/error "Native agent stream failed"
{:conversation-id conversation-id
:assistant-msg-id assistant-msg-id
- :external-id external-id})
+ :external-id external-id
+ :error (ex-message t)})
;; Stream a well-formed AI SDK error tail so the client surfaces the failure
;; instead of treating the truncated stream as a silent success. Unlike binary
;; downloads (which abort the connection), an event stream carries its own error
@@ -284,10 +285,11 @@
:error error-data
:turn-state (some-> @memory-atom memory/turn-state)))
(catch Exception e
- (log/error e "Failed to finalize assistant turn"
+ (log/error "Failed to finalize assistant turn"
{:conversation-id conversation-id
:assistant-msg-id assistant-msg-id
- :external-id external-id})))))))))
+ :external-id external-id
+ :error (ex-message e)})))))))))
(defn streaming-request
"Handles an incoming request, making all required tool invocation, LLM call loops, etc.
diff --git a/src/metabase/metabot/context.clj b/src/metabase/metabot/context.clj
index 49b5654bc4d..7db97860375 100644
--- a/src/metabase/metabot/context.clj
+++ b/src/metabase/metabot/context.clj
@@ -149,7 +149,7 @@
(table-utils/used-tables query))
[])
(catch Exception e
- (log/error e "Error getting database tables for context")
+ (log/errorf "Error getting database tables for context: %s" (ex-message e))
[])))
(defn- python-transform-db-and-table-ids
@@ -169,7 +169,7 @@
(when (and database-id (seq table-ids))
(not-empty (mapv table-stub (table-utils/used-tables-from-ids database-id table-ids))))
(catch Exception e
- (log/error e "Error getting Python transform tables for context")
+ (log/errorf "Error getting Python transform tables for context: %s" (ex-message e))
[])))
(defn- mbql-source-table-ids
@@ -207,7 +207,7 @@
(map table-stub))
raw-tables))
(catch Exception e
- (log/error e "Error getting MBQL source tables for context")
+ (log/errorf "Error getting MBQL source tables for context: %s" (ex-message e))
nil)))
(defn- enhance-context-with-schema
@@ -249,7 +249,7 @@
:source_type (transforms-base.u/transform-source-type (:source transform))))
item)
(catch Exception e
- (log/error e "Error annotating transform source type for metabot context")
+ (log/errorf "Error annotating transform source type for metabot context: %s" (ex-message e))
item)))
user-viewing)]
(assoc context :user_is_viewing annotated-viewing))
@@ -317,7 +317,7 @@
(assoc :type item-type))))
(take 5 recents)))))
(catch Exception e
- (log/error e "Error adding recent views to metabot context")
+ (log/errorf "Error adding recent views to metabot context: %s" (ex-message e))
context)))
(defn- set-user-time
diff --git a/src/metabase/metabot/conversation_title.clj b/src/metabase/metabot/conversation_title.clj
index 4ae289e36af..617df621323 100644
--- a/src/metabase/metabot/conversation_title.clj
+++ b/src/metabase/metabot/conversation_title.clj
@@ -169,8 +169,9 @@
:timeout-ms title-timeout-ms})
nil)
(catch ExecutionException e
- (log/warn (.getCause e) "Metabot title generation failed"
- {:conversation-id conversation-id})
+ (log/warn "Metabot title generation failed"
+ {:conversation-id conversation-id
+ :error (ex-message (.getCause e))})
nil)
(catch InterruptedException _
(.interrupt (Thread/currentThread))
@@ -195,8 +196,9 @@
(bound-fn* #(try
(generate-with-timeout! conversation-id profile-id message)
(catch Throwable t
- (log/warn t "Failed to generate Metabot conversation title"
- {:conversation-id conversation-id})
+ (log/warn "Failed to generate Metabot conversation title"
+ {:conversation-id conversation-id
+ :error (ex-message t)})
nil)
(finally
(when-let [task @task-ref]
@@ -240,8 +242,9 @@
(or (.get title-future)
(current-title conversation-id))
(catch ExecutionException e
- (log/warn (.getCause e) "Metabot title generation failed"
- {:conversation-id conversation-id})
+ (log/warn "Metabot title generation failed"
+ {:conversation-id conversation-id
+ :error (ex-message (.getCause e))})
nil)
(catch CancellationException _
nil)
diff --git a/src/metabase/metabot/example_question_generator.clj b/src/metabase/metabot/example_question_generator.clj
index caac8e82a4a..2137087ac8c 100644
--- a/src/metabase/metabot/example_question_generator.clj
+++ b/src/metabase/metabot/example_question_generator.clj
@@ -166,7 +166,7 @@
{:ok (generate-fn item)}
(catch Throwable e
(when-not (= :api-key-missing (:error-code (ex-data e)))
- (log/warn e "Example question generation failed for one item"))
+ (log/warnf "Example question generation failed for one item: %s" (ex-message e)))
{:error e}))))
batch)]
(mapv deref futures)))
diff --git a/src/metabase/metabot/models/metabot_message.clj b/src/metabase/metabot/models/metabot_message.clj
index de36d21750e..f474d1fb658 100644
--- a/src/metabase/metabot/models/metabot_message.clj
+++ b/src/metabase/metabot/models/metabot_message.clj
@@ -31,7 +31,7 @@
(schema.v2/check-message-data "migrated metabot_message.data")))
(assoc :data_version schema.v2/current-data-version))
(catch Throwable e
- (log/warn e "Failed to migrate metabot_message data v1->v2 on read" {:id (:id message)})
+ (log/warn "Failed to migrate metabot_message data v1->v2 on read" {:id (:id message)} (ex-message e))
message)))
(t2/define-after-select :model/MetabotMessage
diff --git a/src/metabase/metabot/self.clj b/src/metabase/metabot/self.clj
index f4a9700dc2a..a35a76bf200 100644
--- a/src/metabase/metabot/self.clj
+++ b/src/metabase/metabot/self.clj
@@ -258,11 +258,12 @@
(retry? e)
(retryable-error? e))
(let [delay (retry-delay-ms attempt e)]
- (log/warn e "LLM call failed with retryable error, retrying"
+ (log/warn "LLM call failed with retryable error, retrying"
{:attempt attempt
:max max-llm-retries
:delay delay
- :status (:status (ex-data e))})
+ :status (:status (ex-data e))
+ :error (ex-message e)})
(analytics/inc! :metabase-metabot/llm-retries labels)
{:retry delay})
(do (analytics/inc! :metabase-metabot/llm-errors
diff --git a/src/metabase/metabot/self/core.clj b/src/metabase/metabot/self/core.clj
index 0044f6f5ed6..b90c318713d 100644
--- a/src/metabase/metabot/self/core.clj
+++ b/src/metabase/metabot/self/core.clj
@@ -110,7 +110,7 @@
:else
(do
- (log/warn "SSE unexpected line" {:line line})
+ (log/warn "SSE unexpected line" {:line-len (count line)})
(recur acc)))
acc)))))
@@ -544,7 +544,7 @@
arguments (or (coerce-stringified-json arguments) {})
decode (tool-decode-fn tool)
arguments (cond-> arguments decode decode)]
- (log/debug "Executing tool" {:tool-name tool-name :arguments arguments})
+ (log/debug "Executing tool" {:tool-name tool-name})
(when (ait/capture-active?)
(ait/record! {:ai/tool-args arguments}))
(let [tool-fn (tool-call-fn tool)
@@ -554,7 +554,7 @@
(catch Exception e
(if (:agent-error? (ex-data e))
(log/debugf "Tool %s: agent validation error: %s" tool-name (ex-message e))
- (log/warn e "Tool execution failed" {:tool-name tool-name}))
+ (log/warn "Tool execution failed" {:tool-name tool-name :error (ex-message e)}))
[{:type :tool-output-available
:toolCallId tool-call-id
:toolName tool-name
@@ -735,15 +735,16 @@
(def ^:private auth-error-statuses
"Statuses whose upstream body may carry provider-side auth/account detail
- (raw API keys, org/account names, tenant IDs). The full body still hits the
- warn log; we just don't splice it into the message the caller sees."
+ (raw API keys, org/account names, tenant IDs). For these we don't splice a
+ body preview into the message the caller sees."
#{401 403})
(defn rethrow-api-error!
"Rethrow a provider HTTP exception with a translated, user-facing message.
`res->message` receives the decoded response map and returns the provider-specific message.
A body preview is appended to the message except on 401/403 (see [[auth-error-statuses]]),
- where the body may carry sensitive auth/account detail; the full body is still logged.
+ where the body may carry sensitive auth/account detail. The warn log carries provider and
+ status only — response bodies are never logged; the full body travels on the thrown ex-data.
ex-data is an explicit allow-list of `:status`, `:reason-phrase`, `:headers`, `:body`, plus provider tags.
Exceptions already tagged `:api-error true` are rethrown unchanged."
[provider res->message ^Throwable e]
@@ -759,11 +760,8 @@
(body-preview (:body res)))
msg (cond-> base
preview (str " — " preview))]
- ;; warnf (not warn) so the body renders into the message string, not as MDC.
- ;; body-for-log caps the pr-str so a near-cap slurped stream can't flood the logs;
- ;; the full body still survives in ex-data below.
- (log/warnf "Provider API request failed: provider=%s status=%s body=%s"
- provider (:status res) (body-for-log (:body res)))
+ (log/warnf "Provider API request failed: provider=%s status=%s"
+ provider (:status res))
;; Allow-list explicitly — clj-http responses carry :http-client (a Closeable),
;; :trace-redirects, :orig-content-encoding, etc., none of which should propagate downstream.
;; :headers is included so the retry path in metabase.metabot.self/parse-retry-after-header
diff --git a/src/metabase/metabot/self/debug.clj b/src/metabase/metabot/self/debug.clj
index 1a5aaae7ece..b0e1ded0404 100644
--- a/src/metabase/metabot/self/debug.clj
+++ b/src/metabase/metabot/self/debug.clj
@@ -49,7 +49,7 @@
(.write w ^String (json/encode entry {:pretty true})))
(log/debugf "Wrote AI request log to %s" (.getPath f)))
(catch Exception e
- (log/warn e "Failed to write AI request log")))))
+ (log/warnf "Failed to write AI request log: %s" (ex-message e))))))
(defn capture-stream
"Wrap an SSE reducible so every raw provider event is teed into a vector while
diff --git a/src/metabase/metabot/task/conversation_title_backfill.clj b/src/metabase/metabot/task/conversation_title_backfill.clj
index 8f044179769..829869cf51b 100644
--- a/src/metabase/metabot/task/conversation_title_backfill.clj
+++ b/src/metabase/metabot/task/conversation_title_backfill.clj
@@ -95,8 +95,8 @@
(.interrupt (Thread/currentThread))
:failed)
(catch Throwable e
- (log/warn e "Failed to backfill Metabot conversation title"
- {:conversation-id conversation-id})
+ (log/warn "Failed to backfill Metabot conversation title"
+ {:conversation-id conversation-id :error (ex-message e)})
:failed)))
(defn- finish-result
diff --git a/src/metabase/metabot/task/suggested_prompts_refresh.clj b/src/metabase/metabot/task/suggested_prompts_refresh.clj
index ba4f14c0e51..f23f11ffa4b 100644
--- a/src/metabase/metabot/task/suggested_prompts_refresh.clj
+++ b/src/metabase/metabot/task/suggested_prompts_refresh.clj
@@ -52,9 +52,9 @@
(if (::preserve (ex-data e))
(log/infof "Kept existing suggested prompts for Metabot %s (regeneration produced %s)"
metabot-id (:status (ex-data e)))
- (log/warnf e "Failed to regenerate suggested prompts for Metabot %s" metabot-id)))
+ (log/warnf "Failed to regenerate suggested prompts for Metabot %s: %s" metabot-id (ex-message e))))
(catch Throwable e
- (log/warnf e "Failed to regenerate suggested prompts for Metabot %s" metabot-id)))))
+ (log/warnf "Failed to regenerate suggested prompts for Metabot %s: %s" metabot-id (ex-message e))))))
(task/defjob ^{DisallowConcurrentExecution true
:doc "Regenerate a Metabot's suggested prompts after its content scope changes."}
diff --git a/src/metabase/metabot/tools/analyze_chart.clj b/src/metabase/metabot/tools/analyze_chart.clj
index 43f63ee1182..2ce00ca8d3d 100644
--- a/src/metabase/metabot/tools/analyze_chart.clj
+++ b/src/metabase/metabot/tools/analyze_chart.clj
@@ -102,5 +102,5 @@ Do not use headers (##). Do not list statistics. Do not analyze series separatel
{:output (str "Chart config not found: " chart_config_id
". Available chart configs can be found in the viewing context.")})
(catch Exception e
- (log/error e "Error analyzing chart")
+ (log/errorf "Error analyzing chart: %s" (ex-message e))
{:output (str "Failed to analyze chart: " (or (ex-message e) "Unknown error"))})))
diff --git a/src/metabase/metabot/tools/autogen_dashboard.clj b/src/metabase/metabot/tools/autogen_dashboard.clj
index 38cb7ca9489..3ae6c03d635 100644
--- a/src/metabase/metabot/tools/autogen_dashboard.clj
+++ b/src/metabase/metabot/tools/autogen_dashboard.clj
@@ -153,7 +153,7 @@
:instructions (:instructions result)}
(seq data-parts) (assoc :data-parts data-parts)))
(catch Exception e
- (log/error e "Error creating autogenerated dashboard")
+ (log/errorf "Error creating autogenerated dashboard: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to create autogenerated dashboard: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/charts.clj b/src/metabase/metabot/tools/charts.clj
index e1e71e5a7f3..22c53ef4e61 100644
--- a/src/metabase/metabot/tools/charts.clj
+++ b/src/metabase/metabot/tools/charts.clj
@@ -62,7 +62,7 @@
:title title
:description description})]})
(catch Exception e
- (log/error e "Error creating chart")
+ (log/errorf "Error creating chart: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to create chart: " (or (ex-message e) "Unknown error"))}))))
@@ -110,7 +110,7 @@
:title title
:description description})]})
(catch Exception e
- (log/error e "Error editing chart")
+ (log/errorf "Error editing chart: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to edit chart: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/charts/create.clj b/src/metabase/metabot/tools/charts/create.clj
index 81bd42a757c..4c2da2fbf4c 100644
--- a/src/metabase/metabot/tools/charts/create.clj
+++ b/src/metabase/metabot/tools/charts/create.clj
@@ -70,8 +70,7 @@
:query-id query-id
:chart-type chart-type}]
(log/info "Created chart" {:chart-id chart-id
- :chart-type chart-type
- :results-url results-url})
+ :chart-type chart-type})
{:chart-id chart-id
:chart-content (format-chart-for-llm chart-data)
:chart-link (format-chart-link chart-id)
diff --git a/src/metabase/metabot/tools/clarification.clj b/src/metabase/metabot/tools/clarification.clj
index 9230aab7604..278ee491f8f 100644
--- a/src/metabase/metabot/tools/clarification.clj
+++ b/src/metabase/metabot/tools/clarification.clj
@@ -24,8 +24,7 @@
- :structured-output - The question and options for the LLM
- :instructions - Instructions for the LLM"
[{:keys [question options]}]
- (log/info "Asking for SQL clarification" {:question question
- :option-count (count options)})
+ (log/info "Asking for SQL clarification" {:option-count (count options)})
{:structured-output {:question question
:options (or options [])}
:instructions "The clarification question has been presented to the user. Stop and wait for their response before continuing."})
diff --git a/src/metabase/metabot/tools/construct.clj b/src/metabase/metabot/tools/construct.clj
index 5ffda087e00..cb4b2a8e700 100644
--- a/src/metabase/metabot/tools/construct.clj
+++ b/src/metabase/metabot/tools/construct.clj
@@ -502,9 +502,8 @@
;; URI-in-source-table, …). Log at debug only — no stacktrace — since the message
;; is the tool's result and the LLM is expected to self-correct on the next turn.
(do
- (log/debug e "construct_notebook_query returned agent-error to the LLM")
+ (log/debugf "construct_notebook_query returned agent-error to the LLM: %s" (ex-message e))
{:output (ex-message e)})
- ;; Genuine unexpected failure — keep full stacktrace.
(do
- (log/error e "Failed to construct notebook query")
+ (log/errorf "Failed to construct notebook query: %s" (ex-message e))
{:output (str "Failed to construct notebook query: " (or (ex-message e) "Unknown error"))})))))
diff --git a/src/metabase/metabot/tools/create_alert.clj b/src/metabase/metabot/tools/create_alert.clj
index 83ae144cea5..c6a663252d9 100644
--- a/src/metabase/metabot/tools/create_alert.clj
+++ b/src/metabase/metabot/tools/create_alert.clj
@@ -158,5 +158,5 @@ NEVER tell the user you have created an alert without actually calling the creat
{:output (:error result)}
{:output (or (:output result) "Alert created successfully.")}))
(catch Exception e
- (log/error e "Failed to create alert")
+ (log/errorf "Failed to create alert: %s" (ex-message e))
{:output (str "Failed to create alert: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/create_dashboard_subscription.clj b/src/metabase/metabot/tools/create_dashboard_subscription.clj
index fabea535c63..709caf0e929 100644
--- a/src/metabase/metabot/tools/create_dashboard_subscription.clj
+++ b/src/metabase/metabot/tools/create_dashboard_subscription.clj
@@ -117,5 +117,5 @@ If any required information is missing, ask the user for it rather than assuming
{:output (:error result)}
{:output (or (:output result) "Dashboard subscription created successfully.")}))
(catch Exception e
- (log/error e "Failed to create dashboard subscription")
+ (log/errorf "Failed to create dashboard subscription: %s" (ex-message e))
{:output (str "Failed to create dashboard subscription: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/document.clj b/src/metabase/metabot/tools/document.clj
index 53e599541b0..aad45bdb0c0 100644
--- a/src/metabase/metabot/tools/document.clj
+++ b/src/metabase/metabot/tools/document.clj
@@ -123,7 +123,7 @@
:structured-output {:database_id database-id
:sql_engine (:engine db)}})))
(catch Exception e
- (log/error e "Error collecting document schema")
+ (log/errorf "Error collecting document schema: %s" (ex-message e))
{:output (str "Failed to collect schema: " (or (ex-message e) "Unknown error"))})))
(def ^:private sql-chart-schema
@@ -173,7 +173,7 @@
{:output "Draft chart payload generated from SQL query."
:structured-output structured}))))
(catch Exception e
- (log/error e "Error constructing SQL chart draft")
+ (log/errorf "Error constructing SQL chart draft: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to construct SQL chart draft: " (or (ex-message e) "Unknown error"))}))))
@@ -220,7 +220,7 @@
(or result
{:output "Failed to construct model chart draft."})))
(catch Exception e
- (log/error e "Error constructing model chart draft")
+ (log/errorf "Error constructing model chart draft: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to construct model chart draft: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/entity_details.clj b/src/metabase/metabot/tools/entity_details.clj
index a9378c20fc3..a0ce55fc493 100644
--- a/src/metabase/metabot/tools/entity_details.clj
+++ b/src/metabase/metabot/tools/entity_details.clj
@@ -65,8 +65,8 @@
exported (repr.resolve/export-query mp definition shared.content-store/default-store)]
(get-in exported ["stages" 0 (name definition-key)]))
(catch Exception e
- (log/warn e "Failed to export measure/segment definition to portable form"
- {:id (:id metadata) :key definition-key})
+ (log/warn "Failed to export measure/segment definition to portable form"
+ {:id (:id metadata) :key definition-key :error (ex-message e)})
nil)))))))
(defn verified-review?
@@ -621,10 +621,10 @@
(throw (ex-info "Invalid measure_id format" {:agent-error? true :status-code 400})))
{:structured-output (assoc (measure-or-segment-details :measure measure-id) :result-type :entity)})
(catch Exception e
- (let [{:keys [status-code agent-error?] :as data} (ex-data e)]
+ (let [{:keys [status-code agent-error?]} (ex-data e)]
;; Agent-facing errors (bad input, not-found) are expected; only log genuine failures.
(when-not agent-error?
- (log/error e "Failed to fetch measure details" data))
+ (log/errorf "Failed to fetch measure details: %s" (ex-message e)))
(if (= status-code 404)
{:output (ex-message e) :status-code 404}
(metabot.tools.u/handle-agent-error e))))))
@@ -638,10 +638,10 @@
(throw (ex-info "Invalid segment_id format" {:agent-error? true :status-code 400})))
{:structured-output (assoc (measure-or-segment-details :segment segment-id) :result-type :entity)})
(catch Exception e
- (let [{:keys [status-code agent-error?] :as data} (ex-data e)]
+ (let [{:keys [status-code agent-error?]} (ex-data e)]
;; Agent-facing errors (bad input, not-found) are expected; only log genuine failures.
(when-not agent-error?
- (log/error e "Failed to fetch segment details" data))
+ (log/errorf "Failed to fetch segment details: %s" (ex-message e)))
(if (= status-code 404)
{:output (ex-message e) :status-code 404}
(metabot.tools.u/handle-agent-error e))))))
diff --git a/src/metabase/metabot/tools/entity_retrieval.clj b/src/metabase/metabot/tools/entity_retrieval.clj
index 072e01323ba..835e7fec4ec 100644
--- a/src/metabase/metabot/tools/entity_retrieval.clj
+++ b/src/metabase/metabot/tools/entity_retrieval.clj
@@ -197,6 +197,6 @@
;; library is empty" — say so in :output (the only channel the agent reads) so it doesn't confidently
;; tell the user nothing matches. No :structured-output: that feeds the FE a result payload, and there's
;; no successful search to render.
- (log/error e "Error in retrieve_library_entities")
+ (log/errorf "Error in retrieve_library_entities: %s" (ex-message e))
{:output (str "The library search is temporarily unavailable (" (or (ex-message e) "unknown error")
"). This does not mean the library is empty; the search could not be run.")})))
diff --git a/src/metabase/metabot/tools/metadata.clj b/src/metabase/metabot/tools/metadata.clj
index 2a9ccf7430a..277786839fd 100644
--- a/src/metabase/metabot/tools/metadata.clj
+++ b/src/metabase/metabot/tools/metadata.clj
@@ -36,7 +36,7 @@
{:value structured}
{:error (or output (str "No metadata returned for ID " id))}))
(catch Exception e
- (log/error e "Failed to fetch metadata" {:id id})
+ (log/error "Failed to fetch metadata" {:id id, :error (ex-message e)})
{:error (or (ex-message e) (str "Failed to fetch metadata for ID " id))})))
(defn get-metadata
@@ -98,7 +98,7 @@
:metrics metrics
:errors errors}})
(catch Exception e
- (log/error e "Failed to fetch metadata")
+ (log/errorf "Failed to fetch metadata: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to fetch metadata: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/resources.clj b/src/metabase/metabot/tools/resources.clj
index e5d5865b346..2f4123a1014 100644
--- a/src/metabase/metabot/tools/resources.clj
+++ b/src/metabase/metabot/tools/resources.clj
@@ -888,7 +888,7 @@
{:uri uri :error (or (:output result) result)}
{:uri uri :content result}))
(catch Exception e
- (log/warn "Error fetching resource" {:uri uri :error (ex-message e)})
+ (log/warn "Error fetching resource" {:error (ex-message e)})
{:uri uri :error (or (ex-message e) "Unknown error")})))
(defn- format-with-instructions
@@ -1006,5 +1006,5 @@
(try
(read-resource {:uris uris})
(catch Exception e
- (log/error e "Error in read_resource tool")
+ (log/errorf "Error in read_resource tool: %s" (ex-message e))
{:output (str "Failed to read resources: " (or (ex-message e) "Unknown error"))})))
diff --git a/src/metabase/metabot/tools/save_entity.clj b/src/metabase/metabot/tools/save_entity.clj
index e03d47aa611..3ec0ddffad7 100644
--- a/src/metabase/metabot/tools/save_entity.clj
+++ b/src/metabase/metabot/tools/save_entity.clj
@@ -233,7 +233,7 @@
:card_id (:id card)
:destination saved-destination})]})
(catch Exception e
- (log/error e "Error saving entity")
+ (log/errorf "Error saving entity: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to save: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/search.clj b/src/metabase/metabot/tools/search.clj
index ed4299fa933..9dee6113c83 100644
--- a/src/metabase/metabot/tools/search.clj
+++ b/src/metabase/metabot/tools/search.clj
@@ -274,17 +274,15 @@
[{:keys [term-queries semantic-queries database-id created-at last-edited-at
entity-types limit metabot-id profile-id search-native-query weights]}]
(log/infof "[METABOT-SEARCH] Starting search with params: %s"
- {:term-queries term-queries
- :semantic-queries semantic-queries
- :database-id database-id
- :created-at created-at
- :last-edited-at last-edited-at
- :entity-types entity-types
- :limit limit
- :metabot-id metabot-id
- :profile-id profile-id
- :search-native-query search-native-query
- :weights weights})
+ {:term-query-count (count term-queries)
+ :semantic-query-count (count semantic-queries)
+ :database-id database-id
+ :entity-types entity-types
+ :limit limit
+ :metabot-id metabot-id
+ :profile-id profile-id
+ :search-native-query search-native-query
+ :weights weights})
(let [search-models (if (seq entity-types)
(set (distinct (keep metabot.search-models/entity-type->search-model entity-types)))
metabot-search-models)
@@ -326,12 +324,12 @@
(assoc :search-engine (name search-engine))
collection-id
(assoc :collection collection-id)))
- _ (log/infof "[METABOT-SEARCH] Search context models for query '%s': %s"
- search-string (:models search-context))
+ _ (log/infof "[METABOT-SEARCH] Search context models: %s"
+ (:models search-context))
search-results (search/search search-context)
data (:data search-results)
result-models (frequencies (map :model data))]
- (log/infof "[METABOT-SEARCH] Query '%s' returned entity types: %s" search-string result-models)
+ (log/infof "[METABOT-SEARCH] Query returned entity types: %s" result-models)
data))
search-fn* (fn [search-engine queries]
(let [queries (search.engine/disjunction search-engine queries)]
@@ -540,7 +538,7 @@
:data results
:total_count (count results)}})
(catch Exception e
- (log/error e (str "Error in " label))
+ (log/error (str "Error in " label ": " (ex-message e)))
{:output (str "Search failed: " (or (ex-message e) "Unknown error"))}))))
(def ^:private search-schema
diff --git a/src/metabase/metabot/tools/shared/llm_shape.clj b/src/metabase/metabot/tools/shared/llm_shape.clj
index 511a5853198..b454c325926 100644
--- a/src/metabase/metabot/tools/shared/llm_shape.clj
+++ b/src/metabase/metabot/tools/shared/llm_shape.clj
@@ -174,7 +174,7 @@
(-> (selmer/render template payload)
str/trim)
(catch Exception e
- (log/error e "Error rendering LLM representations template" {:type type})
+ (log/error "Error rendering LLM representations template" {:type type :error (ex-message e)})
(pr-str payload)))
(do
(log/warn "LLM representations template missing" {:template llm-template-name})
diff --git a/src/metabase/metabot/tools/skills.clj b/src/metabase/metabot/tools/skills.clj
index dce4e2a3bed..763b7fdb5d0 100644
--- a/src/metabase/metabot/tools/skills.clj
+++ b/src/metabase/metabot/tools/skills.clj
@@ -19,7 +19,7 @@
(let [skill (skills/get-skill-by-id-string id)]
(cond
(nil? skill)
- (do (log/info "Unknown skill requested by load_skill" {:id id})
+ (do (log/info "Unknown skill requested by load_skill")
(format "Unknown skill: \"%s\". Load only ids listed under \"Available skills\"." id))
(not (skills/skill-loadable? skill))
@@ -40,5 +40,5 @@
(try
{:output (str/join "\n\n" (map load-one ids))}
(catch Exception e
- (log/error e "Failed to load skill(s)" {:ids ids})
+ (log/errorf "Failed to load skill(s): %s" (ex-message e))
{:output (str "Failed to load skill(s): " (or (ex-message e) "Unknown error"))})))
diff --git a/src/metabase/metabot/tools/slackbot_query.clj b/src/metabase/metabot/tools/slackbot_query.clj
index 6ce35e612b6..8d652b130ab 100644
--- a/src/metabase/metabot/tools/slackbot_query.clj
+++ b/src/metabase/metabot/tools/slackbot_query.clj
@@ -57,7 +57,7 @@
:data-parts [(streaming/adhoc-viz-part adhoc-viz-value)]})
query-result))
(catch Exception e
- (log/error e "Failed to construct slackbot notebook query")
+ (log/errorf "Failed to construct slackbot notebook query: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to construct notebook query: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/sql.clj b/src/metabase/metabot/tools/sql.clj
index c5539548831..d6a1fc98101 100644
--- a/src/metabase/metabot/tools/sql.clj
+++ b/src/metabase/metabot/tools/sql.clj
@@ -108,7 +108,7 @@
{:output (format-validation-error-output instr)
:instructions instr})))
(catch Exception e
- (log/error e "Error creating SQL query")
+ (log/errorf "Error creating SQL query: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to create SQL query: " (or (ex-message e) "Unknown error"))}))))
@@ -186,7 +186,7 @@
{:output (format-validation-error-output instr)
:instructions instr})))
(catch Exception e
- (log/error e "Error editing SQL query")
+ (log/errorf "Error editing SQL query: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to edit SQL query: " (or (ex-message e) "Unknown error"))}))))
@@ -235,7 +235,7 @@
{:output (format-validation-error-output instr)
:instructions instr})))
(catch Exception e
- (log/error e "Error replacing SQL query")
+ (log/errorf "Error replacing SQL query: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to replace SQL query: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/sql/create.clj b/src/metabase/metabot/tools/sql/create.clj
index 775de9b7620..39402cca2a9 100644
--- a/src/metabase/metabot/tools/sql/create.clj
+++ b/src/metabase/metabot/tools/sql/create.clj
@@ -46,10 +46,9 @@
- :query-id - The ID of the created query
- :query-content - The SQL content
- :database - Database ID"
- [{:keys [database-id sql name]}]
+ [{:keys [database-id sql]}]
(log/info "Creating SQL query"
{:database-id database-id
- :name name
:sql-length (count sql)})
;; Validate access
diff --git a/src/metabase/metabot/tools/subscriptions.clj b/src/metabase/metabot/tools/subscriptions.clj
index bbcc8ec96cf..5ccbeb0dac4 100644
--- a/src/metabase/metabot/tools/subscriptions.clj
+++ b/src/metabase/metabot/tools/subscriptions.clj
@@ -120,7 +120,7 @@ If any required information is missing, ask the user for it rather than assuming
{:output (:error result)}
{:output (or (:output result) "Dashboard subscription created successfully.")}))
(catch Exception e
- (log/error e "Failed to create dashboard subscription")
+ (log/errorf "Failed to create dashboard subscription: %s" (ex-message e))
{:output (str "Failed to create dashboard subscription: " (or (ex-message e) "Unknown error"))}))))
(def ^:private subscription-schema
@@ -159,7 +159,7 @@ If any required information is missing, ask the user for it rather than assuming
(:day_of_month schedule) (-> (assoc :day-of-month (keyword (:day_of_month schedule)))
(dissoc :day_of_month))))})
(catch Exception e
- (log/error e "Error creating dashboard subscription")
+ (log/errorf "Error creating dashboard subscription: %s" (ex-message e))
(if (:agent-error? (ex-data e))
{:output (ex-message e)}
{:output (str "Failed to create dashboard subscription: " (or (ex-message e) "Unknown error"))}))))
diff --git a/src/metabase/metabot/tools/transforms.clj b/src/metabase/metabot/tools/transforms.clj
index 6b17659c1de..5f57ee3b258 100644
--- a/src/metabase/metabot/tools/transforms.clj
+++ b/src/metabase/metabot/tools/transforms.clj
@@ -57,7 +57,7 @@
(seq (:bad_questions structured_output))))
structured_output))
(catch Exception e
- (log/error e "Dependency check failed for transform" transform-id)
+ (log/error "Dependency check failed for transform" transform-id (ex-message e))
nil))))
(defn- format-dependency-warnings
diff --git a/src/metabase/metabot/used_tables.clj b/src/metabase/metabot/used_tables.clj
index a26b65598f8..6b26ecce5f8 100644
--- a/src/metabase/metabot/used_tables.clj
+++ b/src/metabase/metabot/used_tables.clj
@@ -77,8 +77,7 @@
(lib/query metadata-providerable raw-query)
(catch Exception e
(record-extraction-warning! :query-build)
- (log/warn e "Failed to convert query to MBQL 5")
- (log/debugf "Failed to convert query to MBQL 5: %s" (pr-str raw-query))
+ (log/warnf "Failed to convert query to MBQL 5: %s" (ex-message e))
nil)))
(defn- native-tables
@@ -90,13 +89,11 @@
(if (:error result)
(do (record-extraction-warning! :native-parse)
(log/warnf "tables-for-native error: %s" (:error result))
- (log/debugf "tables-for-native error: %s; query: %s" (:error result) (pr-str query))
#{})
(into #{} (keep :table-id) (:tables result))))
(catch Exception e
(record-extraction-warning! :native-parse)
- (log/warn e "Failed to extract tables from native SQL")
- (log/debugf "Failed to extract tables from native SQL: %s" (pr-str query))
+ (log/warnf "Failed to extract tables from native SQL: %s" (ex-message e))
#{}))
#{}))
@@ -115,8 +112,7 @@
:cards (set/union (:card ids) (:metric ids))})
(catch Exception e
(record-extraction-warning! :query-walk)
- (log/warn e "Failed to walk query for used-table extraction")
- (log/debugf "Failed to walk query for used-table extraction: %s" (pr-str query))
+ (log/warnf "Failed to walk query for used-table extraction: %s" (ex-message e))
{:tables #{} :cards #{}})))
(defn- card-query
@@ -131,7 +127,7 @@
nil))
(catch Exception e
(record-extraction-warning! :card-lookup)
- (log/warnf e "Failed to look up card %s for used-table extraction" card-id)
+ (log/warnf "Failed to look up card %s for used-table extraction: %s" card-id (ex-message e))
nil)))
(defn- collect-tables
@@ -185,8 +181,7 @@
(lib/native-query (lib.metadata/->metadata-provider metadata-providerable db-id) sql)
(catch Exception e
(record-extraction-warning! :native-build)
- (log/warnf e "Failed to build native query for %s from raw SQL on database %s" tool-name db-id)
- (log/debugf "Failed to build native query for %s from raw SQL on database %s: %s" tool-name db-id sql)
+ (log/warnf "Failed to build native query for %s from raw SQL on database %s: %s" tool-name db-id (ex-message e))
nil)))))))
(defn- transform-sql-starting-query
@@ -392,7 +387,7 @@
(when (seq rows)
(t2/insert! :model/MetabotUsedTable rows)))
(catch Exception e
- (log/warn e "Failed to record metabot used tables for message" message-id)))))
+ (log/warn "Failed to record metabot used tables for message" message-id (ex-message e))))))
(defn record-used-tables!
"Extract used tables from `parts` and persist `metabot_used_table` rows for `message-id`.
diff --git a/src/metabase/model_persistence/events/persisted_info.clj b/src/metabase/model_persistence/events/persisted_info.clj
index 801e316fa63..1585d95261a 100644
--- a/src/metabase/model_persistence/events/persisted_info.clj
+++ b/src/metabase/model_persistence/events/persisted_info.clj
@@ -24,4 +24,4 @@
(nil? (t2/select-one-fn :id :model/PersistedInfo :card_id (:id card))))
(persisted-info/turn-on-model! user-id card))
(catch Throwable e
- (log/warnf e "Failed to process persisted-info event. %s" topic))))
+ (log/warnf "Failed to process persisted-info event. %s: %s" topic (ex-message e)))))
diff --git a/src/metabase/model_persistence/task/persist_refresh.clj b/src/metabase/model_persistence/task/persist_refresh.clj
index 9e6aaa20872..815de4ec61f 100644
--- a/src/metabase/model_persistence/task/persist_refresh.clj
+++ b/src/metabase/model_persistence/task/persist_refresh.clj
@@ -73,8 +73,8 @@
{:keys [state error]} (try
(refresh! refresher database definition card)
(catch Exception e
- (log/infof e "Error refreshing persisting model with card-id %s"
- (:card_id persisted-info))
+ (log/infof "Error refreshing persisting model with card-id %s: %s"
+ (:card_id persisted-info) (ex-message e))
{:state :error :error (ex-message e)}))]
(t2/update! :model/PersistedInfo (u/the-id persisted-info)
{:active (= state :success),
@@ -108,7 +108,7 @@
:persisted-infos persisted-infos
:trigger (:trigger task-details)}))
(catch Exception e
- (log/error e "Error sending persist refresh email"))))
+ (log/errorf "Error sending persist refresh email: %s" (ex-message e)))))
(defn- save-task-history!
"Create a task history entry with start, end, and duration. :task will be `task-type`, `db-id` is optional,
@@ -148,7 +148,7 @@
(t2/delete! :model/PersistedInfo :id (:id persisted-info)))
(update stats :success inc)
(catch Exception e
- (log/infof e "Error unpersisting model with card-id %s" (:card_id persisted-info))
+ (log/infof "Error unpersisting model with card-id %s: %s" (:card_id persisted-info) (ex-message e))
(update stats :error inc)))))
(update stats :skipped inc))))
{:success 0, :error 0, :skipped 0}
diff --git a/src/metabase/models/interface.clj b/src/metabase/models/interface.clj
index 50c4dcf9910..8522a035e59 100644
--- a/src/metabase/models/interface.clj
+++ b/src/metabase/models/interface.clj
@@ -157,7 +157,7 @@
(try
(json/decode s keywordize-keys?)
(catch Throwable e
- (log/error e "Error parsing JSON")
+ (log/errorf "Error parsing JSON: %s" (ex-message e))
s))
s))
@@ -206,7 +206,7 @@
(try
(doall (f x))
(catch Throwable e
- (log/errorf e "Unable to normalize:\n%s" (u/pprint-to-str 'red x))
+ (log/errorf "Unable to normalize: %s" (ex-message e))
nil))))
(def ^{:deprecated "0.57.0"} transform-legacy-field-ref
@@ -314,8 +314,8 @@
(catch Throwable e
(if (or (encryption/possibly-encrypted-string? decrypted)
(encryption/possibly-encrypted-bytes? decrypted))
- (log/error e "Could not decrypt encrypted field! Have you forgot to set MB_ENCRYPTION_SECRET_KEY?")
- (log/error e "Error parsing JSON")) ; same message as in `json-out`
+ (log/error "Could not decrypt encrypted field! Have you forgot to set MB_ENCRYPTION_SECRET_KEY?")
+ (log/errorf "Error parsing JSON: %s" (ex-message e))) ; same message as in `json-out`
v))))
;; cache the decryption/JSON parsing because it's somewhat slow (~500µs vs ~100µs on a *fast* computer)
@@ -366,7 +366,7 @@
:else (try
(mbql.normalize/normalize x)
(catch Throwable e
- (log/debugf e "Error normalizing column settings key %s" (pr-str x))
+ (log/debugf "Error normalizing column settings key %s: %s" (pr-str x) (ex-message e))
nil)))))
json/encode))
(normalize-column-settings [column-settings]
@@ -393,7 +393,7 @@
(mbql.normalize/normalize form)
(catch Exception e
(log/warnf "Unable to normalize visualization-settings part %s: %s"
- (u/pprint-to-str 'red form)
+ (pr-str form)
(ex-message e))
form))
diff --git a/src/metabase/models/serialization.clj b/src/metabase/models/serialization.clj
index 097c1013650..8d3b3c35070 100644
--- a/src/metabase/models/serialization.clj
+++ b/src/metabase/models/serialization.clj
@@ -424,7 +424,7 @@
(defn log-and-extract-one
"Extracts a single entity; will replace `extract-one` as public interface once `extract-one` overrides are gone."
[model opts instance]
- (log/tracef "Extracting %s" (log-path-str (generate-path model instance)))
+ (log/tracef "Extracting %s %s" model (:id instance))
(try
(extract-one model opts instance)
(catch Exception e
@@ -684,7 +684,7 @@
(let [model (t2.model/resolve-model (symbol model-name))
pk (first (t2/primary-keys model))
id (get local pk)]
- (log/tracef "Upserting %s %d: old %s new %s" model-name id (pr-str local) (pr-str ingested))
+ (log/tracef "Upserting %s %d" model-name id)
(t2/update! model id ingested)
(t2/select-one model pk id)))
@@ -709,7 +709,7 @@
(fn [model _] model))
(defmethod load-insert! :default [model-name ingested]
- (log/tracef "Inserting %s: %s" model-name (pr-str ingested))
+ (log/tracef "Inserting %s" model-name)
(first (t2/insert-returning-instances! (t2.model/resolve-model (symbol model-name)) ingested)))
(defmulti load-one!
@@ -883,7 +883,7 @@
`(try
~@body
(catch clojure.lang.ExceptionInfo e#
- (log/debugf e# "Caught error in fk-elide")
+ (log/debugf "Caught error in fk-elide: %s" (ex-message e#))
(when-not (= (::type (ex-data e#)) :target-not-found)
(throw e#))
nil)))
@@ -1282,7 +1282,7 @@
(normalize-mbql-ref x)
(lib/normalize x))
(catch Throwable e
- (log/warn e "Error normalizing imported MBQL")
+ (log/warnf "Error normalizing imported MBQL: %s" (ex-message e))
x))))
(defn- import-mbql*
diff --git a/src/metabase/models/serialization/resolve/db.clj b/src/metabase/models/serialization/resolve/db.clj
index 813a85c66d4..a03dfc207d2 100644
--- a/src/metabase/models/serialization/resolve/db.clj
+++ b/src/metabase/models/serialization/resolve/db.clj
@@ -169,7 +169,7 @@
(reify resolve/SerdesImportResolver
(resolve/import-fk [_ eid model] (try (resolve/import-fk default-import-resolver eid model)
(catch ExceptionInfo e
- (log/warn e "Failed to import FK")
+ (log/warnf "Failed to import FK: %s" (ex-message e))
nil)))
(resolve/import-fk-keyed [_ portable model field] (resolve/import-fk-keyed default-import-resolver portable model field))
(resolve/import-user [_ email] (resolve/import-user default-import-resolver email))
diff --git a/src/metabase/mq/impl.clj b/src/metabase/mq/impl.clj
index ad62267f902..8d91e691eb6 100644
--- a/src/metabase/mq/impl.clj
+++ b/src/metabase/mq/impl.clj
@@ -53,7 +53,7 @@
(analytics/inc! :metabase-mq/batches-handled (assoc labels :status "success"))
nil
(catch Throwable e
- (log/error e (str "Error handling " (namespace channel) " message") labels)
+ (log/error (str "Error handling " (namespace channel) " message") labels (ex-message e))
(analytics/inc! :metabase-mq/batches-handled (assoc labels :status "error"))
e)
(finally
@@ -69,8 +69,9 @@
(try
(payload/decode payload)
(catch Exception e
- (log/error e "Dropping queue message with an undecodable payload"
- {:channel channel :payload-bytes (count (str payload))})
+ (log/error "Dropping queue message with an undecodable payload"
+ {:channel channel :payload-bytes (count (str payload))}
+ (ex-message e))
(analytics/inc! :metabase-mq/batches-dropped {:channel (name channel) :reason "undecodable"})
undecodable)))
diff --git a/src/metabase/mq/listener.clj b/src/metabase/mq/listener.clj
index 37a34507c13..1432e191658 100644
--- a/src/metabase/mq/listener.clj
+++ b/src/metabase/mq/listener.clj
@@ -105,7 +105,7 @@
(try
(f k)
(catch Throwable e
- (log/errorf e "Failed to register listener %s" k)
+ (log/errorf "Failed to register listener %s: %s" k (ex-message e))
(throw (ex-info (str "Failed to register listener " k)
{:channel k}
e))))))
diff --git a/src/metabase/mq/polling.clj b/src/metabase/mq/polling.clj
index 372081e747f..728703bdc68 100644
--- a/src/metabase/mq/polling.clj
+++ b/src/metabase/mq/polling.clj
@@ -18,7 +18,7 @@
(try
(f)
(catch Exception e
- (log/error e (str "Error in " label)))))))
+ (log/error (str "Error in " label ":") (ex-message e)))))))
(def ^:private active-poll-states
"Set of poll states that currently have a running polling thread."
@@ -49,7 +49,7 @@
(poll-fn)
(catch InterruptedException e (throw e))
(catch Exception e
- (log/errorf e "Error in %s polling loop" label)
+ (log/errorf "Error in %s polling loop: %s" label (ex-message e))
false))]
(when-not found-work?
(locking notify (.wait ^Object notify (long wait-ms)))))
diff --git a/src/metabase/mq/publish.clj b/src/metabase/mq/publish.clj
index 75209c04069..0d804528097 100644
--- a/src/metabase/mq/publish.clj
+++ b/src/metabase/mq/publish.clj
@@ -48,7 +48,7 @@
(try
(publish! channel msgs)
(catch Exception e
- (log/error e "Error flushing deferred messages" {:channel channel}))))))
+ (log/error "Error flushing deferred messages" {:channel channel :error (ex-message e)}))))))
(defn defer-in-transaction!
"Accumulates msgs in *transaction-state* under [::deferred-messages channel].
@@ -100,7 +100,7 @@
(publish-collected! channel msgs))
result)
(catch Exception e
- (log/error e error-label)
+ (log/error error-label (ex-message e))
(throw e)))))
(defmacro with-buffer
diff --git a/src/metabase/mq/publish_buffer.clj b/src/metabase/mq/publish_buffer.clj
index a6c12c351b5..376a6f70b7b 100644
--- a/src/metabase/mq/publish_buffer.clj
+++ b/src/metabase/mq/publish_buffer.clj
@@ -68,12 +68,12 @@
(try
(q.outbox/insert-batch! channel (payload/encode messages))
(analytics/inc! :metabase-mq/batches-retried {:channel (name channel) :reason "publish-outbox-handoff"})
- (log/warnf e "Backend publish failed for %s; handed %d message(s) to the durable outbox for recovery"
- channel (count messages))
+ (log/warnf "Backend publish failed for %s; handed %d message(s) to the durable outbox for recovery: %s"
+ channel (count messages) (ex-message e))
(catch Exception oe
(analytics/inc! :metabase-mq/batches-dropped {:channel (name channel) :reason "outbox-handoff-failed"})
- (log/errorf oe "Backend publish AND outbox handoff both failed for %s; dropping %d message(s). Publish error: %s"
- channel (count messages) (ex-message e)))))
+ (log/errorf "Backend publish AND outbox handoff both failed for %s; dropping %d message(s). Publish error: %s; outbox error: %s"
+ channel (count messages) (ex-message e) (ex-message oe)))))
(defn- flush-accumulation!
"Drains accumulation entries past their deadline (or all of them when `force?`) and publishes each.
@@ -119,7 +119,7 @@
(try
(flush-publish-buffer!)
(catch Throwable t
- (log/error t "Unexpected error in publish-buffer flush; flusher continues"))))
+ (log/errorf "Unexpected error in publish-buffer flush; flusher continues: %s" (ex-message t)))))
(defn start-publish-buffer-flush!
"Starts a daemon thread that flushes the publish buffer every 100ms. Idempotent.
diff --git a/src/metabase/mq/quartz_affinity.clj b/src/metabase/mq/quartz_affinity.clj
index 803d63e291d..34cf721af0b 100644
--- a/src/metabase/mq/quartz_affinity.clj
+++ b/src/metabase/mq/quartz_affinity.clj
@@ -157,8 +157,8 @@
(ensure-delegate-loadable! db-type)
(catch Throwable t
(let [fallback (get base-delegate-class-name db-type default-base-delegate-class-name)]
- (log/warn t (str "Could not install Quartz queue-affinity delegate; falling back to "
- fallback " (queue node-affinity disabled)"))
+ (log/warn (str "Could not install Quartz queue-affinity delegate; falling back to "
+ fallback " (queue node-affinity disabled): " (ex-message t)))
fallback)))]
(System/setProperty driver-delegate-property class-name)
class-name))
diff --git a/src/metabase/mq/queue/impl.clj b/src/metabase/mq/queue/impl.clj
index 4dc1f344fd4..631882eeae0 100644
--- a/src/metabase/mq/queue/impl.clj
+++ b/src/metabase/mq/queue/impl.clj
@@ -25,7 +25,7 @@
:error error
:attempts attempts})
(catch Throwable t
- (log/error t "Queue :on-error handler threw; still dropping the batch" {:channel channel})))))
+ (log/error "Queue :on-error handler threw; still dropping the batch" {:channel channel :error (ex-message t)})))))
(defn handle-batch-failure-policy!
"Retry-vs-drop policy for a just-failed queue batch. `failures` is the number of attempts that have
@@ -45,8 +45,8 @@
(do
(run-on-error! channel payload error attempts)
(u/ignore-exceptions
- (log/error error "Dropping queue batch after exhausting retries"
- {:channel channel :max-retries max-retries})
+ (log/error "Dropping queue batch after exhausting retries"
+ {:channel channel :max-retries max-retries :error (ex-message error)})
(analytics/inc! :metabase-mq/batches-dropped
{:channel (name channel) :reason "delivery-exhausted"}))
(on-drop))
diff --git a/src/metabase/mq/queue/outbox.clj b/src/metabase/mq/queue/outbox.clj
index 954e5672479..13837b63628 100644
--- a/src/metabase/mq/queue/outbox.clj
+++ b/src/metabase/mq/queue/outbox.clj
@@ -108,8 +108,8 @@
(transport/publish-encoded! channel payload)
(conj ids id)
(catch Exception e
- (log/error e "Error publishing outbox row; recovery sweep will retry"
- {:channel channel :outbox-id id})
+ (log/error "Error publishing outbox row; recovery sweep will retry"
+ {:channel channel :outbox-id id :error (ex-message e)})
ids)))
[]
(::rows @state))]
@@ -139,8 +139,8 @@
[acc ^Instant now {:keys [id queue_name publish_attempts]} ^Exception e]
(let [next-attempts (inc publish_attempts)
delay-ms (retry-delay-ms next-attempts)]
- (log/warn e "Failed to publish queue outbox row during recovery; will retry with backoff"
- {:queue queue_name :outbox-id id :publish-attempts next-attempts :retry-delay-ms delay-ms})
+ (log/warn "Failed to publish queue outbox row during recovery; will retry with backoff"
+ {:queue queue_name :outbox-id id :publish-attempts next-attempts :retry-delay-ms delay-ms :error (ex-message e)})
(analytics/inc! :metabase-mq/batches-retried {:channel queue_name :reason "outbox-recovery"})
(update acc :bumps conj {:id id :next-attempt-at (Timestamp/from (.plusMillis now delay-ms))})))
diff --git a/src/metabase/mq/queue/quartz.clj b/src/metabase/mq/queue/quartz.clj
index 2679dd7dfbd..7d7a334cae3 100644
--- a/src/metabase/mq/queue/quartz.clj
+++ b/src/metabase/mq/queue/quartz.clj
@@ -172,7 +172,7 @@
(ensure-nudge-job! scheduler)
(.resumeJob scheduler nudge-job-key)
(catch Throwable t
- (log/debugf t "Could not wake the Quartz acquire loop after freeing a slot on %s" queue)))))
+ (log/debugf "Could not wake the Quartz acquire loop after freeing a slot on %s: %s" queue (ex-message t))))))
(defn- deliver-batch!
"Shared job body. Reads the merged job+trigger data and dispatches on the delivery result:
diff --git a/src/metabase/mq/queue/registry.clj b/src/metabase/mq/queue/registry.clj
index b9622bf0c98..8b007fa6975 100644
--- a/src/metabase/mq/queue/registry.clj
+++ b/src/metabase/mq/queue/registry.clj
@@ -121,7 +121,7 @@
(try
(cap)
(catch Throwable t
- (log/warnf t "Error resolving :max-concurrent-batches for %s; treating as unbounded" queue-name)
+ (log/warnf "Error resolving :max-concurrent-batches for %s; treating as unbounded: %s" queue-name (ex-message t))
nil))
cap)))
diff --git a/src/metabase/notification/payload/execute.clj b/src/metabase/notification/payload/execute.clj
index 517cc5aeecd..282d0b5db5d 100644
--- a/src/metabase/notification/payload/execute.clj
+++ b/src/metabase/notification/payload/execute.clj
@@ -242,7 +242,7 @@
(is-card-empty? (assoc card :result (:result result))))
(update result :dashcard assoc :series-results series-results))))
(catch Throwable e
- (log/warnf e "Error running query for Card %s" (:card_id dashcard)))))))
+ (log/warnf "Error running query for Card %s: %s" (:card_id dashcard) (ex-message e)))))))
(defn- dashcard->part
"Given a dashcard returns its part based on its type.
@@ -344,7 +344,7 @@
should-render-tab? (< 1 (count tabs-with-cards))]
(doall (flatten (for [{:keys [cards] :as tab} tabs-with-cards]
(do
- (log/debugf "Rendering tab %s with %d cards" (:name tab) (count cards))
+ (log/debugf "Rendering tab %s with %d cards" (:id tab) (count cards))
(concat
(when should-render-tab?
[(tab->part tab)])
diff --git a/src/metabase/notification/payload/impl/card.clj b/src/metabase/notification/payload/impl/card.clj
index c1a69985145..f864dc53413 100644
--- a/src/metabase/notification/payload/impl/card.clj
+++ b/src/metabase/notification/payload/impl/card.clj
@@ -77,7 +77,7 @@
(when-let [rows (-> notification-payload :payload :card_part :result :data :rows)]
(notification.payload/cleanup! rows))
(catch Exception e
- (log/warn e "Error cleaning up temp files for notification" id)))
+ (log/warn "Error cleaning up temp files for notification" id ":" (ex-message e))))
(when-not skipped?
(events/publish-event! :event/alert-send
{:id id
diff --git a/src/metabase/notification/payload/impl/dashboard.clj b/src/metabase/notification/payload/impl/dashboard.clj
index 9d5a51a9201..56b63327483 100644
--- a/src/metabase/notification/payload/impl/dashboard.clj
+++ b/src/metabase/notification/payload/impl/dashboard.clj
@@ -84,7 +84,7 @@
(try
(run! #(some-> % :result :data :rows notification.payload/cleanup!) (->> notification-payload :payload :dashboard_parts))
(catch Exception e
- (log/warn e "Error cleaning up temp files for notification" id)))
+ (log/warn "Error cleaning up temp files for notification" id (ex-message e))))
(when-not skipped?
(events/publish-event! :event/subscription-send
{:id id
diff --git a/src/metabase/notification/send.clj b/src/metabase/notification/send.clj
index e4154589d2b..d1aada9d2d4 100644
--- a/src/metabase/notification/send.clj
+++ b/src/metabase/notification/send.clj
@@ -88,9 +88,9 @@
:on-retry (fn [_ ex]
(vswap! retry-errors conj {:message (u/strip-error ex)
:timestamp (t/offset-date-time)})
- (log/warn ex "Failed to send, retrying..."))
+ (log/warnf "Failed to send, retrying: %s" (ex-message ex)))
:on-failure (fn [_ ex]
- (log/warn ex "Failed to send, not retrying")))
+ (log/warnf "Failed to send, not retrying: %s" (ex-message ex))))
(channel/send! channel message))
(log/debugf "Sent with %d retries" (count @retry-errors))
(log/info "Sent successfully")))
@@ -99,7 +99,7 @@
(catch Throwable e
(analytics/inc! :metabase-notification/channel-send-error {:payload-type payload-type
:channel-type channel-type})
- (log/warn e "Failed to send")))))
+ (log/warnf "Failed to send: %s" (ex-message e))))))
(defn- hydrate-notification
[notification-info]
@@ -187,12 +187,12 @@
(doseq [message messages]
(channel-send-retrying! id payload_type handler message)))
(catch Exception e
- (log/errorf e "Error sending to channel %s" (handler->channel-name handler))))))
+ (log/errorf "Error sending to channel %s: %s" (handler->channel-name handler) (ex-message e))))))
(log/info "Done processing notification")))
(do-after-notification-sent hydrated-notification notification-payload (some? skip-reason))
(analytics/inc! :metabase-notification/send-ok {:payload-type payload_type}))))
(catch Exception e
- (log/error e "Failed to send")
+ (log/errorf "Failed to send: %s" (ex-message e))
(analytics/inc! :metabase-notification/send-error {:payload-type payload_type})
(throw e))
(finally
@@ -390,7 +390,7 @@
(log/warn "Notification worker interrupted, shutting down")
(throw (InterruptedException.)))
(catch Throwable e
- (log/error e "Error in notification worker")))))))
+ (log/errorf "Error in notification worker: %s" (ex-message e))))))))
ensure-enough-workers! (fn []
(dotimes [i (- pool-size (.getActiveCount ^ThreadPoolExecutor executor))]
(log/debugf "Not enough workers, starting a new one %d/%d"
@@ -502,4 +502,4 @@
((:shutdown-fn @worker) default-shutdown-timeout-ms))
(log/info "All notification workers shut down successfully")
(catch Exception e
- (log/error e "Error shutting down notification workers"))))))
+ (log/errorf "Error shutting down notification workers: %s" (ex-message e)))))))
diff --git a/src/metabase/notification/task/send.clj b/src/metabase/notification/task/send.clj
index 848671e0638..ba36213be29 100644
--- a/src/metabase/notification/task/send.clj
+++ b/src/metabase/notification/task/send.clj
@@ -120,7 +120,7 @@
(notification.send/send-notification! (assoc notification :triggering_subscription subscription)))
(log/info "Submitted to the notification queue")
(catch Exception e
- (log/error e "Failed to submit to the notification queue")
+ (log/errorf "Failed to submit to the notification queue: %s" (ex-message e))
(throw e)))))
(nil? notification)
diff --git a/src/metabase/oauth_server/api/oauth.clj b/src/metabase/oauth_server/api/oauth.clj
index b25e96f42f8..d7bbd51ee54 100644
--- a/src/metabase/oauth_server/api/oauth.clj
+++ b/src/metabase/oauth_server/api/oauth.clj
@@ -278,7 +278,7 @@
:oauth-params oauth-params})}
(response/set-cookie csrf-cookie-name csrf-token (csrf-cookie-opts 600))))
(catch ExceptionInfo e
- (log/warn e "OAuth authorize request failed")
+ (log/warnf "OAuth authorize request failed: %s" (ex-message e))
{:status 400
:headers {"Content-Type" "application/json"}
:body {:error "invalid_request"
@@ -321,7 +321,7 @@
:body {:error "params_tampered"}}
(redirect-authorization-decision provider parsed approved request)))
(catch ExceptionInfo e
- (log/warn e "OAuth authorization decision failed")
+ (log/warnf "OAuth authorization decision failed: %s" (ex-message e))
{:status 400
:headers {"Content-Type" "application/json"}
:body {:error "invalid_request"
@@ -349,7 +349,7 @@
"Pragma" "no-cache"}
:body response})
(catch ExceptionInfo e
- (log/warn e "OAuth token request failed")
+ (log/warnf "OAuth token request failed: %s" (ex-message e))
(let [data (ex-data e)
error (or (:error data) "invalid_request")]
{:status (if (= error "invalid_client") 401 400)
diff --git a/src/metabase/parameters/chain_filter.clj b/src/metabase/parameters/chain_filter.clj
index 717510338bf..8eb72a623e6 100644
--- a/src/metabase/parameters/chain_filter.clj
+++ b/src/metabase/parameters/chain_filter.clj
@@ -80,7 +80,6 @@
[metabase.parameters.params :as params]
[metabase.parameters.schema :as parameters.schema]
[metabase.query-processor :as qp]
- [metabase.query-processor.compile :as qp.compile]
[metabase.query-processor.middleware.permissions :as qp.perms]
[metabase.query-processor.parameters.dates :as params.dates]
[metabase.query-processor.preprocess :as qp.preprocess]
@@ -138,7 +137,7 @@
(try
(params.dates/date-string->filter value field-id)
(catch Throwable e
- (log/error e "Error creating filter for date string")
+ (log/errorf "Error creating filter for date string: %s" (ex-message e))
nil))
;; we don't want to skip our value, even if its nil
(let [values (if (nil? value) [nil] (u/one-or-many value))]
@@ -147,12 +146,12 @@
:options options
:args (cons field values)}))]
(when filter-op
- (log/tracef "Adding filter clause: %s" (pr-str filter-op)))
+ (log/tracef "Adding filter clause with operator %s" (pr-str (:operator filter-op))))
(cond-> query
filter-op (lib/filter filter-op))))
(defn- name-for-logging [model id]
- (format "%s %d %s" (name model) id (u/format-color 'blue (pr-str (t2/select-one-fn :name model :id id)))))
+ (format "%s %d" (name model) id))
(defn- format-join-for-logging [join]
(format "%s %s -> %s %s"
@@ -183,10 +182,9 @@
(if (or (= field-table-id source-table-id)
(contains? joined-table-ids field-table-id))
(do
- (log/tracef "Added filter clause for %s %s with constraint %s"
+ (log/tracef "Added filter clause for %s %s"
(name-for-logging :model/Table field-table-id)
- (name-for-logging :model/Field field-id)
- (pr-str constraint))
+ (name-for-logging :model/Field field-id))
(add-filter query source-table-id id->field constraint))
(do
(log/tracef "Not adding filter clause for %s %s because we did not join against its Table"
@@ -402,8 +400,8 @@
(lib/with-join-alias (joined-table-alias lhs-table-id)))
(-> rhs-field
(lib/with-join-alias (joined-table-alias rhs-table-id))))]))]
- (log/tracef "Adding join against %s\n%s"
- (name-for-logging :model/Table rhs-table-id) (u/cprint-to-str join))
+ (log/tracef "Adding join against %s"
+ (name-for-logging :model/Table rhs-table-id))
(lib/join query join)))
query
joins)))
@@ -448,7 +446,7 @@
[field-id :- ::lib.schema.id/field
constraints :- [:maybe ::constraints]
{:keys [original-field-id limit]} :- [:maybe ::options]]
- (log/tracef "Chain filter %s with constraints %s" (name-for-logging :model/Field field-id) (u/cprint-to-str constraints))
+ (log/tracef "Chain filter %s with %d constraint(s)" (name-for-logging :model/Field field-id) (count constraints))
;; `field-id->database-id` is the one place we still bootstrap from a raw field-id: we need the Database before we
;; can build a (per-Database) metadata provider. Every other table-id/db-id below comes from `mp`.
(let [database-id (field/field-id->database-id field-id)
@@ -481,7 +479,7 @@
(name-for-logging :model/Field original-field-id)))
(when (seq joins)
(log/tracef "Generating joins and filters for source %s with joins info\n%s"
- (name-for-logging :model/Table source-table-id) (u/cprint-to-str joins)))
+ (name-for-logging :model/Table source-table-id) (pr-str joins)))
(-> (lib/query mp (lib.metadata/table mp source-table-id))
;; return the lesser of limit (if set) or max results
(lib/limit ((fnil min Integer/MAX_VALUE) limit max-results))
@@ -520,17 +518,11 @@
constraints :- [:maybe ::constraints]
options :- [:maybe ::options]]
(let [mbql-query (chain-filter-mbql-query field-id constraints options)]
- (log/debugf "Chain filter MBQL query:\n%s" (u/cprint-to-str mbql-query))
(try
(let [query-limit (lib/current-limit mbql-query)
;; FIXME: this can OOM for text column if each value are too large. See #46411
;; Consider using the [[field-values/distinct-text-field-rff] rff]
values (qp/process-query mbql-query (constantly conj))]
- (try ; Feature issue #46888: log chain filter query.
- (log/debugf "Chain filter native query: `%s`."
- (:query (qp.compile/compile mbql-query)))
- (catch Throwable _
- (log/error "Chain filter log failed!")))
{:values values
;; It's unlikely that we don't have a query-limit, but better safe than sorry and default it true
;; so that calling chain-filter-search on the same field will search from DB.
diff --git a/src/metabase/parameters/custom_values.clj b/src/metabase/parameters/custom_values.clj
index 7c35b873636..1e0f7770286 100644
--- a/src/metabase/parameters/custom_values.clj
+++ b/src/metabase/parameters/custom_values.clj
@@ -99,15 +99,12 @@
(log/warnf "Cannot get values from Card %d: Card query has no visible columns"
card-id))]
(when-let [value-column (or (lib/find-matching-column query -1 field-ref visible-columns)
- (log/warnf "Cannot get values from Card %d: failed to find column for ref %s\nFound: %s"
- card-id
- (pr-str field-ref)
- (pr-str (map (some-fn :lib/source-column-alias :name) visible-columns))))]
+ (log/warnf "Cannot get values from Card %d: failed to find matching column for ref"
+ card-id))]
(let [label-column (when label-field
(or (lib/find-matching-column query -1 label-field visible-columns)
- (log/warnf "Cannot get labels from Card %d: failed to find column for ref %s"
- card-id
- (pr-str label-field))))
+ (log/warnf "Cannot get labels from Card %d: failed to find matching column for ref"
+ card-id)))
search-column (or label-column value-column)
value-textual? (lib.types.isa/string? value-column)
search-textual? (lib.types.isa/string? search-column)
diff --git a/src/metabase/parameters/field.clj b/src/metabase/parameters/field.clj
index b7ff21c1d4f..24308057ade 100644
--- a/src/metabase/parameters/field.clj
+++ b/src/metabase/parameters/field.clj
@@ -67,7 +67,7 @@
limit (or maybe-limit default-max-field-search-limit)]
(search-values-query/search-values-query field search-field value limit))
(catch Throwable e
- (log/error e "Error searching field values")
+ (log/errorf "Error searching field values: %s" (ex-message e))
[]))))
(mu/defn field->values :- ms/FieldValuesResult
@@ -133,5 +133,5 @@
[:data :rows])))
;; as with fn above this error can usually be safely ignored which is why log level is log/debug
(catch Throwable e
- (log/debug e "Error searching for remapping")
+ (log/debugf "Error searching for remapping: %s" (ex-message e))
nil)))
diff --git a/src/metabase/parameters/params.clj b/src/metabase/parameters/params.clj
index 35bfb49aeb2..af0079b0614 100644
--- a/src/metabase/parameters/params.clj
+++ b/src/metabase/parameters/params.clj
@@ -74,7 +74,7 @@
:dimension
lib/field-ref-id)
(do
- (log/tracef "Could not find matching Field ID for target: %s" (pr-str template-tag-name))
+ (log/trace "Could not find matching Field ID for target template tag")
nil)))
(mu/defn param-target->field-id :- [:maybe ::lib.schema.id/field]
diff --git a/src/metabase/permissions/models/permissions.clj b/src/metabase/permissions/models/permissions.clj
index 359bf3cfe24..f4895ff4be0 100644
--- a/src/metabase/permissions/models/permissions.clj
+++ b/src/metabase/permissions/models/permissions.clj
@@ -413,7 +413,7 @@
(clear-current-user-cached-permissions!)
;; on some occasions through weirdness we might accidentally try to insert a key that's already been inserted
(catch Throwable e
- (log/error e (u/format-color 'red "Failed to grant permissions"))
+ (log/error (u/format-color 'red "Failed to grant permissions: %s" (ex-message e)))
;; if we're running tests, we're doing something wrong here if duplicate permissions are getting assigned,
;; mostly likely because tests aren't properly cleaning up after themselves, and possibly causing other tests
;; to pass when they shouldn't. Don't allow this during tests
diff --git a/src/metabase/permissions/util.clj b/src/metabase/permissions/util.clj
index d7de5a974b4..945c211ad8a 100644
--- a/src/metabase/permissions/util.clj
+++ b/src/metabase/permissions/util.clj
@@ -6,7 +6,6 @@
[metabase.api.common :as api]
[metabase.permissions.models.collection-permission-graph-revision :as collection-permission-graph-revision]
[metabase.premium-features.core :refer [defenterprise]]
- [metabase.util :as u]
[metabase.util.i18n :refer [tru]]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
@@ -22,8 +21,8 @@
"Log changes to the permissions graph."
[old new]
(log/debug "Changing permissions"
- "\n FROM:" (u/pprint-to-str :magenta old)
- "\n TO:" (u/pprint-to-str :blue new)))
+ "FROM:" (pr-str old)
+ "TO:" (pr-str new)))
(defn check-revision-numbers
"Check that the revision number coming in as part of `new-graph` matches the one from `old-graph`. This way we can
diff --git a/src/metabase/plugins/impl.clj b/src/metabase/plugins/impl.clj
index c0b230b94cd..94e191c042e 100644
--- a/src/metabase/plugins/impl.clj
+++ b/src/metabase/plugins/impl.clj
@@ -36,12 +36,12 @@
;; rather than failing to launch entirely. Log instructions for what should be done to fix the problem.
(catch Throwable e
(log/warn
- e
(format "Metabase cannot use the plugins directory %s" filename)
"\n"
"Please make sure the directory exists and that Metabase has permission to write to it."
"You can change the directory Metabase uses for modules by setting the environment variable MB_PLUGINS_DIR."
- "Falling back to a temporary directory for now.")
+ "Falling back to a temporary directory for now."
+ (str "Error: " (ex-message e)))
;; Check whether the fallback temporary directory is writable. If it's not, there's no way for us to
;; gracefully proceed here. Throw an Exception detailing the critical issues.
(let [path (u.files/get-path (System/getProperty "java.io.tmpdir"))]
@@ -176,7 +176,7 @@
(try
(init-plugin! path)
(catch Throwable e
- (log/errorf e "Failed to initialize plugin %s" (.getFileName path))))))
+ (log/errorf "Failed to initialize plugin %s: %s" (.getFileName path) (ex-message e))))))
(defn- load! []
;; Load any user-supplied plugin JARs from the plugins directory (e.g. Oracle JDBC driver).
diff --git a/src/metabase/premium_features/api.clj b/src/metabase/premium_features/api.clj
index 8bb774e7ff6..f78a6549a81 100644
--- a/src/metabase/premium_features/api.clj
+++ b/src/metabase/premium_features/api.clj
@@ -36,7 +36,7 @@
(when-not (<= 200 (:status response) 299)
(log/warnf "LLM proxy token cache invalidation failed with status %s" (:status response))))
(catch Exception e
- (log/warn e "Failed to invalidate LLM proxy token cache"))))))
+ (log/warnf "Failed to invalidate LLM proxy token cache: %s" (ex-message e)))))))
#_{:clj-kondo/ignore [:metabase/validate-defendpoint-has-response-schema]}
(api.macros/defendpoint :post "/token/refresh"
diff --git a/src/metabase/premium_features/token_check.clj b/src/metabase/premium_features/token_check.clj
index 3ebd9e2c624..182bcab8133 100644
--- a/src/metabase/premium_features/token_check.clj
+++ b/src/metabase/premium_features/token_check.clj
@@ -229,7 +229,7 @@
:content-type :json
:throw-exceptions false})
(catch Throwable e
- (log/error e "Error sending metering events"))))))))
+ (log/errorf "Error sending metering events: %s" (ex-message e)))))))))
;;;;;;;;;;;;;;;;;;;; Airgap Tokens ;;;;;;;;;;;;;;;;;;;;
@@ -407,7 +407,7 @@
(try
(premium-features.settings/locked-meters! (extract-locks (:meters result)))
(catch Throwable t
- (log/warn t "Failed to mirror :locked-meters from token-check response")))))
+ (log/warnf "Failed to mirror :locked-meters from token-check response: %s" (ex-message t))))))
(def ^:dynamic *testing-only-call-after-refresh*
"When non-nil, a zero-arg function called after async background refresh completes.
@@ -464,7 +464,7 @@
(try
(do-refresh! token token-hash)
(catch Exception e
- (log/error e "Background premium features refresh failed"))
+ (log/errorf "Background premium features refresh failed: %s" (ex-message e)))
(finally
(reset! refresh-in-progress? false)
(when-let [after *testing-only-call-after-refresh*]
@@ -594,7 +594,7 @@
(setting/set-value-of-type! :string :premium-embedding-token new-value)
(events/publish-event! :event/set-premium-embedding-token {})
(catch Throwable e
- (log/error e "Error setting premium features token")
+ (log/errorf "Error setting premium features token: %s" (ex-message e))
;; merge in error-details if present
(throw (ex-info (.getMessage e) (merge
{:message (.getMessage e), :status-code 400}
@@ -608,8 +608,7 @@
(let [cached-logger (memoize/ttl
^{::memoize/args-fn (fn [[token _e]] [token])}
(fn [_token e]
- (log/error "Error validating token:" (ex-message e))
- (log/debug e "Error validating token"))
+ (log/errorf "Error validating token: %s" (ex-message e)))
;; log every five minutes
:ttl/threshold (* 1000 60 5))]
(mu/defn ^:dynamic *token-features* :- [:set ms/NonBlankString]
diff --git a/src/metabase/product_feedback/api.clj b/src/metabase/product_feedback/api.clj
index 56dbd0146b4..787f014eade 100644
--- a/src/metabase/product_feedback/api.clj
+++ b/src/metabase/product_feedback/api.clj
@@ -24,7 +24,7 @@
:source source
:email email})})
(catch Exception e
- (log/warn e)
+ (log/warn (ex-message e))
(throw e))))
;; TODO (Cam 2025-11-25) please add a response schema to this API endpoint, it makes it easier for our customers to
diff --git a/src/metabase/product_feedback/task/creator_sentiment_emails.clj b/src/metabase/product_feedback/task/creator_sentiment_emails.clj
index afce3373e41..4994a97f90a 100644
--- a/src/metabase/product_feedback/task/creator_sentiment_emails.clj
+++ b/src/metabase/product_feedback/task/creator_sentiment_emails.clj
@@ -99,7 +99,7 @@
(try
(messages/send-creator-sentiment-email! creator (blob creator))
(catch Throwable e
- (log/error e "Problem sending creator sentiment email:")))))))
+ (log/errorf "Problem sending creator sentiment email: %s" (ex-message e))))))))
(task/defjob ^{:doc "Sends out a monthly survey to a portion of the creators."} CreatorSentimentEmail [_]
(let [current-week (.get (t/local-date) (.weekOfWeekBasedYear (WeekFields/of (Locale/getDefault))))]
diff --git a/src/metabase/product_feedback/task/follow_up_emails.clj b/src/metabase/product_feedback/task/follow_up_emails.clj
index 63266ffda4c..636d18e249c 100644
--- a/src/metabase/product_feedback/task/follow_up_emails.clj
+++ b/src/metabase/product_feedback/task/follow_up_emails.clj
@@ -31,7 +31,7 @@
(try
(messages/send-follow-up-email! (:email admin))
(catch Throwable e
- (log/error e "Problem sending follow-up email:"))
+ (log/errorf "Problem sending follow-up email: %s" (ex-message e)))
(finally
(product-feedback.settings/follow-up-email-sent! true))))))
diff --git a/src/metabase/pulse/send.clj b/src/metabase/pulse/send.clj
index 3aeccb33339..c19230823ff 100644
--- a/src/metabase/pulse/send.clj
+++ b/src/metabase/pulse/send.clj
@@ -110,7 +110,7 @@
(try
(send-notification! (notification-info pulse dashboard pulse-channel) :notification/sync? (not async?))
(catch Exception e
- (log/errorf e "[Pulse %d] Error sending to %s channel" (:id pulse) (:channel_type pulse-channel)))))
+ (log/errorf "[Pulse %d] Error sending to %s channel: %s" (:id pulse) (:channel_type pulse-channel) (ex-message e)))))
nil))
(defn pulse->task-run-info
diff --git a/src/metabase/pulse/task/send_pulses.clj b/src/metabase/pulse/task/send_pulses.clj
index 9b963926f52..bbc65e886b8 100644
--- a/src/metabase/pulse/task/send_pulses.clj
+++ b/src/metabase/pulse/task/send_pulses.clj
@@ -66,7 +66,7 @@
:done))
(log/debugf "Pulse %d not found, Skipping." pulse-id))
(catch Throwable e
- (log/errorf e "Error sending Pulse %d to channel ids: %s" pulse-id (str/join ", " channel-ids))))))
+ (log/errorf "Error sending Pulse %d to channel ids: %s: %s" pulse-id (str/join ", " channel-ids) (ex-message e))))))
(defn- send-trigger-timezone
[]
diff --git a/src/metabase/queries/events/cards_notification_deleted_on_card_save.clj b/src/metabase/queries/events/cards_notification_deleted_on_card_save.clj
index 8adc1807fcc..54ebb1a0966 100644
--- a/src/metabase/queries/events/cards_notification_deleted_on_card_save.clj
+++ b/src/metabase/queries/events/cards_notification_deleted_on_card_save.clj
@@ -48,4 +48,4 @@
(throw (ex-info "Unknown recipient type" {:recipient recipient}))))))]
(send-message! card recipients recipients-with-no-links actor))
(catch Throwable e
- (log/error e "Error sending notification email"))))
+ (log/errorf "Error sending notification email: %s" (ex-message e)))))
diff --git a/src/metabase/queries/models/card.clj b/src/metabase/queries/models/card.clj
index 7fba0f592ad..fdb638812e9 100644
--- a/src/metabase/queries/models/card.clj
+++ b/src/metabase/queries/models/card.clj
@@ -250,7 +250,7 @@
(try
(prefetch-tables-for-cards! cards-with-non-empty-queries)
(catch Throwable t
- (log/errorf t "Failed prefetching cards `%s`." (pr-str (map :id cards-with-non-empty-queries))))))
+ (log/errorf "Failed prefetching cards `%s`: %s" (pr-str (map :id cards-with-non-empty-queries)) (ex-message t)))))
(query-perms/with-card-instances (when (seq source-card-ids)
(t2/select-fn->fn :id identity [:model/Card :id :collection_id :card_schema]
:id [:in source-card-ids]))
@@ -762,20 +762,17 @@
Always returns `card`."
[card]
(when (= (:dataset_query card) {})
- (log/infof "Card %d has a blank :dataset_query - this indicates a Metabase issue. Legacy MBQL: %s"
- (:id card) (:legacy_query card))
+ (log/infof "Card %d has a blank :dataset_query - this indicates a Metabase issue."
+ (:id card))
(let [uniques (swap! unique-cards-with-blank-dataset-query conj (:id card))]
(analytics/set-gauge! :metabase-card/unique-cards-failed-conversion (count uniques))))
;; Always returns the original card.
card)
-(defn- mbql5-conversion-clean-callback [untransformed-card pre-cleaning-query post-cleaning-query]
+(defn- mbql5-conversion-clean-callback [untransformed-card _pre-cleaning-query _post-cleaning-query]
(analytics/inc! :metabase-card/conversions-requiring-cleaning)
- (log/infof "MBQL 4->5 conversion for Card %d had real 'clean' changes from %s into %s; :legacy_query is %s"
- (:id untransformed-card)
- (pr-str (dissoc pre-cleaning-query :lib/metadata))
- (pr-str (dissoc post-cleaning-query :lib/metadata))
- (:legacy_query untransformed-card)))
+ (log/infof "MBQL 4->5 conversion for Card %d had real 'clean' changes"
+ (:id untransformed-card)))
;; Uses [[lib/with-card-clean-hook]] to bind a callback which logs the impact of the cleaning process during
;; `transform-out`, so that we can log whenever a card gets converted and [[lib.convert/clean]] makes material
@@ -1281,10 +1278,7 @@
(try
(update-associated-parameters! card-before-update card-updates)
(catch Throwable e
- (log/error e "Update of dependent card parameters failed!")
- (log/debug e
- "`card-before-update`:" (pr-str card-before-update)
- "`card-updates`:" (pr-str card-updates))))
+ (log/errorf "Update of dependent card parameters failed!: %s" (ex-message e))))
(collection/check-for-remote-sync-update card-before-update))
;; Fetch the updated Card from the DB
(let [card (t2/select-one :model/Card :id (:id card-before-update))]
diff --git a/src/metabase/queries/models/card/metadata.clj b/src/metabase/queries/models/card/metadata.clj
index 7d1139e4155..0ba248a6a31 100644
--- a/src/metabase/queries/models/card/metadata.clj
+++ b/src/metabase/queries/models/card/metadata.clj
@@ -30,7 +30,7 @@
#_{:clj-kondo/ignore [:deprecated-var]}
(qp.metadata/legacy-result-metadata query api/*current-user-id*)
(catch Throwable e
- (log/errorf e "Error calculating result metadata for Card: %s" (ex-message e))
+ (log/errorf "Error calculating result metadata for Card: %s" (ex-message e))
[]))))
(def ^:private metadata-sync-wait-ms
@@ -66,7 +66,7 @@ saved later when it is ready."
(combiner @futur)
(catch Throwable e
(future-cancel futur)
- (log/errorf e "Error blending model metadata: %s" (ex-message e))
+ (log/errorf "Error blending model metadata: %s" (ex-message e))
metadata')))}
{:metadata (combiner result)})))
@@ -167,7 +167,7 @@ saved later when it is ready."
(log/infof "Metadata updated asynchronously for card %s" id))
(log/infof "Not updating metadata asynchronously for card %s because query has changed" id)))))
(catch Throwable e
- (log/errorf e "Error updating metadata for Card %d asynchronously: %s" id (ex-message e)))))))
+ (log/errorf "Error updating metadata for Card %d asynchronously: %s" id (ex-message e)))))))
(defn infer-metadata
"Infer the default result_metadata to store for MBQL cards.
diff --git a/src/metabase/queries/models/query.clj b/src/metabase/queries/models/query.clj
index ffb118ef735..1e2bd5e1a40 100644
--- a/src/metabase/queries/models/query.clj
+++ b/src/metabase/queries/models/query.clj
@@ -182,7 +182,7 @@
(t2/with-transaction [_conn]
(insert-query-entries! new-entry))
(catch Throwable e
- (log/tracef e "Error inserting concurrently created Query entries: %s" (ex-message e))))))))
+ (log/tracef "Error inserting concurrently created Query entries: %s" (ex-message e))))))))
(mr/def ::database-and-table-ids
[:map
diff --git a/src/metabase/query_permissions/impl.clj b/src/metabase/query_permissions/impl.clj
index 8042078afe2..c469aa65655 100644
--- a/src/metabase/query_permissions/impl.clj
+++ b/src/metabase/query_permissions/impl.clj
@@ -252,7 +252,7 @@
{:query (or (u/ignore-exceptions (mbql.normalize/normalize query))
query)}
e)]
- (if throw-exceptions? (throw e) (log/error e)))
+ (if throw-exceptions? (throw e) (log/error (ex-message e))))
{:perms/create-queries {0 :query-builder}})))) ; table 0 will never exist
(defn- mbql5-required-perms
diff --git a/src/metabase/query_processor/card.clj b/src/metabase/query_processor/card.clj
index 2d33b4b0acb..addb5e7d91f 100644
--- a/src/metabase/query_processor/card.clj
+++ b/src/metabase/query_processor/card.clj
@@ -357,8 +357,7 @@
:metadata/own-model-query? true))]
(when (seq parameters)
(validate-card-parameters card-id (:dataset_query card) (lib/normalize ::lib.schema.parameter/parameters parameters)))
- (log/tracef "Running query for Card %d (dashcard %s):\n%s" card-id dashcard-id
- (u/pprint-to-str query))
+ (log/tracef "Running query for Card %d (dashcard %s)" card-id dashcard-id)
(binding [qp.perms/*card-id* card-id]
(when-let [context (card-read-context info)]
(events/publish-event! :event/card-read {:object-id card-id
diff --git a/src/metabase/query_processor/dashboard.clj b/src/metabase/query_processor/dashboard.clj
index 5191a95f158..2f8343dda39 100644
--- a/src/metabase/query_processor/dashboard.clj
+++ b/src/metabase/query_processor/dashboard.clj
@@ -1,6 +1,6 @@
(ns metabase.query-processor.dashboard
"Code for running a query in the context of a specific DashboardCard."
- (:refer-clojure :exclude [some select-keys not-empty get-in])
+ (:refer-clojure :exclude [some not-empty get-in])
(:require
[clojure.string :as str]
[medley.core :as m]
@@ -20,7 +20,7 @@
[metabase.util.i18n :refer [tru]]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
- [metabase.util.performance :refer [select-keys some not-empty get-in]]
+ [metabase.util.performance :refer [some not-empty get-in]]
[steffan-westcott.clj-otel.api.trace.span :as span]
^{:clj-kondo/ignore [:discouraged-namespace]}
[toucan2.core :as t2]))
@@ -43,15 +43,14 @@
(throw (ex-info (tru "Unable to resolve invalid query parameter: parameter is missing :id")
{:type qp.error-type/invalid-parameter
:invalid-parameter request-param})))
- (log/tracef "Resolving parameter %s\n%s" (pr-str param-id) (u/pprint-to-str request-param))
+ (log/tracef "Resolving parameter %s" (pr-str param-id))
;; find information about this dashboard parameter by its parameter `:id`. If no parameter with this ID
;; exists, it is an error.
(let [matching-param (or (get param-id->param param-id)
(throw (ex-info (tru "Dashboard does not have a parameter with ID {0}." (pr-str param-id))
{:type qp.error-type/invalid-parameter
:status-code 400})))]
- (log/tracef "Found matching Dashboard parameter\n%s" (u/pprint-to-str (update matching-param :mappings (fn [mappings]
- (into #{} (map #(dissoc % :dashcard)) mappings)))))
+ (log/tracef "Found matching Dashboard parameter %s" (pr-str param-id))
;; now find the mapping for this specific card. If there is no mapping, we can just ignore this parameter.
(when-let [matching-mapping (or (some (fn [mapping]
(when (and (= (:card_id mapping) card-id)
@@ -59,9 +58,8 @@
mapping))
(:mappings matching-param))
(log/tracef "Parameter has no mapping for Card %d; skipping" card-id))]
- (log/tracef "Found matching mapping for Card %d, Dashcard %d:\n%s"
- card-id dashcard-id
- (u/pprint-to-str (update matching-mapping :dashcard #(select-keys % [:id :parameter_mappings]))))
+ (log/tracef "Found matching mapping for Card %d, Dashcard %d"
+ card-id dashcard-id)
;; if `request-param` specifies type, then validate that the type is allowed
(when (:type request-param)
(qp.card/check-allowed-parameter-value-type
@@ -143,18 +141,15 @@
(when-let [user-id api/*current-user-id*]
(when (seq request-params)
(user-parameter-value/store! user-id dashboard-id request-params)))
- (log/tracef "Dashboard parameters:\n%s\nRequest parameters:\n%s\nMerged:\n%s"
- (u/pprint-to-str (update-vals dashboard-param-id->param
- (fn [param]
- (update param :mappings (fn [mappings]
- (into #{} (map #(dissoc % :dashcard)) mappings))))))
- (u/pprint-to-str request-param-id->param)
- (u/pprint-to-str merged-parameters))
+ (log/tracef "Merged %d dashboard parameter(s) and %d request parameter(s) into %d parameter(s)"
+ (count dashboard-param-id->param)
+ (count request-param-id->param)
+ (count merged-parameters))
(u/prog1
(into [] (comp (map (partial resolve-param-for-card card-id dashcard-id dashboard-param-id->param))
(filter some?))
merged-parameters)
- (log/tracef "Resolved =>\n%s" (u/pprint-to-str <>)))))
+ (log/tracef "Resolved %d parameter(s)" (count <>)))))
(defn process-query-for-dashcard
"Like [[metabase.query-processor.card/process-query-for-card]], but runs the query for a `DashboardCard` with
@@ -198,9 +193,8 @@
(dissoc options :dashboard :card)
{:parameters resolved-params
:dashboard-id dashboard-id})]
- (log/tracef "Running Query for Dashboard %d, Card %d, Dashcard %d with options\n%s"
- dashboard-id card-id dashcard-id
- (u/pprint-to-str options))
+ (log/tracef "Running Query for Dashboard %d, Card %d, Dashcard %d"
+ dashboard-id card-id dashcard-id)
;; we've already validated our parameters, so we don't need the [[qp.card]] namespace to do it again
(binding [qp.card/*allow-arbitrary-mbql-parameters* true]
(m/mapply qp.card/process-query-for-card card export-format options))))))
diff --git a/src/metabase/query_processor/metadata.clj b/src/metabase/query_processor/metadata.clj
index 08f83ec80cd..ec9f6c90158 100644
--- a/src/metabase/query_processor/metadata.clj
+++ b/src/metabase/query_processor/metadata.clj
@@ -61,7 +61,7 @@
(try
(qp/process-query query' result-metadata-rff)
(catch Throwable e
- (log/error e "Error running query to determine Card result metadata")
+ (log/errorf "Error running query to determine Card result metadata: %s" (ex-message e))
[]))))
(mu/defn- metadata-from-driver :- [:sequential :map]
diff --git a/src/metabase/query_processor/middleware/add_remaps.clj b/src/metabase/query_processor/middleware/add_remaps.clj
index 1ae8a62ade0..254af7931f7 100644
--- a/src/metabase/query_processor/middleware/add_remaps.clj
+++ b/src/metabase/query_processor/middleware/add_remaps.clj
@@ -27,7 +27,6 @@
See also [[metabase.parameters.chain-filter]] for another explanation of remapping."
(:refer-clojure :exclude [mapv select-keys some empty? not-empty get-in])
(:require
- [clojure.data :as data]
[medley.core :as m]
[metabase.lib-be.core :as lib-be]
[metabase.lib.core :as lib]
@@ -439,7 +438,7 @@
from-display-name :name
to-name :human-readable-field-name} :- ::external-remapping]
(log/trace "Considering column\n"
- (u/pprint-to-str 'cyan (select-keys column [:id :name :fk_field_id :display_name :options]))
+ (pr-str (select-keys column [:id :fk_field_id :options]))
(u/colorize :magenta "\nAdd :remapped_to metadata?")
"\n=>" '(= dimension-id original-field-dimension-id)
"\n=>" (list '= dimension-id original-field-dimension-id)
@@ -474,11 +473,11 @@
from-name)
:display_name from-display-name}))
(when (not= column <>)
- (log/tracef "Added metadata:\n%s" (u/pprint-to-str 'green (second (data/diff column <>)))))))
+ (log/trace "Added remapping metadata to column"))))
(mu/defn- merge-metadata-for-externally-remapped-column :- [:maybe [:sequential :map]]
[columns :- [:maybe [:sequential :map]] dimension :- ::external-remapping]
- (log/tracef "Merging metadata for external dimension\n%s" (u/pprint-to-str 'yellow (into {} dimension)))
+ (log/tracef "Merging metadata for external dimension %s" (:id dimension))
(mapv #(merge-metadata-for-externally-remapped-column* columns % dimension)
columns))
diff --git a/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj b/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj
index 4b387268ff5..93d4a87c874 100644
--- a/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj
+++ b/src/metabase/query_processor/middleware/auto_bucket_datetimes.clj
@@ -54,7 +54,7 @@
field-ids)
;; don't fail if some of the Fields are invalid.
(catch Throwable e
- (log/errorf e "Error fetching Fields: %s" (ex-message e))
+ (log/errorf "Error fetching Fields: %s" (ex-message e))
nil))]
[id (select-keys field [:base-type :effective-type :semantic-type])])))))
@@ -74,7 +74,7 @@
(when-let [expr-type (try
(lib.walk/apply-f-for-stage-at-path lib/type-of query stage-path x)
(catch Throwable e
- (log/errorf e "Error calculating expression type: %s" (ex-message e))
+ (log/errorf "Error calculating expression type: %s" (ex-message e))
nil))]
(isa? expr-type :type/Boolean))))
diff --git a/src/metabase/query_processor/middleware/cache.clj b/src/metabase/query_processor/middleware/cache.clj
index d45afbaa4ba..f013e8a3347 100644
--- a/src/metabase/query_processor/middleware/cache.clj
+++ b/src/metabase/query_processor/middleware/cache.clj
@@ -61,7 +61,7 @@
(i/purge-old-entries! backend (cache/query-caching-max-ttl))
(log/trace "Successfully purged old cache entries.")
(catch Throwable e
- (log/errorf e "Error purging old cache entries: %s" (ex-message e))))))
+ (log/errorf "Error purging old cache entries: %s" (ex-message e))))))
(defonce ^:private purge-queue
(delay (grouper/start!
@@ -111,8 +111,8 @@
true)))
(catch Throwable e
(if (= (:type (ex-data e)) ::impl/max-bytes)
- (log/debugf e "Not caching results: results are larger than %s KB" (cache/query-caching-max-kb))
- (log/errorf e "Error saving query results to cache: %s" (ex-message e)))
+ (log/debugf "Not caching results: results are larger than %s KB" (cache/query-caching-max-kb))
+ (log/errorf "Error saving query results to cache: %s" (ex-message e)))
false)))
(defn- save-results-xform [start-time-ns metadata query-hash strategy rf]
@@ -326,7 +326,7 @@
(log/debug "Request is closed; no one to return cached results to")
[::canceled nil])
(catch Throwable e
- (log/errorf e "Error attempting to fetch cached results for query with hash %s: %s"
+ (log/errorf "Error attempting to fetch cached results for query with hash %s: %s"
(i/short-hex-hash query-hash)
(ex-message e))
[::miss nil]))))
diff --git a/src/metabase/query_processor/middleware/cache/impl.clj b/src/metabase/query_processor/middleware/cache/impl.clj
index 60f2d4ab7ce..356d86ecb0d 100644
--- a/src/metabase/query_processor/middleware/cache/impl.clj
+++ b/src/metabase/query_processor/middleware/cache/impl.clj
@@ -45,7 +45,7 @@
(defn- freeze!
[^OutputStream os obj]
- (log/tracef "Freezing %s" (pr-str obj))
+ (log/tracef "Freezing %s" (class obj))
(nippy/freeze-to-out! os obj))
(defn do-with-serialization
@@ -85,7 +85,7 @@
(try
(freeze! os obj)
(catch Throwable e
- (log/trace e "Caught error when freezing object")
+ (log/tracef "Caught error when freezing object: %s" (ex-message e))
(reset! error e))))
nil)
(fn result* []
diff --git a/src/metabase/query_processor/middleware/cache_backend/db.clj b/src/metabase/query_processor/middleware/cache_backend/db.clj
index b771018688e..9c12ac6a6a2 100644
--- a/src/metabase/query_processor/middleware/cache_backend/db.clj
+++ b/src/metabase/query_processor/middleware/cache_backend/db.clj
@@ -102,7 +102,7 @@
(try
(t2/delete! (t2/table-name :model/QueryCache) :query_hash query-hash)
(catch Throwable e
- (log/error e "Error deleting outdated cache entry")))
+ (log/errorf "Error deleting outdated cache entry: %s" (ex-message e))))
nil)
(defn- purge-old-cache-entries!
@@ -114,7 +114,7 @@
(t2/delete! (t2/table-name :model/QueryCache)
:updated_at [:<= (seconds-ago max-age-seconds)])
(catch Throwable e
- (log/error e "Error purging old cache entries")))
+ (log/errorf "Error purging old cache entries: %s" (ex-message e))))
nil)
(defn- save-results!
@@ -130,7 +130,7 @@
:results final-results
:refresh_started_at nil}))
(catch Throwable e
- (log/error e "Error saving query results to cache.")))
+ (log/errorf "Error saving query results to cache: %s" (ex-message e))))
nil))
(defmethod i/cache-backend :db
diff --git a/src/metabase/query_processor/middleware/expand_macros.clj b/src/metabase/query_processor/middleware/expand_macros.clj
index 074004858ba..5c8ee0ec80a 100644
--- a/src/metabase/query_processor/middleware/expand_macros.clj
+++ b/src/metabase/query_processor/middleware/expand_macros.clj
@@ -56,9 +56,8 @@
(converted by the segment model's after-select hook), so we just extract the first stage."
[_metadata-providerable :- ::lib.schema.metadata/metadata-providerable
{:keys [definition], :as _legacy-macro} :- ::legacy-macro]
- (log/tracef "Extracting MBQL 5 stage from segment definition:\n%s" (u/pprint-to-str definition))
- (u/prog1 (first (:stages definition))
- (log/tracef "Extracted stage:\n%s" (u/pprint-to-str <>))))
+ (log/trace "Extracting MBQL 5 stage from segment definition")
+ (first (:stages definition)))
(mu/defn- legacy-macro-filters :- [:maybe [:sequential ::lib.schema.expression/boolean]]
"Get the filter(s) associated with a Segment."
@@ -99,9 +98,7 @@
[:segment _opts (id :guard pos-int?)]
(let [legacy-segment (get id->legacy-segment id)
filter-clauses (legacy-macro-filters legacy-segment)]
- (log/debugf "Expanding legacy Segment macro\n%s" (u/pprint-to-str &match))
- (doseq [filter-clause filter-clauses]
- (log/tracef "Adding filter clause for legacy Segment %d:\n%s" id (u/pprint-to-str filter-clause)))
+ (log/debugf "Expanding legacy Segment macro for Segment %d (%d filter clauses)" id (count filter-clauses))
;; replace a single segment with a single filter, wrapping them in `:and` if needed... we will unwrap once
;; we've expanded all of the :segment refs.
(if (> (count filter-clauses) 1)
diff --git a/src/metabase/query_processor/middleware/measures.clj b/src/metabase/query_processor/middleware/measures.clj
index c164382d8d9..2b0d49145b8 100644
--- a/src/metabase/query_processor/middleware/measures.clj
+++ b/src/metabase/query_processor/middleware/measures.clj
@@ -88,7 +88,7 @@
(not aggregation) (throw (ex-info (tru "Measure {0} has no aggregation defined." id)
{:type qp.error-type/invalid-measure, :measure measure}))
:else (do
- (log/debugf "Expanding measure %d:\n%s\n->\n%s" id (u/pprint-to-str &match) (u/pprint-to-str aggregation))
+ (log/debugf "Expanding measure %d" id)
;; Preserve :lib/uuid and :display-name from the measure clause options if present
;; This is important so that :aggregation refs pointing to the measure remain valid
(lib.options/update-options aggregation merge (select-keys opts [:lib/uuid :display-name]))))))
diff --git a/src/metabase/query_processor/middleware/normalize_query.clj b/src/metabase/query_processor/middleware/normalize_query.clj
index cbccb9d498d..2eb074aacaa 100644
--- a/src/metabase/query_processor/middleware/normalize_query.clj
+++ b/src/metabase/query_processor/middleware/normalize_query.clj
@@ -7,8 +7,6 @@
[metabase.lib.schema.id :as lib.schema.id]
[metabase.query-processor.error-type :as qp.error-type]
^{:clj-kondo/ignore [:deprecated-namespace]} [metabase.query-processor.store :as qp.store]
- [metabase.util :as u]
- [metabase.util.log :as log]
[metabase.util.malli :as mu]))
(defn- normalize*
@@ -24,8 +22,7 @@
keywords. Convert query to MBQL 5 if needed."
[query :- [:map [:database ::lib.schema.id/database]]]
(try
- (u/prog1 (normalize* query)
- (log/tracef "Normalized query:\n%s\n=>\n%s" (u/pprint-to-str query) (u/pprint-to-str <>)))
+ (normalize* query)
(catch Throwable e
(throw (ex-info (format "Error normalizing query: %s" (ex-message e))
{:type qp.error-type/qp
diff --git a/src/metabase/query_processor/middleware/optimize_temporal_filters.clj b/src/metabase/query_processor/middleware/optimize_temporal_filters.clj
index 6e8f1a0718d..851e290a546 100644
--- a/src/metabase/query_processor/middleware/optimize_temporal_filters.clj
+++ b/src/metabase/query_processor/middleware/optimize_temporal_filters.clj
@@ -299,11 +299,11 @@
(u/prog1 (optimize-clause query path clause)
(if <>
(when-not (= clause <>)
- (log/tracef "Optimized clause %s to %s" (pr-str clause) (pr-str <>)))
+ (log/trace "Optimized temporal filter clause"))
;; if for some reason `optimize-clause` doesn't return an optimized clause, log and error and use
;; the original. `can-optimize-clause?` shouldn't have said we could optimize this clause in the first
;; place
- (log/error "Error optimizing temporal clause: optimize-clause unexpectedly returned nil" (pr-str clause)))))
+ (log/error "Error optimizing temporal clause: optimize-clause unexpectedly returned nil"))))
clause)))
(mu/defn optimize-temporal-clauses :- ::lib.schema/query
diff --git a/src/metabase/query_processor/middleware/parameters.clj b/src/metabase/query_processor/middleware/parameters.clj
index 3aadbda54d2..7b149ece04f 100644
--- a/src/metabase/query_processor/middleware/parameters.clj
+++ b/src/metabase/query_processor/middleware/parameters.clj
@@ -2,7 +2,6 @@
"Middleware for substituting parameters in queries."
(:refer-clojure :exclude [mapv some])
(:require
- [clojure.data :as data]
[clojure.set :as set]
[medley.core :as m]
[metabase.lib.core :as lib]
@@ -76,7 +75,7 @@
(do
(log/errorf "Query does not have a stage %d, ignoring parameter %s"
param-stage-number
- (pr-str parameter))
+ (:id parameter))
query)
(lib/update-query-stage query param-stage-number
update :parameters
@@ -151,8 +150,7 @@
move-top-level-params-to-stage
expand-all)
(when (not= <> query)
- (when-let [diff (second (data/diff query <>))]
- (log/tracef "\n\nSubstituted params:\n%s\n" (u/pprint-to-str 'cyan diff))))))
+ (log/trace "Substituted params into query"))))
(mu/defn- assoc-database-id-in-snippet-tag :- ::lib.schema.template-tag/template-tags
[template-tags :- ::lib.schema.template-tag/template-tags
diff --git a/src/metabase/query_processor/middleware/parameters/mbql.clj b/src/metabase/query_processor/middleware/parameters/mbql.clj
index 3e23d520735..40675856a8e 100644
--- a/src/metabase/query_processor/middleware/parameters/mbql.clj
+++ b/src/metabase/query_processor/middleware/parameters/mbql.clj
@@ -163,14 +163,14 @@
(not target)
(do
- (log/debugf "Ignoring parameter %s because it has no target" (pr-str param))
+ (log/debugf "Ignoring parameter %s because it has no target" (pr-str (:id param)))
(recur stage more-params))
(or (nil? param-value)
(and (sequential? param-value)
(every? nil? param-value)))
(do
- (log/debugf "Ignoring parameter %s because it has no value" (pr-str param))
+ (log/debugf "Ignoring parameter %s because it has no value" (pr-str (:id param)))
(recur stage more-params))
(= (:type param) :temporal-unit)
@@ -179,6 +179,6 @@
:else
(let [filter-clause (or (build-filter-clause query stage-path (assoc param :value param-value))
- (log/warnf "build-filter-clause did not return a valid clause for param %s" (pr-str param)))
+ (log/warnf "build-filter-clause did not return a valid clause for param %s" (pr-str (:id param))))
stage' (lib.filter/add-filter-to-stage stage filter-clause)]
(recur stage' more-params))))))
diff --git a/src/metabase/query_processor/middleware/prefetch_metadata.clj b/src/metabase/query_processor/middleware/prefetch_metadata.clj
index d33266ecb42..1c9933a2e97 100644
--- a/src/metabase/query_processor/middleware/prefetch_metadata.clj
+++ b/src/metabase/query_processor/middleware/prefetch_metadata.clj
@@ -16,7 +16,7 @@
(lib/all-referenced-entity-ids [(lib/card->underlying-query metadata-provider card)]))
(catch Throwable e
;; prefetching is an optimization: a Card we cannot make sense of here will be dealt with when it is resolved
- (log/debugf e "Error getting referenced entity ids for Card %s" (:id card)))))
+ (log/debugf "Error getting referenced entity ids for Card %s: %s" (:id card) (ex-message e)))))
(defn- all-referenced-entity-ids
"Collect the ids of all the entities referenced by `query`, following Card references (source cards and
diff --git a/src/metabase/query_processor/middleware/process_userland_query.clj b/src/metabase/query_processor/middleware/process_userland_query.clj
index 4052b27932b..9c1b64c60f5 100644
--- a/src/metabase/query_processor/middleware/process_userland_query.clj
+++ b/src/metabase/query_processor/middleware/process_userland_query.clj
@@ -57,7 +57,7 @@
(try
(query/save-queries-and-update-average-execution-times! entries)
(catch Throwable e
- (log/error e "Error updating query average execution times"))))
+ (log/errorf "Error updating query average execution times: %s" (ex-message e)))))
(try
(let [{with-context true, no-context false} (group-by (comp some? :context) query-executions)]
(when (seq no-context)
@@ -65,7 +65,7 @@
(when (seq with-context)
(t2/insert! :model/QueryExecution (map #(dissoc % :json_query) with-context))))
(catch Throwable e
- (log/error e "Error saving query execution info")))))
+ (log/errorf "Error saving query execution info: %s" (ex-message e))))))
(defonce ^:private save-execution-metadata-queue
(delay (grouper/start!
@@ -100,7 +100,7 @@
(try
(save-execution-metadata! (assoc query-execution :error (str message)))
(catch Throwable e
- (log/errorf e "Unexpected error saving failed query execution: %s" (ex-message e)))))
+ (log/errorf "Unexpected error saving failed query execution: %s" (ex-message e)))))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | Middleware |
diff --git a/src/metabase/query_processor/middleware/results_metadata.clj b/src/metabase/query_processor/middleware/results_metadata.clj
index df890fb173a..3c42d224a8f 100644
--- a/src/metabase/query_processor/middleware/results_metadata.clj
+++ b/src/metabase/query_processor/middleware/results_metadata.clj
@@ -91,7 +91,7 @@
;; if for some reason we weren't able to record results metadata for this query then just proceed as normal
;; rather than failing the entire query
(catch Throwable e
- (log/error e "Error recording results metadata for query"))))
+ (log/errorf "Error recording results metadata for query: %s" (ex-message e)))))
(defn- merge-final-column-metadata
"Because insights are generated by reducing functions, they start working before the entire query metadata is in its
diff --git a/src/metabase/query_processor/middleware/update_used_cards.clj b/src/metabase/query_processor/middleware/update_used_cards.clj
index df50f79b192..7783316ce61 100644
--- a/src/metabase/query_processor/middleware/update_used_cards.clj
+++ b/src/metabase/query_processor/middleware/update_used_cards.clj
@@ -38,7 +38,7 @@
card-id->timestamp))
:updated_at :updated_at}}))
(catch Throwable e
- (log/error e "Error updating used cards")))))
+ (log/errorf "Error updating used cards: %s" (ex-message e))))))
(defonce ^:private update-used-cards-queue
(delay
diff --git a/src/metabase/query_processor/parameters/values.clj b/src/metabase/query_processor/parameters/values.clj
index cfa910c338a..33fbd56b970 100644
--- a/src/metabase/query_processor/parameters/values.clj
+++ b/src/metabase/query_processor/parameters/values.clj
@@ -230,7 +230,7 @@
(throw (ex-info (tru "Card {0} not found." card-id)
{:card-id card-id, :tag tag, :type qp.error-type/invalid-parameter})))]
(try
- (log/tracef "Compiling referenced query for Card %d\n%s" card-id (u/pprint-to-str query))
+ (log/tracef "Compiling referenced query for Card %d" card-id)
(let [query (assoc query :info {:card-id card-id})
{:keys [query params]} (or (when (qp.persistence/can-substitute? card persisted-info)
{:query (qp.persistence/persisted-info-native-query
@@ -408,8 +408,8 @@
(every? string? value))
(mapv (partial parse-value-for-field-type effective-type) value))]
(when (not= value new-value)
- (log/tracef "update filter for base-type: %s value: %s -> %s"
- (pr-str effective-type) (pr-str value) (pr-str new-value)))
+ (log/tracef "updated filter value for base-type: %s"
+ (pr-str effective-type)))
(cond-> field-filter
new-value (assoc-in [:value :value] new-value))))
@@ -475,12 +475,12 @@
[[metabase.query-processor.middleware.parameters/expand-stage]]. "
[metadata-providerable :- ::lib.schema.metadata/metadata-providerable
{tags :template-tags, params :parameters, :as _stage} :- ::lib.schema/stage]
- (log/tracef "Building params map out of tags\n%s\nand params\n%s\n" (u/pprint-to-str tags) (u/pprint-to-str params))
+ (log/tracef "Building params map out of %d tag(s) and %d param(s)" (count tags) (count params))
(try
(into {} (for [{tag-name :name, :as tag} tags
:let [v (value-for-tag metadata-providerable tag params)]]
(do
- (log/tracef "Value for tag %s\n%s\n->\n%s" (pr-str tag-name) (u/pprint-to-str tag) (u/pprint-to-str v))
+ (log/tracef "Resolved value for tag %s" (pr-str tag-name))
(let [k' (or (lib/match-and-normalize-tag-name tag-name) tag-name)]
[k' v]))))
(catch Throwable e
diff --git a/src/metabase/query_processor/pipeline.clj b/src/metabase/query_processor/pipeline.clj
index d80cb9742f2..c0faac507d1 100644
--- a/src/metabase/query_processor/pipeline.clj
+++ b/src/metabase/query_processor/pipeline.clj
@@ -122,7 +122,7 @@
(when-not (interrupted-exception? e)
(throw e))
;; ok, at this point we know it's an InterruptedException.
- (log/trace e "Caught InterruptedException when executing query, this means the query was canceled. Ignoring exception.")
+ (log/trace "Caught InterruptedException when executing query, this means the query was canceled. Ignoring exception.")
;; just to be extra safe and sure that the canceled chan has gotten a message. It's a promise channel so
;; duplicate messages don't matter
(some-> *canceled-chan* (a/>!! ::cancel))
diff --git a/src/metabase/query_processor/pivot.clj b/src/metabase/query_processor/pivot.clj
index 8b0757f30ec..e44ad568ef1 100644
--- a/src/metabase/query_processor/pivot.clj
+++ b/src/metabase/query_processor/pivot.clj
@@ -194,7 +194,7 @@
(seq info) (qp/userland-query info))]
(qp/process-query query rff))
(catch Throwable e
- (log/error e "Error processing additional pivot table query")
+ (log/errorf "Error processing additional pivot table query: %s" (ex-message e))
(throw e))))))
(mu/defn- process-queries-append-results
@@ -394,7 +394,7 @@
legacy-ref
breakouts))
(catch Throwable e
- (log/errorf e "Error finding matching column for ref %s" (pr-str legacy-ref))
+ (log/errorf "Error finding matching column for ref %s: %s" (pr-str legacy-ref) (ex-message e))
nil)))
process-refs (fn process-refs [refs]
(when (seq refs)
@@ -697,7 +697,7 @@
([query :- ::qp.schema/any-query
rff :- [:maybe ::qp.schema/rff]]
- (log/debugf "Running pivot query:\n%s" (u/pprint-to-str query))
+ (log/debug "Running pivot query")
;; Do not bind *card-id* here. Callers that run pivot queries for saved cards
;; (e.g. card.clj, dashboards) bind *card-id* themselves before calling
;; run-pivot-query, so binding it here from the query's :info map would be
diff --git a/src/metabase/query_processor/preprocess.clj b/src/metabase/query_processor/preprocess.clj
index 97d81aa8d4c..3f5dd9b704b 100644
--- a/src/metabase/query_processor/preprocess.clj
+++ b/src/metabase/query_processor/preprocess.clj
@@ -127,7 +127,6 @@
identity
(fn
([preprocessed]
- (log/debugf "Preprocessed query:\n\n%s" (u/pprint-to-str preprocessed))
preprocessed)
([query middleware-fn]
(try
diff --git a/src/metabase/query_processor/writeback.clj b/src/metabase/query_processor/writeback.clj
index 38e069e283c..b018b5badf0 100644
--- a/src/metabase/query_processor/writeback.clj
+++ b/src/metabase/query_processor/writeback.clj
@@ -14,7 +14,6 @@
[metabase.query-processor.preprocess :as qp.preprocess]
[metabase.query-processor.setup :as qp.setup]
^{:clj-kondo/ignore [:deprecated-namespace]} [metabase.query-processor.store :as qp.store]
- [metabase.util :as u]
[metabase.util.i18n :refer [tru]]
[metabase.util.log :as log]
[metabase.util.malli :as mu]))
@@ -47,7 +46,7 @@
(letfn [(qp* [query _rff]
(let [query (substitute-params query)]
;; ok, now execute the query.
- (log/debugf "Executing query\n\n%s" (u/pprint-to-str query))
+ (log/debug "Executing write query")
(driver/execute-write-query! driver/*driver* (lib/->legacy-MBQL query))))]
(apply-middleware qp* (concat execution-middleware qp/around-middleware))))
diff --git a/src/metabase/request/util.clj b/src/metabase/request/util.clj
index 221790e63b4..10a646e1cf7 100644
--- a/src/metabase/request/util.clj
+++ b/src/metabase/request/util.clj
@@ -159,5 +159,5 @@
result)
(catch Throwable e
(analytics/inc! :metabase-geocoding/errors)
- (log/error e "Error geocoding IP addresses" {:url url})
+ (log/errorf "Error geocoding IP addresses: %s" (ex-message e))
nil))))))
diff --git a/src/metabase/revisions/events.clj b/src/metabase/revisions/events.clj
index ba139245dee..5b4ad88f1b6 100644
--- a/src/metabase/revisions/events.clj
+++ b/src/metabase/revisions/events.clj
@@ -27,7 +27,7 @@
:is-creation? is-creation?
:message (:revision-message event)}))
(catch Throwable e
- (log/warnf e "Failed to process revision event for model %s" model)))))
+ (log/warnf "Failed to process revision event for model %s: %s" model (ex-message e))))))
(derive ::card-event ::event)
(derive :event/card-create ::card-event)
diff --git a/src/metabase/run_tracking/task.clj b/src/metabase/run_tracking/task.clj
index 5c129b27970..62729c2c6eb 100644
--- a/src/metabase/run_tracking/task.clj
+++ b/src/metabase/run_tracking/task.clj
@@ -56,7 +56,7 @@
(heartbeat-fn)
(catch InterruptedException e (throw e))
(catch Throwable t
- (log/error t "Error sending run-tracking heartbeat")))
+ (log/errorf "Error sending run-tracking heartbeat: %s" (ex-message t))))
(Thread/sleep (long (u/minutes->ms interval-minutes)))
(recur))
(catch InterruptedException _ nil))))
diff --git a/src/metabase/sample_data/impl.clj b/src/metabase/sample_data/impl.clj
index d09cb8c71ed..ffa2db8440c 100644
--- a/src/metabase/sample_data/impl.clj
+++ b/src/metabase/sample_data/impl.clj
@@ -108,7 +108,7 @@
(sync/sync-database! db))
(log/debug "Finished adding Sample Database.")
(catch Throwable e
- (log/error e "Failed to load sample database"))))
+ (log/errorf "Failed to load sample database: %s" (ex-message e)))))
(defn- table-schema-for-engine
"The schema value the sync process assigns to the sample database's tables for a given engine: H2 puts
diff --git a/src/metabase/search/appdb/core.clj b/src/metabase/search/appdb/core.clj
index 1669c7eb7ae..ffa8cc5308c 100644
--- a/src/metabase/search/appdb/core.clj
+++ b/src/metabase/search/appdb/core.clj
@@ -145,7 +145,7 @@
(future
(search.engine/init! search-engine {:force-reset? false}))
(catch Exception e
- (log/error e))))
+ (log/error (ex-message e)))))
;; Even if the index exists now, return an error so that we don't obscure that there was an issue.
(throw (ex-info "Search Index not found."
{:search-engine search-engine
@@ -287,7 +287,7 @@
(u/prog1 (populate-index! (if in-place? :search/updating :search/reindexing))
(search.index/activate-table!))
(catch Throwable e
- (log/error e "Error during reindexing")
+ (log/errorf "Error during reindexing: %s" (ex-message e))
(throw e))))
(derive :event/setting-update ::settings-changed-event)
diff --git a/src/metabase/search/appdb/index.clj b/src/metabase/search/appdb/index.clj
index 53287f3ab37..2819327bb80 100644
--- a/src/metabase/search/appdb/index.clj
+++ b/src/metabase/search/appdb/index.clj
@@ -144,7 +144,7 @@
(vswap! dropped conj table)
;; Deletion could fail if it races with other instances
(catch Exception e
- (log/warnf e "Failed to drop stale index %s" table))))
+ (log/warnf "Failed to drop stale index %s: %s" table (ex-message e)))))
(log/infof "Dropped %d stale indexes: %s" (count @dropped) @dropped)))
(defn- ->db-type [t]
@@ -218,12 +218,12 @@
(try
(create-table! table-name)
(catch Exception e
- (log/error e "Error creating pending index table, cleaning up metadata")
+ (log/errorf "Error creating pending index table, cleaning up metadata: %s" (ex-message e))
(try
(t2/with-connection [safe-conn (mdb/app-db)]
(t2/delete! :conn safe-conn :model/SearchIndexMetadata :index_name (name table-name)))
(catch Exception del-e
- (log/warn del-e "Error clearing out search metadata after failure")))
+ (log/warnf "Error clearing out search metadata after failure: %s" (ex-message del-e))))
(sync-tracking-atoms!))))
(let [pending (:pending (sync-tracking-atoms!))]
(log/infof "New pending index %s" pending)
@@ -236,7 +236,7 @@
(try
(specialization/analyze-table! table-name)
(catch Exception e
- (log/warnf e "Failed to analyze index table %s" table-name))))
+ (log/warnf "Failed to analyze index table %s: %s" table-name (ex-message e)))))
(defn activate-table!
"Make the pending index active if it exists. Returns true if it did so."
@@ -331,14 +331,13 @@
(if (table-not-found-exception? e2)
(throw (retry-upsert-ex table-type table-name refreshed-table-name e e2))
(do (analytics/inc! :metabase-search/appdb-index-batches-skipped {:table-type table-type})
- (log/errorf (retry-upsert-ex table-type table-name refreshed-table-name e e2)
- "Error upserting search index batch into %s table %s after refresh; skipping batch and continuing"
- (name table-type) refreshed-table-name)
+ (log/errorf "Error upserting search index batch into %s table %s after refresh; skipping batch and continuing: %s"
+ (name table-type) refreshed-table-name (ex-message e2))
nil))))))
;; Any other failure - log and continue so reindex can still finish.
(do (analytics/inc! :metabase-search/appdb-index-batches-skipped {:table-type table-type})
- (log/errorf e "Error upserting search index batch into %s table %s; skipping batch and continuing"
- (name table-type) table-name)
+ (log/errorf "Error upserting search index batch into %s table %s; skipping batch and continuing: %s"
+ (name table-type) table-name (ex-message e))
nil)))))))
(defn- batch-update!
diff --git a/src/metabase/search/core.clj b/src/metabase/search/core.clj
index f7e18776952..01cf29eada2 100644
--- a/src/metabase/search/core.clj
+++ b/src/metabase/search/core.clj
@@ -210,7 +210,7 @@
(try
(reindex-logic! opts)
(catch Exception e
- (log/error e "Reindex failed")
+ (log/errorf "Reindex failed: %s" (ex-message e))
(analytics/inc! :metabase-search/index-error)
(throw e))))]
(if (or search.ingestion/*force-sync* (not async?))
diff --git a/src/metabase/search/in_place/legacy.clj b/src/metabase/search/in_place/legacy.clj
index 90b64c37133..19474978603 100644
--- a/src/metabase/search/in_place/legacy.clj
+++ b/src/metabase/search/in_place/legacy.clj
@@ -16,9 +16,7 @@
[metabase.search.in-place.scoring :as scoring]
[metabase.search.in-place.util :as search.util]
[metabase.search.permissions :as search.permissions]
- [metabase.util :as u]
[metabase.util.honey-sql-2 :as h2x]
- [metabase.util.log :as log]
[metabase.util.malli :as mu]
[metabase.util.malli.schema :as ms]
[toucan2.core :as t2]))
@@ -716,9 +714,6 @@
(defn- results
[search-ctx]
(let [search-query (full-search-query search-ctx)]
- (log/tracef "Searching with query:\n%s\n%s"
- (u/pprint-to-str search-query)
- (mdb/format-sql (first (mdb/compile search-query))))
(mdb/streaming-reducible-query search-query)))
(defmethod search.engine/results
diff --git a/src/metabase/search/index_health.clj b/src/metabase/search/index_health.clj
index 55934b33150..1de12db7db0 100644
--- a/src/metabase/search/index_health.clj
+++ b/src/metabase/search/index_health.clj
@@ -114,7 +114,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/error e "Search index metric collector errored" {:check check-name})
+ (log/error "Search index metric collector errored" {:check check-name :error (ex-message e)})
{:health 0, :message (str "Metric collector errored: " (ex-message e))}))]
(set-index-gauge! gauge-key index value)
(when health
@@ -148,7 +148,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/error e "Search index health-row persist errored" {:check check-name}))))
+ (log/error "Search index health-row persist errored" {:check check-name :error (ex-message e)}))))
(defonce ^:private gauge-refresh-running? (atom false))
@@ -161,7 +161,7 @@
(catch InterruptedException e
(throw e))
(catch Exception e
- (log/error e "Search index gauge refresh errored" {:check check-name}))))
+ (log/error "Search index gauge refresh errored" {:check check-name :error (ex-message e)}))))
(defn- refresh-search-index-gauges!
[]
@@ -177,7 +177,7 @@
(submit-gauge-refresh! refresh-search-index-gauges!)
(catch Exception e
(reset! gauge-refresh-running? false)
- (log/error e "Could not schedule search index gauge refresh"))))
+ (log/errorf "Could not schedule search index gauge refresh: %s" (ex-message e)))))
nil)
;; Prometheus scrapes every Metabase process, whereas the scheduled metric job may run on only one member of
diff --git a/src/metabase/search/ingestion.clj b/src/metabase/search/ingestion.clj
index 7cc67acf552..2785c75af43 100644
--- a/src/metabase/search/ingestion.clj
+++ b/src/metabase/search/ingestion.clj
@@ -113,7 +113,7 @@
record)]
(f input))
(catch Exception e
- (log/warn e "Function execution failed for attribute" attr-key)
+ (log/warn "Function execution failed for attribute" attr-key ":" (ex-message e))
nil)))
(defn- execute-all-function-attrs
@@ -257,7 +257,7 @@
(let [n (vswap! failures inc)]
(cond
(<= n max-document-error-logs)
- (log/warnf t "Error building search document for %s %s; skipping" (:model m) (:id m))
+ (log/warnf "Error building search document for %s %s; skipping: %s" (:model m) (:id m) (ex-message t))
(= n (inc max-document-error-logs))
(log/warnf "Suppressing further per-document error logs after %d failures" max-document-error-logs)))
nil))]
@@ -417,7 +417,7 @@
{:success-handler (fn [_result _duration _]
(track-queue-size!))
:err-handler (fn [err _]
- (log/error err "Error indexing search entries")
+ (log/errorf "Error indexing search entries: %s" (ex-message err))
(analytics/inc! :metabase-search/index-error)
(track-queue-size!))
;; Note that each message can correspond to multiple documents,
diff --git a/src/metabase/search/semantic/core.clj b/src/metabase/search/semantic/core.clj
index c4225889d69..35596f527de 100644
--- a/src/metabase/search/semantic/core.clj
+++ b/src/metabase/search/semantic/core.clj
@@ -64,7 +64,7 @@
(try
(supported?)
(catch Exception e
- (log/warn e "Semantic search engine not supported")
+ (log/warnf "Semantic search engine not supported: %s" (ex-message e))
false)))
(defmethod search.engine/dependencies :search.engine/semantic [_]
@@ -87,7 +87,7 @@
(try
(update-index! document-reducible)
(catch Exception e
- (log/error e "Error updating semantic search engine")
+ (log/errorf "Error updating semantic search engine: %s" (ex-message e))
{})))
(defmethod search.engine/delete! :search.engine/semantic
@@ -95,7 +95,7 @@
(try
(delete-from-index! model ids)
(catch Exception e
- (log/error e "Error deleting from semantic search engine")
+ (log/errorf "Error deleting from semantic search engine: %s" (ex-message e))
{})))
(defmethod search.engine/init! :search.engine/semantic
@@ -104,7 +104,7 @@
(log/debug "Initializing semantic search engine")
(init! (search.ingestion/searchable-documents) opts)
(catch Exception e
- (log/error e "Error initializing semantic search engine")
+ (log/errorf "Error initializing semantic search engine: %s" (ex-message e))
(throw e))))
(defmethod search.engine/reindex! :search.engine/semantic
diff --git a/src/metabase/search/settings.clj b/src/metabase/search/settings.clj
index 48051731a9c..ac856c29e79 100644
--- a/src/metabase/search/settings.clj
+++ b/src/metabase/search/settings.clj
@@ -49,7 +49,7 @@
((requiring-resolve 'metabase.search.task.search-index/trigger-init-for-newly-active-engines!)
before)
(catch Throwable t
- (log/error t "Failed to trigger search index init for newly active engines")))))
+ (log/errorf "Failed to trigger search index init for newly active engines: %s" (ex-message t))))))
result))
:doc false)
diff --git a/src/metabase/segments/models/segment.clj b/src/metabase/segments/models/segment.clj
index 5cc642fc77a..118201c0258 100644
--- a/src/metabase/segments/models/segment.clj
+++ b/src/metabase/segments/models/segment.clj
@@ -48,8 +48,7 @@
(let [definition
(if (:aggregation definition)
(do
- (log/warn "Stripping :aggregation from MBQL4 segment definition during migration"
- {:segment-definition definition})
+ (log/warn "Stripping :aggregation from MBQL4 segment definition during migration")
(dissoc definition :aggregation))
definition)]
{:database database-id
@@ -188,7 +187,7 @@
(try
(migrated-segment-definition segment)
(catch Throwable e
- (log/error e "Error upgrading segment definition:" (ex-message e))
+ (log/errorf "Error upgrading segment definition: %s" (ex-message e))
nil)))
(t2/define-after-select :model/Segment
@@ -203,7 +202,7 @@
(try
(lib/describe-top-level-key definition :filters)
(catch Throwable e
- (log/error e "Error calculating Segment description:" (ex-message e))
+ (log/errorf "Error calculating Segment description: %s" (ex-message e))
nil))))
(methodical/defmethod t2.hydrate/batched-hydrate [:model/Segment :definition_description]
diff --git a/src/metabase/server/handler.clj b/src/metabase/server/handler.clj
index 426a5b8623e..1093a9f3422 100644
--- a/src/metabase/server/handler.clj
+++ b/src/metabase/server/handler.clj
@@ -69,7 +69,7 @@
(when (and config/dev-available? (not *compile-files*))
(requiring-resolve 'dev.server.middleware.proxy/wrap-remote-api-proxy))
(catch Exception e
- (log/warn e "Failed to load dev remote API proxy middleware")
+ (log/warnf "Failed to load dev remote API proxy middleware: %s" (ex-message e))
nil)))
(def ^:private middleware
diff --git a/src/metabase/server/instance.clj b/src/metabase/server/instance.clj
index 611fd37d6c0..ec42c40e2ee 100644
--- a/src/metabase/server/instance.clj
+++ b/src/metabase/server/instance.clj
@@ -7,7 +7,6 @@
[metabase.config.core :as config]
[metabase.server.protocols :as server.protocols]
[metabase.server.statistics-handler :as statistics-handler]
- [metabase.util :as u]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
[ring.adapter.jetty :as ring-jetty]
@@ -52,10 +51,10 @@
(merge (jetty-ssl-config)))))
(defn- log-config [jetty-config]
- (log/info "Launching Embedded Jetty Webserver with config:\n"
- (u/pprint-to-str (m/filter-keys
- #(not (str/includes? % "password"))
- jetty-config))))
+ (log/info "Launching Embedded Jetty Webserver with config:"
+ (pr-str (m/filter-keys
+ #(not (str/includes? % "password"))
+ jetty-config))))
(defonce ^:private instance*
(atom nil))
@@ -79,11 +78,11 @@
(.setTimeout timeout))
request-map (servlet/build-request-map request)
raise (fn raise [^Throwable e]
- (log/error e "Unexpected exception in endpoint")
+ (log/errorf "Unexpected exception in endpoint: %s" (ex-message e))
(try
(.sendError response 500 (.getMessage e))
(catch Throwable e
- (log/error e "Unexpected exception writing error response")))
+ (log/errorf "Unexpected exception writing error response: %s" (ex-message e))))
(.complete context))]
(try
(handler
@@ -96,7 +95,7 @@
:response-map response-map}))
raise)
(catch Throwable e
- (log/error e "Unexpected Exception in API request handler")
+ (log/errorf "Unexpected Exception in API request handler: %s" (ex-message e))
(raise e))
(finally
(.setHandled base-request true)))))))
diff --git a/src/metabase/server/middleware/log.clj b/src/metabase/server/middleware/log.clj
index c4d4ee01ffc..0a385e7f508 100644
--- a/src/metabase/server/middleware/log.clj
+++ b/src/metabase/server/middleware/log.clj
@@ -88,11 +88,6 @@
(when include-stats?
(stats diag-info-fn)))
-(defn- format-error-info [{{:keys [body]} :response} {:keys [error?]}]
- (when (and error?
- (or (string? body) (coll? body)))
- (str "\n" (u/pprint-to-str body))))
-
(defn- format-log-context [{:keys [log-context]} _]
(pr-str log-context))
@@ -100,8 +95,7 @@
(str/join " " (filter some? [(format-status-info info)
(format-performance-info info)
(format-threads-info info opts)
- (format-log-context info opts)
- (format-error-info info opts)])))
+ (format-log-context info opts)])))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | Logging the Info |
@@ -149,7 +143,7 @@
log-options)]
(log-fn (u/format-color color (format-info info opts))))
(catch Throwable e
- (log/error e "Error logging API request"))))
+ (log/errorf "Error logging API request: %s" (ex-message e)))))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | Async Logging |
diff --git a/src/metabase/server/middleware/misc.clj b/src/metabase/server/middleware/misc.clj
index d657a8cbae1..e4f1f198e91 100644
--- a/src/metabase/server/middleware/misc.clj
+++ b/src/metabase/server/middleware/misc.clj
@@ -92,7 +92,7 @@
(try
(system/site-url! site-url)
(catch Throwable e
- (log/warn e "Failed to set site-url")))))))
+ (log/warnf "Failed to set site-url: %s" (ex-message e))))))))
(defn maybe-set-site-url
"Middleware to set the `site-url` setting on the initial setup request"
diff --git a/src/metabase/server/middleware/premium_features_cache.clj b/src/metabase/server/middleware/premium_features_cache.clj
index a399748f087..36c5fe77fe2 100644
--- a/src/metabase/server/middleware/premium_features_cache.clj
+++ b/src/metabase/server/middleware/premium_features_cache.clj
@@ -23,7 +23,7 @@
(or (nil? last-known)
(try (pos? (compare cookie-timestamp last-known))
(catch Exception _e
- (log/infof "Strange premium features cookie value: %s" cookie-timestamp)
+ (log/info "Strange premium features cookie value")
false))))
(log/info "Premium features cookie indicates cache is out of date. Clearing...")
(premium-features/clear-cache!)
diff --git a/src/metabase/server/middleware/session.clj b/src/metabase/server/middleware/session.clj
index c553ef09de1..02eb96c2c78 100644
--- a/src/metabase/server/middleware/session.clj
+++ b/src/metabase/server/middleware/session.clj
@@ -382,7 +382,7 @@
:set {:last_active_at :%now}
:where [:= :key_hashed hashed]})
(catch Exception e
- (log/warn e "Failed to update session last_active_at")))))))
+ (log/warnf "Failed to update session last_active_at: %s" (ex-message e))))))))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | reset-cookie-timeout |
diff --git a/src/metabase/server/middleware/settings_cache.clj b/src/metabase/server/middleware/settings_cache.clj
index eab59afeb2f..df74e276c1d 100644
--- a/src/metabase/server/middleware/settings_cache.clj
+++ b/src/metabase/server/middleware/settings_cache.clj
@@ -16,7 +16,7 @@
(when (and last-known-update
(try (pos? (compare cookie-timestamp last-known-update))
(catch Exception _e
- (log/infof "Strange last known update cookie: %s" cookie-timestamp)
+ (log/info "Strange last known update cookie")
false)))
(log/info "Settings cookie indicates cache is out of date. Refreshing...")
(setting/restore-cache!)
diff --git a/src/metabase/server/middleware/trace.clj b/src/metabase/server/middleware/trace.clj
index fd73044b54d..0c26dd57f6b 100644
--- a/src/metabase/server/middleware/trace.clj
+++ b/src/metabase/server/middleware/trace.clj
@@ -89,7 +89,7 @@
(try
(end-span-with-status! span span-ctx (:status response))
(catch Throwable t
- (log/error t "Error ending trace span")))
+ (log/errorf "Error ending trace span: %s" (ex-message t))))
(respond response))
(fn trace-raise [exception]
(try
@@ -97,7 +97,7 @@
(.recordException span exception)
(span/end-span! {:context span-ctx})
(catch Throwable t
- (log/error t "Error ending trace span on exception")))
+ (log/errorf "Error ending trace span on exception: %s" (ex-message t))))
(raise exception)))
(catch Throwable t
;; Handler itself threw synchronously — end span and re-raise
diff --git a/src/metabase/server/routes.clj b/src/metabase/server/routes.clj
index 9972562b51c..6651e03e5bc 100644
--- a/src/metabase/server/routes.clj
+++ b/src/metabase/server/routes.clj
@@ -61,7 +61,7 @@
{:status 200, :body {:status "ok"}}
{:status 503 :body {:status "Unable to get app-db connection"}})
(catch Exception e
- (log/warn e "Error in api/health database check")
+ (log/warnf "Error in api/health database check: %s" (ex-message e))
{:status 503 :body {:status "Error getting app-db connection"}}))
{:status 503, :body {:status "initializing", :progress (init-status/progress)}}))
diff --git a/src/metabase/server/routes/index.clj b/src/metabase/server/routes/index.clj
index 0c811a0b629..5ded6ca51fa 100644
--- a/src/metabase/server/routes/index.clj
+++ b/src/metabase/server/routes/index.clj
@@ -76,7 +76,7 @@
(stencil/render-file path variables)
(catch IllegalArgumentException e
(let [message (trs "Failed to load template ''{0}''. Did you remember to build the Metabase frontend?" path)]
- (log/error e message)
+ (log/error message (ex-message e))
(throw (Exception. message e))))))
(defn- template-parameters
diff --git a/src/metabase/server/streaming_response.clj b/src/metabase/server/streaming_response.clj
index 978730f4ff9..490d07ffec0 100644
--- a/src/metabase/server/streaming_response.clj
+++ b/src/metabase/server/streaming_response.clj
@@ -114,8 +114,9 @@
(defn- log-skipped-error! [obj]
(if (instance? Throwable obj)
- (log/error obj "Async context already completed, cannot write error to client")
- (log/errorf "Async context already completed, cannot write error to client: %s" obj)))
+ (log/errorf "Async context already completed, cannot write error to client: %s" (ex-message obj))
+ (log/errorf "Async context already completed, cannot write error to client: %s"
+ (if (map? obj) (or (:message obj) (:error obj) (:status obj)) obj))))
(defn- sanitize-error-obj [obj export-format]
(-> (if (not= :api export-format)
@@ -146,7 +147,7 @@
;; `.complete` the async context, instead of leaving the request to hang until
;; Jetty's async timeout fires.
(.set ^AtomicBoolean *completed?* false)
- (log/error e "Error aborting streaming connection after mid-stream error")))))
+ (log/errorf "Error aborting streaming connection after mid-stream error: %s" (ex-message e))))))
(defn- write-error-to-stream!
"Serialize `obj` as a JSON error body onto `os` and close the stream. Used when there is no
@@ -155,14 +156,14 @@
used directly)."
[^OutputStream os obj export-format]
(with-open [os os]
- (log/trace (u/pprint-to-str (list 'write-error! obj)))
+ (log/trace "write-error!")
(try
(let [obj (sanitize-error-obj obj export-format)]
(with-open [writer (BufferedWriter. (OutputStreamWriter. os StandardCharsets/UTF_8))]
(json/encode-to obj writer {})))
(catch EofException _)
(catch Throwable e
- (log/error e "Error writing error to output stream" obj)))))
+ (log/errorf "Error writing error to output stream: %s" (ex-message e))))))
(defn write-error!
"Handle an error that occurred while producing a streaming response.
@@ -242,7 +243,7 @@
(try
(do-f* f os finished-chan canceled-chan)
(catch Throwable e
- (log/error e "Caught unexpected Exception in streaming response body")
+ (log/errorf "Caught unexpected Exception in streaming response body: %s" (ex-message e))
(a/>!! finished-chan :unexpected-error)
(write-error! os e nil))
(finally
@@ -341,7 +342,7 @@
(catch ClosedChannelException _ true)
(catch SocketException _ true)
(catch Throwable e
- (log/error e "Error determining whether HTTP request was canceled")
+ (log/errorf "Error determining whether HTTP request was canceled: %s" (ex-message e))
false)))
(def ^:private async-cancellation-poll-timeout-ms
@@ -384,7 +385,7 @@
(when (.compareAndSet completed? false true)
(.complete async-context)))
(onError [_ event]
- (log/warn (.getThrowable ^AsyncEvent event) "Jetty async context error, completing request")
+ (log/warnf "Jetty async context error, completing request: %s" (ex-message (.getThrowable ^AsyncEvent event)))
(when (.compareAndSet completed? false true)
(.complete async-context)))
(onComplete [_ _event])
@@ -415,11 +416,11 @@
(start-async-cancel-loop! request finished-chan canceled-chan)
(do-f-async async-context response request f delay-os finished-chan canceled-chan completed?)))
(catch Throwable e
- (log/error e "Unexpected exception in do-f-async")
+ (log/errorf "Unexpected exception in do-f-async: %s" (ex-message e))
(try
(.sendError response 500 (.getMessage e))
(catch Throwable e
- (log/error e "Unexpected exception writing error response")))
+ (log/errorf "Unexpected exception writing error response: %s" (ex-message e))))
(a/>!! finished-chan :unexpected-error)
(a/close! finished-chan)
(a/close! canceled-chan)
diff --git a/src/metabase/session/api.clj b/src/metabase/session/api.clj
index 46cf4951693..4f3577fd854 100644
--- a/src/metabase/session/api.clj
+++ b/src/metabase/session/api.clj
@@ -526,7 +526,7 @@
(open-api/handler-with-open-api-spec
(fn [request respond raise]
(letfn [(raise' [e]
- (log/error e "Authentication endpoint error")
+ (log/errorf "Authentication endpoint error: %s" (ex-message e))
(raise e))]
(handler request respond raise')))
(fn [prefix]
diff --git a/src/metabase/session/challenge.clj b/src/metabase/session/challenge.clj
index 9b7fa9ce5c1..1fa71155a80 100644
--- a/src/metabase/session/challenge.clj
+++ b/src/metabase/session/challenge.clj
@@ -39,5 +39,5 @@
(when (= (:purpose claims) "mfa-challenge")
claims))
(catch Exception e
- (log/debug e "Invalid MFA challenge token")
+ (log/debugf "Invalid MFA challenge token: %s" (ex-message e))
nil)))
diff --git a/src/metabase/settings/models/setting.clj b/src/metabase/settings/models/setting.clj
index e0a912a2814..2bde790638d 100644
--- a/src/metabase/settings/models/setting.clj
+++ b/src/metabase/settings/models/setting.clj
@@ -726,7 +726,7 @@
(defn- throw-or-log
"Given an error that should never happen, throw it for us, log it for customers."
[e]
- (if config/is-prod? (log/warn e) (throw e)))
+ (if config/is-prod? (log/warn (ex-message e)) (throw e)))
(defn get
"Fetch the value of `setting-definition-or-name`. What this means depends on the Setting's `:getter`; by default, this
@@ -783,9 +783,8 @@
;; and there's actually a row in the DB that's not in the cache for some reason. Go ahead and update the
;; existing value and log a warning
(catch Throwable e
- (log/warn "Error inserting a new Setting:\n"
- (ex-message e) "\n"
- "Assuming Setting already exists in DB and updating existing value.")
+ (log/warnf "Error inserting a new Setting: %s. Assuming Setting already exists in DB and updating existing value."
+ (ex-message e))
(update-setting! setting-name new-value))))
(defn- obfuscated-value? [v]
@@ -1528,7 +1527,7 @@
:value (try
(m/mapply user-facing-value setting options)
(catch Throwable e
- (log/error e "Error fetching value of Setting")))
+ (log/errorf "Error fetching value of Setting: %s" (ex-message e))))
:is_env_setting from-env?
:env_name (env-var-name setting)
:description (str (description))
@@ -1671,7 +1670,7 @@
(cond
(instance? JsonEOFException ex) false
(instance? JsonParseException ex) true
- :else (do (log/warn ex "Unexpected exception while parsing JSON")
+ :else (do (log/warnf "Unexpected exception while parsing JSON: %s" (ex-message ex))
;; err on the side of caution
true)))
@@ -1708,8 +1707,9 @@
(name (:name invalid-setting)))
(dissoc invalid-setting :parse-error)
(:parse-error invalid-setting)))
- (log/warn (:parse-error invalid-setting)
- (format "Unable to parse setting %s" (:name invalid-setting))))))
+ (log/warnf "Unable to parse setting %s: %s"
+ (name (:name invalid-setting))
+ (ex-message (:parse-error invalid-setting))))))
(defn migrate-encrypted-settings!
"We have some settings that may currently be encrypted in the database that we'd like to disable encryption for.
diff --git a/src/metabase/settings/models/setting/cache.clj b/src/metabase/settings/models/setting/cache.clj
index 63c1c3c8699..4ad87941ecc 100644
--- a/src/metabase/settings/models/setting/cache.clj
+++ b/src/metabase/settings/models/setting/cache.clj
@@ -3,7 +3,7 @@
lookup."
(:require
[clojure.core :as core]
- [clojure.java.jdbc :as jdbc]
+ [clojure.string :as str]
[metabase.app-db.core :as mdb]
[metabase.util :as u]
[metabase.util.honey-sql-2 :as h2x]
@@ -85,9 +85,10 @@
;; Use `simple-insert!` because we do *not* want to trigger pre-insert behavior, such as encrypting `:value`
(t2/insert! (t2/table-name (t2/resolve-model :model/Setting)) :key settings-last-updated-key, :value current-timestamp-as-string-honeysql)
(catch java.sql.SQLException e
- ;; go ahead and log the Exception anyway on the off chance that it *wasn't* just a race condition issue
+ ;; go ahead and log the whole SQLException message chain anyway on the off chance that it *wasn't* just a
+ ;; race condition issue
(log/errorf "Error updating Settings last updated value: %s"
- (with-out-str (jdbc/print-sql-exception-chain e)))))))
+ (str/join "; " (keep ex-message (take-while some? (iterate #(.getNextException ^java.sql.SQLException %) e)))))))))
;; Now that we updated the value in the DB, go ahead and update our cached value as well, because we know about the
;; changes
(swap! (cache*) assoc settings-last-updated-key (t2/select-one-fn :value :model/Setting :key settings-last-updated-key)))
diff --git a/src/metabase/slackbot/api.clj b/src/metabase/slackbot/api.clj
index e318014eb2a..30208b8ba05 100644
--- a/src/metabase/slackbot/api.clj
+++ b/src/metabase/slackbot/api.clj
@@ -73,7 +73,7 @@
(when ok
permalink))
(catch Exception e
- (log/warn e "Unable to fetch Slack permalink for metabot conversation")
+ (log/warnf "Unable to fetch Slack permalink for metabot conversation: %s" (ex-message e))
nil))))
;; ------------------------- VALIDATION ----------------------------------
@@ -242,7 +242,7 @@
(finally
(analytics/observe! :metabase-slackbot/response-duration-ms {:source source} (u/since-ms timer)))))))
(catch Exception e
- (log/errorf e "[slackbot] Error processing %s: %s" event-type (ex-message e))))))))
+ (log/errorf "[slackbot] Error processing %s: %s" event-type (ex-message e))))))))
(defn- ignore-event
"Handle any event we don't care to process"
@@ -371,7 +371,7 @@
:source "reaction"
:reaction reaction))))
(catch Exception e
- (log/error e "[slackbot] Error handling delete reaction"))))
+ (log/errorf "[slackbot] Error handling delete reaction: %s" (ex-message e)))))
(defn- assert-setup-complete
"Asserts that all required Slack settings have been configured."
@@ -561,7 +561,7 @@
:message_ts message-ts
:message_external_id message_external_id})})
(catch Exception e
- (log/errorf e "[slackbot] Error opening feedback modal: %s" (ex-data e)))))))
+ (log/errorf "[slackbot] Error opening feedback modal: %s" (ex-message e)))))))
(defn- handle-delete-action
"Handle replacing a metabot response message with a removed notice.
@@ -576,7 +576,7 @@
(try
(replace-response-with-removed-notice! client channel-id message-ts (:request-user-id authorization))
(catch Exception e
- (log/errorf e "[slackbot] Error replacing metabot response with removed notice: %s" (ex-data e)))))))
+ (log/errorf "[slackbot] Error replacing metabot response with removed notice: %s" (ex-message e)))))))
(log-ignored-delete-request (assoc authorization :source "action")))))
@@ -618,8 +618,8 @@
:issue_type issue-type
:freeform_feedback freeform}))
(catch Exception e
- (log/warnf e "[slackbot] Feedback submission failed (external_id=%s user_id=%s)"
- external-id user_id))))))))
+ (log/warnf "[slackbot] Feedback submission failed (external_id=%s user_id=%s): %s"
+ external-id user_id (ex-message e)))))))))
#_{:clj-kondo/ignore [:metabase/validate-defendpoint-has-response-schema]}
(api.macros/defendpoint :post "/interactive"
diff --git a/src/metabase/slackbot/channel.clj b/src/metabase/slackbot/channel.clj
index bbafed6307f..38044ec9047 100644
--- a/src/metabase/slackbot/channel.clj
+++ b/src/metabase/slackbot/channel.clj
@@ -42,7 +42,7 @@
:thread-ts thread-ts
:loading-messages [(or status "")]})
(catch Exception e
- (log/warnf e "[slackbot] set-status failed (channel=%s thread-ts=%s)" channel thread-ts))))]
+ (log/warnf "[slackbot] set-status failed (channel=%s thread-ts=%s): %s" channel thread-ts (ex-message e)))))]
{:on-text (bound-fn* (fn [text]
(when (seq text)
(swap! current-text str text))))
@@ -106,7 +106,7 @@
(post-viz-error! client channel thread-ts e))))
(catch Exception e
(cancel-prefetched-viz! prefetched-viz)
- (log/error e "[slackbot] Error in channel response")
+ (log/errorf "[slackbot] Error in channel response: %s" (ex-message e))
(set-status! nil)
(let [res (slackbot.client/post-thread-reply client message-ctx
"Something went wrong. Please try again.")]
diff --git a/src/metabase/slackbot/client.clj b/src/metabase/slackbot/client.clj
index af9b0aff501..a6fb8b6b7a2 100644
--- a/src/metabase/slackbot/client.clj
+++ b/src/metabase/slackbot/client.clj
@@ -221,11 +221,8 @@
{:stream_ts (:ts body)
:channel (:channel body)
:thread_ts thread_ts}
- (do
- (log/warnf "[slackbot] start-stream failed: %s (channel=%s thread_ts=%s recipient_team_id=%s recipient_user_id=%s)"
- (:error body) channel thread_ts team_id user_id)
- (log/debugf "[slackbot] start-stream failure body=%s payload=%s"
- (pr-str body) (pr-str payload))))))
+ (log/warnf "[slackbot] start-stream failed: %s (channel=%s thread_ts=%s recipient_team_id=%s recipient_user_id=%s)"
+ (:error body) channel thread_ts team_id user_id))))
(defn append-stream
"Append chunks to an active stream. Each chunk is a map with :type and type-specific keys,
@@ -261,7 +258,5 @@
:socket-timeout streaming-socket-timeout-ms))]
(when-not (:ok body)
(log/warnf "[slackbot] stop-stream failed: %s (channel=%s stream_ts=%s block_count=%d block_types=%s)"
- (:error body) channel stream-ts (count (or blocks [])) (pr-str block-types))
- (log/debugf "[slackbot] stop-stream failure body=%s payload=%s"
- (pr-str body) (pr-str (update payload :blocks #(when % "[redacted-blocks]")))))
+ (:error body) channel stream-ts (count (or blocks [])) (pr-str block-types)))
body)))
diff --git a/src/metabase/slackbot/streaming.clj b/src/metabase/slackbot/streaming.clj
index e5c30d9716e..05fdec3587b 100644
--- a/src/metabase/slackbot/streaming.clj
+++ b/src/metabase/slackbot/streaming.clj
@@ -314,7 +314,7 @@
:thread_ts thread-ts
:text (viz-error-message e)})
(catch Exception post-e
- (log/error post-e "Failed to post visualization error"))))
+ (log/errorf "Failed to post visualization error: %s" (ex-message post-e)))))
(defn- collect-viz-blocks
"Wait for all in-flight visualization futures and return blocks to include in stop-stream.
@@ -330,10 +330,10 @@
(assoc acc :blocks (into blocks (viz-output->blocks output filename resolved-title link))))
(catch ExecutionException e
(let [cause (or (.getCause e) e)]
- (log/errorf cause "Visualization future %d failed" idx)
+ (log/errorf "Visualization future %d failed: %s" idx (ex-message cause))
{:blocks blocks :errors (conj errors cause)}))
(catch Exception e
- (log/errorf e "Visualization future %d failed" idx)
+ (log/errorf "Visualization future %d failed: %s" idx (ex-message e))
{:blocks blocks :errors (conj errors e)})))
{:blocks [] :errors []}
(sort-by first prefetched-viz)))
@@ -430,7 +430,7 @@
thinking-ts (atom nil)
slack-writer (agent nil
:error-mode :continue
- :error-handler (fn [_ e] (log/warn e "[slackbot] Async Slack write failed")))
+ :error-handler (fn [_ e] (log/warnf "[slackbot] Async Slack write failed: %s" (ex-message e))))
stream-opts {:channel channel
:thread_ts thread-ts
:team_id team-id
@@ -610,7 +610,7 @@
(slackbot.client/post-thread-reply client message-ctx "I wasn't able to generate a response. Please try again.")))
(catch Exception e
(cancel-prefetched-viz! prefetched-viz)
- (log/error e "[slackbot] Error in streaming response")
+ (log/errorf "[slackbot] Error in streaming response: %s" (ex-message e))
(when-not (await-for slack-writer-await-timeout-ms slack-writer)
(log/warn "[slackbot] Timed out waiting for slack-writer agent to flush"))
(if-let [{:keys [stream_ts channel]} @stream-state]
@@ -626,7 +626,7 @@
(when-not (:ok fallback-result)
(log/errorf "[slackbot] cleanup fallback post-message failed: %s" (:error fallback-result))))))
(catch Exception stop-e
- (log/debug stop-e "[slackbot] Failed to stop stream during error cleanup")))
+ (log/debugf "[slackbot] Failed to stop stream during error cleanup: %s" (ex-message stop-e))))
(slackbot.client/post-thread-reply client message-ctx "Something went wrong. Please try again."))))))
(defn send-response
diff --git a/src/metabase/slackbot/uploads.clj b/src/metabase/slackbot/uploads.clj
index 1ca51d03082..3a675bb77e8 100644
--- a/src/metabase/slackbot/uploads.clj
+++ b/src/metabase/slackbot/uploads.clj
@@ -45,7 +45,7 @@
[{:keys [db_id schema_name table_prefix]} {:keys [name url_private] :as file}]
(if-let [size-error (validate-file-size file)]
(do
- (log/warnf "[slackbot] File exceeds size limit: file=%s error=%s" name size-error)
+ (log/warnf "[slackbot] File exceeds size limit: error=%s" size-error)
{:error size-error :filename name})
(let [temp-file (java.io.File/createTempFile "slack-upload-" (str "-" name))]
(try
@@ -58,13 +58,13 @@
:schema-name schema_name
:table-prefix table_prefix
:collection-id nil})]
- (log/infof "[slackbot] File uploaded: file=%s model_id=%d" name (:id result))
+ (log/infof "[slackbot] File uploaded: model_id=%d" (:id result))
(analytics/inc! :metabase-slackbot/file-uploads {:result "success"})
{:filename name
:model-id (:id result)
:model-name (:name result)}))
(catch Exception e
- (log/warnf "[slackbot] File upload failed: file=%s error=%s" name (ex-message e))
+ (log/warnf "[slackbot] File upload failed: error=%s" (ex-message e))
(analytics/inc! :metabase-slackbot/file-uploads {:result "error"})
{:error (ex-message e) :filename name})
(finally
@@ -78,7 +78,7 @@
(let [{csv-files true other-files false} (group-by csv-file? files)
skipped (mapv :name other-files)]
(when (seq skipped)
- (log/debugf "[slackbot] Skipping non-CSV files: %s" (pr-str skipped)))
+ (log/debugf "[slackbot] Skipping %d non-CSV files" (count skipped)))
{:results (mapv (partial process-csv-file settings) csv-files)
:skipped skipped}))
diff --git a/src/metabase/sql_parsing/core.clj b/src/metabase/sql_parsing/core.clj
index 896d7cef50b..99414315ae1 100644
--- a/src/metabase/sql_parsing/core.clj
+++ b/src/metabase/sql_parsing/core.clj
@@ -173,7 +173,7 @@
(try
(strip-large-values* sql)
(catch Exception e
- (log/warn e "Error stripping VALUES clauses, passing SQL through unchanged")
+ (log/warnf "Error stripping VALUES clauses, passing SQL through unchanged: %s" (ex-message e))
sql)))
;;; -------------------------------------------------- Public API --------------------------------------------------
diff --git a/src/metabase/sql_tools/macaw/core.clj b/src/metabase/sql_tools/macaw/core.clj
index bf98509cbea..e586270acd5 100644
--- a/src/metabase/sql_tools/macaw/core.clj
+++ b/src/metabase/sql_tools/macaw/core.clj
@@ -174,7 +174,7 @@
:else
{:is_simple true}))
(catch Exception e
- (log/debugf e "Failed to parse query: %s" (ex-message e))
+ (log/debugf "Failed to parse query: %s" (ex-message e))
{:is_simple false})))
(defmethod sql-tools/add-into-clause-impl :macaw
diff --git a/src/metabase/sql_tools/sqlglot/core.clj b/src/metabase/sql_tools/sqlglot/core.clj
index 9ecc383ab2d..945507111a3 100644
--- a/src/metabase/sql_tools/sqlglot/core.clj
+++ b/src/metabase/sql_tools/sqlglot/core.clj
@@ -161,7 +161,7 @@
;; No dialect available from caller, use nil for SQLGlot's default dialect
(sql-parsing/simple-query? nil sql-string)
(catch Exception e
- (log/debugf e "Failed to parse query: %s" (ex-message e))
+ (log/debugf "Failed to parse query: %s" (ex-message e))
{:is_simple false})))
(defmethod sql-tools/add-into-clause-impl :sqlglot
diff --git a/src/metabase/sso/api/slack_connect.clj b/src/metabase/sso/api/slack_connect.clj
index 1357becb93d..00153d5bb1a 100644
--- a/src/metabase/sso/api/slack_connect.clj
+++ b/src/metabase/sso/api/slack_connect.clj
@@ -14,7 +14,7 @@
(try
(slack-connect-integration/sso-initiate request)
(catch Throwable e
- (log/error e "Error initiating Slack Connect SSO")
+ (log/errorf "Error initiating Slack Connect SSO: %s" (ex-message e))
(throw e))))
;; GET /auth/sso/slack-connect/callback
@@ -26,7 +26,7 @@
(try
(slack-connect-integration/sso-callback request)
(catch Throwable e
- (log/error e "Error handling Slack Connect callback")
+ (log/errorf "Error handling Slack Connect callback: %s" (ex-message e))
(throw e))))
(def ^{:arglists '([request respond raise])} routes
diff --git a/src/metabase/sso/common.clj b/src/metabase/sso/common.clj
index d549248f30b..ae2e7dbea66 100644
--- a/src/metabase/sso/common.clj
+++ b/src/metabase/sso/common.clj
@@ -41,7 +41,7 @@
;; that stays on the log-and-continue path like any other bogus group id.
(if (some (comp some? :group-is-tenant?) (:bad-user-group-pairs (ex-data e)))
(throw e)
- (log/errorf e "Error adding user %s to group %s" (u/the-id user-or-id) (u/the-id group-or-id)))))))
+ (log/errorf "Error adding user %s to group %s: %s" (u/the-id user-or-id) (u/the-id group-or-id) (ex-message e)))))))
(defn sync-group-memberships!
"Update the PermissionsGroups a User belongs to, adding or deleting membership entries as needed so that Users is
diff --git a/src/metabase/sso/integrations/slack_connect.clj b/src/metabase/sso/integrations/slack_connect.clj
index 16af053faac..fbb52ab1bfc 100644
--- a/src/metabase/sso/integrations/slack_connect.clj
+++ b/src/metabase/sso/integrations/slack_connect.clj
@@ -87,8 +87,7 @@
(let [final-redirect (or (:redirect-url login-result) "/")
base-response (-> (response/redirect final-redirect)
(sso/clear-oidc-state-cookie))]
- (log/infof "Slack authentication successful for user %s"
- (get-in login-result [:user-data :email]))
+ (log/info "Slack authentication successful")
(if-let [session (:session login-result)]
(request/set-session-cookies request
base-response
diff --git a/src/metabase/sso/ldap.clj b/src/metabase/sso/ldap.clj
index 51bd6cc67f8..2f0cfb6b511 100644
--- a/src/metabase/sso/ldap.clj
+++ b/src/metabase/sso/ldap.clj
@@ -5,7 +5,6 @@
[metabase.settings.core :as setting]
[metabase.sso.ldap.default-implementation :as default-impl]
[metabase.sso.settings :as sso.settings]
- [metabase.util :as u]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
[metabase.util.malli.schema :as ms])
@@ -55,7 +54,7 @@
^LDAPConnectionPool
[]
(let [options (settings->ldap-options)]
- (log/debugf "Opening LDAP connection with options %s" (u/pprint-to-str options))
+ (log/debug "Opening LDAP connection")
(try
(ldap/connect options)
(catch LDAPException e
diff --git a/src/metabase/sso/ldap/default_implementation.clj b/src/metabase/sso/ldap/default_implementation.clj
index adc947f3862..955a9dac047 100644
--- a/src/metabase/sso/ldap/default_implementation.clj
+++ b/src/metabase/sso/ldap/default_implementation.clj
@@ -51,17 +51,12 @@
(let [options {:scope :sub
:filter (str/replace user-filter filter-placeholder (Filter/encodeValue ^String username))
:size-limit 1}]
- (log/debugf "Searching for LDAP user %s with user search base %s and options %s"
- username
- user-base
- (u/pprint-to-str options))
+ (log/debugf "Searching for LDAP user with user search base %s" user-base)
(let [search-result (ldap/search
ldap-connection
user-base
- {:scope :sub
- :filter (str/replace user-filter filter-placeholder (Filter/encodeValue ^String username))
- :size-limit 1})]
- (log/debugf "LDAP search results: %s" (u/pprint-to-str search-result))
+ options)]
+ (log/debugf "LDAP search returned %d result(s)" (count search-result))
(some-> (first search-result) u/lower-case-map-keys))))
(mu/defn- process-group-membership-filter :- ms/NonBlankString
diff --git a/src/metabase/sso/oidc/check.clj b/src/metabase/sso/oidc/check.clj
index 5a62cf099ea..e0205af719c 100644
--- a/src/metabase/sso/oidc/check.clj
+++ b/src/metabase/sso/oidc/check.clj
@@ -74,7 +74,7 @@
:error (str "Unexpected response from token endpoint (HTTP " status "): "
(or (:error_description body) error-code body))}))
(catch Exception e
- (log/warnf e "OIDC credential check failed for %s" token-endpoint)
+ (log/warnf "OIDC credential check failed for %s: %s" token-endpoint (ex-message e))
{:step :credentials
:success false
:verified false
diff --git a/src/metabase/sso/oidc/discovery.clj b/src/metabase/sso/oidc/discovery.clj
index 9e14313f0cc..43400f5b3d2 100644
--- a/src/metabase/sso/oidc/discovery.clj
+++ b/src/metabase/sso/oidc/discovery.clj
@@ -51,10 +51,10 @@
(if (= 200 (:status response))
(:body response)
(do
- (log/warnf "OIDC discovery failed with status %s: %s" (:status response) (:body response))
+ (log/warnf "OIDC discovery failed with status %s" (:status response))
nil)))
(catch Exception e
- (log/warnf e "Failed to fetch OIDC discovery document from %s" url)
+ (log/warnf "Failed to fetch OIDC discovery document from %s: %s" url (ex-message e))
nil))))
(defn clear-cache!
diff --git a/src/metabase/sso/oidc/state.clj b/src/metabase/sso/oidc/state.clj
index 848d2f2e6c8..1f91f3ca680 100644
--- a/src/metabase/sso/oidc/state.clj
+++ b/src/metabase/sso/oidc/state.clj
@@ -106,7 +106,7 @@
This prevents open redirect attacks by ensuring redirects stay within the application."
[redirect-url]
(when-not (valid-redirect-url? redirect-url)
- (log/warnf "OIDC redirect URL validation failed: %s" redirect-url)
+ (log/warn "OIDC redirect URL validation failed")
(throw (ex-info (tru "Invalid redirect URL. Redirect must be a relative path or same-origin URL.")
{:status-code 400
:redirect-url redirect-url}))))
@@ -206,14 +206,14 @@
;; Browser-id mismatch (if validation requested)
(and validate-browser-id
(not= validate-browser-id (:browser-id state-map)))
- (do (log/warnf "OIDC state browser-id mismatch: expected %s" validate-browser-id)
+ (do (log/warn "OIDC state browser-id mismatch")
nil)
;; Valid
:else
state-map))
(catch Exception e
- (log/warn e "Failed to decrypt OIDC state")
+ (log/warnf "Failed to decrypt OIDC state: %s" (ex-message e))
nil)))))
;;; -------------------------------------------------- Cookie Management --------------------------------------------------
diff --git a/src/metabase/sso/oidc/tokens.clj b/src/metabase/sso/oidc/tokens.clj
index 5dd137229f9..db592e22b85 100644
--- a/src/metabase/sso/oidc/tokens.clj
+++ b/src/metabase/sso/oidc/tokens.clj
@@ -47,7 +47,7 @@
(-> (oidc.http/oidc-get jwks-uri {:accept :json})
:body)
(catch Exception e
- (log/warnf e "Failed to fetch JWKS from %s" jwks-uri)
+ (log/warnf "Failed to fetch JWKS from %s: %s" jwks-uri (ex-message e))
nil)))
(defn get-jwks
@@ -116,7 +116,7 @@
public-key (keys/jwk->public-key key-data)]
(jwt/unsign token public-key {:alg alg})))))
(catch Exception e
- (log/warn e "JWT signature verification failed")
+ (log/warnf "JWT signature verification failed: %s" (ex-message e))
nil)))
(defn- validate-expiry
diff --git a/src/metabase/sso/providers/google.clj b/src/metabase/sso/providers/google.clj
index f50c01175f8..9781a5e2279 100644
--- a/src/metabase/sso/providers/google.clj
+++ b/src/metabase/sso/providers/google.clj
@@ -29,7 +29,7 @@
(let [token-info-response (http/post (format google-auth-token-info-url token))
{first-name :given_name last-name :family_name :keys [email]}
(sso.google/google-auth-token-info token-info-response)]
- (log/infof "Successfully authenticated Google Sign-In token for: %s %s" first-name last-name)
+ (log/info "Successfully authenticated Google Sign-In token")
;; Always return user data - let login! handle account creation policy
{:success? true
:user-data {:email email
@@ -38,12 +38,12 @@
:sso_source :google}
:provider-id email})
(catch clojure.lang.ExceptionInfo e
- (log/errorf e "Google authentication failed: %s" (.getMessage e))
+ (log/errorf "Google authentication failed: %s" (.getMessage e))
{:success? false
:error :authentication-failed
:message (.getMessage e)})
(catch Exception e
- (log/errorf e "Unexpected error during Google authentication: %s" (.getMessage e))
+ (log/errorf "Unexpected error during Google authentication: %s" (.getMessage e))
{:success? false
:error :server-error
:message "An unexpected error occurred during authentication"}))))
diff --git a/src/metabase/sso/providers/ldap.clj b/src/metabase/sso/providers/ldap.clj
index c43a29140ac..b4355949f71 100644
--- a/src/metabase/sso/providers/ldap.clj
+++ b/src/metabase/sso/providers/ldap.clj
@@ -41,7 +41,7 @@
:error :invalid-credentials
:message \"...\"}"
[_provider {:keys [username password] :as _request}]
- (log/debugf "Authenticating with LDAP provider for username: %s" username)
+ (log/debug "Authenticating with LDAP provider")
(cond
(not username)
@@ -78,12 +78,12 @@
:error :ldap-error
:message "No user found with that username in LDAP."})
(catch clojure.lang.ExceptionInfo e
- (log/error e "LDAP authentication error")
+ (log/errorf "LDAP authentication error: %s" (ex-message e))
{:success? false
:error :ldap-error
:message (or (ex-message e) "LDAP authentication failed")})
(catch Exception e
- (log/error e "Unexpected error during LDAP authentication")
+ (log/errorf "Unexpected error during LDAP authentication: %s" (ex-message e))
{:success? false
:error :server-error
:message "An unexpected error occurred during authentication"}))))
@@ -132,4 +132,4 @@
all-mapped-ids (ldap.impl/all-mapped-group-ids settings)]
(sso/sync-group-memberships! (:user result) group-ids all-mapped-ids))
(catch Exception e
- (log/error e "Error syncing LDAP group memberships"))))))))
+ (log/errorf "Error syncing LDAP group memberships: %s" (ex-message e)))))))))
diff --git a/src/metabase/sso/providers/oidc.clj b/src/metabase/sso/providers/oidc.clj
index 7b31e22cedb..5d1c512a9fc 100644
--- a/src/metabase/sso/providers/oidc.clj
+++ b/src/metabase/sso/providers/oidc.clj
@@ -60,10 +60,10 @@
(if (= 200 (:status response))
(oidc.common/parse-token-response (:body response))
(do
- (log/errorf "Token exchange failed: %s" (:body response))
+ (log/errorf "Token exchange failed with status %s" (:status response))
nil)))
(catch Exception e
- (log/error e "Token exchange failed")
+ (log/errorf "Token exchange failed: %s" (ex-message e))
nil))))
;;; -------------------------------------------------- User Data Extraction --------------------------------------------------
diff --git a/src/metabase/startup/core.clj b/src/metabase/startup/core.clj
index 2ed9a9a1d05..a7802e7e2fe 100644
--- a/src/metabase/startup/core.clj
+++ b/src/metabase/startup/core.clj
@@ -53,7 +53,7 @@
(try
(f k)
(catch Throwable e
- (log/errorf e "Error initializing startup logic %s" k)))))
+ (log/errorf "Error initializing startup logic %s: %s" k (ex-message e))))))
(defn- run-startup-logic!*
"Run `validation-impls` (each aborts the boot on a throw), then `setup-impls` (throws logged and skipped).
@@ -90,4 +90,4 @@
(log/infof "Running shutdown logic %s" (name k))
(f k)
(catch Throwable e
- (log/errorf e "Error running shutdown logic %s" k)))))
+ (log/errorf "Error running shutdown logic %s: %s" k (ex-message e))))))
diff --git a/src/metabase/sync/events/sync_database.clj b/src/metabase/sync/events/sync_database.clj
index dc1a0e984cb..a1e6a437838 100644
--- a/src/metabase/sync/events/sync_database.clj
+++ b/src/metabase/sync/events/sync_database.clj
@@ -27,6 +27,6 @@
(sync/sync-database! database)
(sync-metadata/sync-db-metadata! database))
(catch Throwable e
- (log/errorf e "Error syncing Database %s" (u/the-id database)))))))
+ (log/errorf "Error syncing Database %s: %s" (u/the-id database) (ex-message e)))))))
(catch Throwable e
- (log/warnf e "Failed to process sync-database event: %s" topic))))
+ (log/warnf "Failed to process sync-database event: %s: %s" topic (ex-message e)))))
diff --git a/src/metabase/sync/fetch_metadata.clj b/src/metabase/sync/fetch_metadata.clj
index b2dec8f3e8b..c6ad7214805 100644
--- a/src/metabase/sync/fetch_metadata.clj
+++ b/src/metabase/sync/fetch_metadata.clj
@@ -21,7 +21,7 @@
`(try
~@body
(catch Throwable e#
- (log/errorf e# "Error while fetching metadata with '%s'" ~function-name)
+ (log/errorf "Error while fetching metadata with '%s': %s" ~function-name (ex-message e#))
(throw e#))))
(mu/defn db-metadata :- i/DatabaseMetadata
@@ -70,7 +70,7 @@
(mapv #(assoc % :table-schema (:schema table) :table-name (:name table))
table-fields))
(catch Throwable e
- (log/warn e (str "Could not fetch fields from table " table-id))
+ (log/warn (str "Could not fetch fields from table " table-id ": " (ex-message e)))
nil))))
table-ids)))
diff --git a/src/metabase/sync/sync_metadata/fields.clj b/src/metabase/sync/sync_metadata/fields.clj
index d351136f61b..247afdb3445 100644
--- a/src/metabase/sync/sync_metadata/fields.clj
+++ b/src/metabase/sync/sync_metadata/fields.clj
@@ -145,7 +145,7 @@
table)]
(sync-and-update! database table all-metadata))
(catch Exception e
- (log/error e)
+ (log/error (ex-message e))
0))
0)]
{:total-fields (count table-metadata)
diff --git a/src/metabase/sync/sync_metadata/fks.clj b/src/metabase/sync/sync_metadata/fks.clj
index 6360d638f66..4df3a4d8c78 100644
--- a/src/metabase/sync/sync_metadata/fks.clj
+++ b/src/metabase/sync/sync_metadata/fks.clj
@@ -131,7 +131,7 @@
(transduce (map (fn [x]
(let [[updated failed] (try [(mark-fk! database x) 0]
(catch Exception e
- (log/error e)
+ (log/error (ex-message e))
[0 1]))]
{:total-fks 1
:updated-fks updated
diff --git a/src/metabase/sync/sync_metadata/tables.clj b/src/metabase/sync/sync_metadata/tables.clj
index 2156ee97094..12c78e4b1ba 100644
--- a/src/metabase/sync/sync_metadata/tables.clj
+++ b/src/metabase/sync/sync_metadata/tables.clj
@@ -407,7 +407,7 @@
[0 t]))]
(when (zero? did-update)
(if err
- (log/errorf err "Failed archiving table %s" (sync-util/name-for-logging table))
+ (log/errorf "Failed archiving table %s: %s" (sync-util/name-for-logging table) (ex-message err))
(log/warnf "Did not archive table %s" (sync-util/name-for-logging table))))
(swap! archived + did-update)))))
@archived))
diff --git a/src/metabase/sync/task/sync_databases.clj b/src/metabase/sync/task/sync_databases.clj
index dc4d5c48d64..e20ca6080d0 100644
--- a/src/metabase/sync/task/sync_databases.clj
+++ b/src/metabase/sync/task/sync_databases.clj
@@ -89,7 +89,7 @@
nil
(catch Throwable e
e))]
- (log/warnf ex "Cannot sync Database %s: %s" (:name database) (ex-message ex))
+ (log/warnf "Cannot sync Database %d: %s" database-id (ex-message ex))
(database-routing/with-database-routing-off
(let [db-id (:id database)
metadata-results (tracing/with-span :sync "sync.metadata" {:db/id db-id}
@@ -298,9 +298,9 @@
;; delete the existing trigger
(nil? new-trigger)
(do
- (log/infof "Trigger for \"%s\" of Database \"%s\" has been removed. It will no longer run on a schedule."
+ (log/infof "Trigger for \"%s\" of Database %d has been removed. It will no longer run on a schedule."
(:name task-info)
- (:name database))
+ (u/the-id database))
(delete-trigger! database task-info))
;; need to recreate the new trigger
@@ -308,13 +308,13 @@
(nil? existing-trigger-with-same-schedule))
(do
(if (delete-trigger! database task-info)
- (log/infof "Trigger for \"%s\" of Database \"%s\" has been updated. The new schedule is: \"%s\""
+ (log/infof "Trigger for \"%s\" of Database %d has been updated. The new schedule is: \"%s\""
(:name task-info)
- (:name database)
+ (u/the-id database)
(cron-schedule database task-info))
- (log/infof "A trigger for \"%s\" of Database \"%s\" has been enabled with schedule: \"%s\""
+ (log/infof "A trigger for \"%s\" of Database %d has been enabled with schedule: \"%s\""
(:name task-info)
- (:name database)
+ (u/the-id database)
(cron-schedule database task-info)))
(task/add-trigger! new-trigger))
@@ -375,7 +375,7 @@
(sync.schedules/default-randomized-schedule))))
(inc counter)
(catch Exception e
- (log/warnf e "Error updating database %d for randomized schedules" (u/the-id db))
+ (log/warnf "Error updating database %d for randomized schedules: %s" (u/the-id db) (ex-message e))
counter))))
(t2/reducible-query
{:select [:*]
diff --git a/src/metabase/sync/util.clj b/src/metabase/sync/util.clj
index bab1342056c..e8fc0853765 100644
--- a/src/metabase/sync/util.clj
+++ b/src/metabase/sync/util.clj
@@ -241,7 +241,7 @@
(catch Throwable e
(if (and *log-exceptions-and-continue?* (not (transient-exception? e)))
(do
- (log/warn e message)
+ (log/warn message (ex-message e))
e)
(throw e))))))
@@ -262,7 +262,7 @@
(catch Throwable e
(if *log-exceptions-and-continue?*
(do
- (log/warn e message)
+ (log/warn message (ex-message e))
{:throwable e})
(throw e)))))
diff --git a/src/metabase/system/settings.clj b/src/metabase/system/settings.clj
index 8e848c4de39..a8d370b3311 100644
--- a/src/metabase/system/settings.clj
+++ b/src/metabase/system/settings.clj
@@ -55,7 +55,7 @@
(try
(some-> (setting/get-value-of-type :string :site-url) normalize-site-url)
(catch clojure.lang.ExceptionInfo e
- (log/error e "site-url is invalid; returning nil for now. Will be reset on next request."))))
+ (log/errorf "site-url is invalid; returning nil for now. Will be reset on next request: %s" (ex-message e)))))
:setter (fn [new-value]
(let [new-value (some-> new-value normalize-site-url)
https? (some-> new-value (str/starts-with? "https:"))]
diff --git a/src/metabase/task/bootstrap.clj b/src/metabase/task/bootstrap.clj
index b0a4cdef6da..8a9f1e972a7 100644
--- a/src/metabase/task/bootstrap.clj
+++ b/src/metabase/task/bootstrap.clj
@@ -85,4 +85,4 @@
(try
(setter db-type)
(catch Throwable t
- (log/warn t "A registered Quartz JDBC property setter failed; continuing")))))
+ (log/warnf "A registered Quartz JDBC property setter failed; continuing: %s" (ex-message t))))))
diff --git a/src/metabase/task/impl.clj b/src/metabase/task/impl.clj
index d48b3340451..65a58c78fb7 100644
--- a/src/metabase/task/impl.clj
+++ b/src/metabase/task/impl.clj
@@ -79,7 +79,7 @@
(log/info "Initializing task" (u/format-color 'green (name k)) (u/emoji "📆"))
(f k)
(catch Throwable e
- (log/errorf e "Error initializing task %s" k)))))
+ (log/errorf "Error initializing task %s: %s" k (ex-message e))))))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | STARTING/STOPPING SCHEDULER |
@@ -186,7 +186,7 @@
(str " (chosen randomly from " (count triggers) " existing ones)"))))
(.rescheduleJob scheduler replaced-key new-trigger))))
(catch Throwable e
- (log/error e "Error rescheduling job"))))
+ (log/errorf "Error rescheduling job: %s" (ex-message e)))))
(mu/defn reschedule-trigger!
"Reschedule a trigger with the same key as the given trigger.
@@ -218,7 +218,7 @@
(when-let [scheduler (scheduler)]
(.triggerJob scheduler job-key))
(catch Throwable e
- (log/errorf e "Failed to trigger immediate execution of task %s" job-key))))
+ (log/errorf "Failed to trigger immediate execution of task %s: %s" job-key (ex-message e)))))
(mu/defn delete-task!
"Delete a task from the scheduler"
@@ -326,7 +326,7 @@
(catch ClassNotFoundException _
(log/infof "Class not found for Quartz Job %s. This probably means that this job was removed or renamed." (.getName job-key)))
(catch Throwable e
- (log/warnf e "Error fetching details for Quartz Job: %s" (.getName job-key)))))))
+ (log/warnf "Error fetching details for Quartz Job %s: %s" (.getName job-key) (ex-message e)))))))
(defn- jobs-info []
(->> (some-> (scheduler) (.getJobKeys nil))
@@ -354,7 +354,7 @@
(try
~@body
(catch Exception e#
- (log/error e# msg#)
+ (log/error msg# (ex-message e#))
(throw (JobExecutionException. msg# e# true))))))
#_{:clj-kondo/ignore [:discouraged-var]}
diff --git a/src/metabase/task/job_factory.clj b/src/metabase/task/job_factory.clj
index a5ebb0767e6..6559a795dd0 100644
--- a/src/metabase/task/job_factory.clj
+++ b/src/metabase/task/job_factory.clj
@@ -19,7 +19,7 @@
(defn- no-op-job
"Logs the exception and returns a no-op job."
^Job [e]
- (log/error e "Failed to load a job class. Usually this means an old version of metabase tried to run a job from a newer version")
+ (log/errorf "Failed to load a job class. Usually this means an old version of metabase tried to run a job from a newer version: %s" (ex-message e))
(->NoOpJob))
(defn create
diff --git a/src/metabase/tracing/core.clj b/src/metabase/tracing/core.clj
index e02911bb3d9..87a861746d3 100644
--- a/src/metabase/tracing/core.clj
+++ b/src/metabase/tracing/core.clj
@@ -177,7 +177,7 @@
(catch ClassNotFoundException _
nil)
(catch Exception e
- (log/debug e "Could not resolve PyroscopeAsyncProfiler")
+ (log/debugf "Could not resolve PyroscopeAsyncProfiler: %s" (ex-message e))
nil))))
;; AsyncProfiler.setTracingContext(long spanId, long spanNameId)
@@ -231,7 +231,7 @@
(Long/valueOf span-name-id)]))
(.setAttribute span "pyroscope.profile.id" span-id-hex))
(catch Exception e
- (log/debug e "Error setting Pyroscope profiling context")))))
+ (log/debugf "Error setting Pyroscope profiling context: %s" (ex-message e))))))
(defn clear-pyroscope-context!
"Clear profiling context for current thread. No-op if Pyroscope is not available."
@@ -375,7 +375,7 @@
(init-enabled-groups! groups-str log-level-str)
(log/info "OpenTelemetry tracing initialized successfully")))
(catch Exception e
- (log/error e "Failed to initialize OpenTelemetry tracing — tracing will be disabled")))))
+ (log/errorf "Failed to initialize OpenTelemetry tracing — tracing will be disabled: %s" (ex-message e))))))
(defn shutdown!
"Shutdown the OTel SDK, flushing any pending spans. Called during application shutdown."
@@ -385,7 +385,7 @@
(try
(otel-sdk/close-otel-sdk! otel)
(catch Exception e
- (log/warn e "Error shutting down OpenTelemetry SDK")))
+ (log/warnf "Error shutting down OpenTelemetry SDK: %s" (ex-message e))))
(reset! otel-sdk-instance nil)
(shutdown-groups!)
(log/info "OpenTelemetry tracing shut down")))
diff --git a/src/metabase/tracing/quartz.clj b/src/metabase/tracing/quartz.clj
index e59ec348ab3..4f333a3f640 100644
--- a/src/metabase/tracing/quartz.clj
+++ b/src/metabase/tracing/quartz.clj
@@ -168,7 +168,7 @@
^Scope scope (.makeCurrent span)]
(.set listener-state {:span span :scope scope}))
(catch Throwable t
- (log/error t "Error starting quartz tracing span")))))
+ (log/errorf "Error starting quartz tracing span: %s" (ex-message t))))))
(jobExecutionVetoed [_ _])
@@ -182,7 +182,7 @@
(.close scope)
(.end span)
(catch Throwable t
- (log/error t "Error ending quartz tracing span")))))))
+ (log/errorf "Error ending quartz tracing span: %s" (ex-message t))))))))
;;; ------------------------------------------- Initialization -------------------------------------------------------
diff --git a/src/metabase/tracing/settings.clj b/src/metabase/tracing/settings.clj
index cbbf9ddf9d6..6810798db47 100644
--- a/src/metabase/tracing/settings.clj
+++ b/src/metabase/tracing/settings.clj
@@ -45,7 +45,7 @@
(if (#{"TRACE" "DEBUG" "INFO"} v)
v
(do
- (log/warnf "MB_TRACING_LOG_LEVEL value '%s' is not valid, expected 'TRACE', 'DEBUG', or 'INFO'. Defaulting to 'INFO'." v)
+ (log/warn "MB_TRACING_LOG_LEVEL value is not valid, expected 'TRACE', 'DEBUG', or 'INFO'. Defaulting to 'INFO'.")
"INFO")))))
(defsetting tracing-max-queue-size
diff --git a/src/metabase/transforms/canceling.clj b/src/metabase/transforms/canceling.clj
index 60bbeed6e81..4713da74825 100644
--- a/src/metabase/transforms/canceling.clj
+++ b/src/metabase/transforms/canceling.clj
@@ -107,8 +107,8 @@
{:object run
:details {:outcome outcome}}))
(catch Throwable t
- (log/warnf t "Failed to publish transform-run-canceled event for run %s (outcome=%s)"
- run-id outcome))))
+ (log/warnf "Failed to publish transform-run-canceled event for run %s (outcome=%s): %s"
+ run-id outcome (ex-message t)))))
(defn cancel-run!
"Cancel a `run` (a `:model/TransformRun` row). `request-time` is the `java.time.OffsetDateTime` of the cancelation
@@ -143,9 +143,9 @@
(try
(record-completion! run-id run request-time "timeout")
(catch Throwable t
- (log/error t (str "Error recording completion for transform run " run-id))))))
+ (log/error (str "Error recording completion for transform run " run-id ": " (ex-message t)))))))
(catch Throwable t
- (log/error t "Error force-canceling stale transform runs.")
+ (log/errorf "Error force-canceling stale transform runs: %s" (ex-message t))
;; Transaction rolled back — the row count is unrecoverable, so emit one aggregate error so the failure
;; is at least visible in metrics. Magnitude can be inferred from log volume if needed.
(analytics/inc! :metabase-transforms/cancelation-completed {:outcome "error"}))))
@@ -196,7 +196,7 @@
(when-let [run (t2/select-one :model/TransformRun :id id)]
(cancel-run! run request-time))
(catch Throwable t
- (log/error t (str "Error canceling " id))))))
+ (log/error (str "Error canceling " id ": " (ex-message t)))))))
(wr.cancelation/reducible-canceled-local-runs))
(catch Throwable t
- (log/error t "Error while canceling a transform run."))) 0 20 TimeUnit/SECONDS))
+ (log/errorf "Error while canceling a transform run: %s" (ex-message t)))) 0 20 TimeUnit/SECONDS))
diff --git a/src/metabase/transforms/crud.clj b/src/metabase/transforms/crud.clj
index e9e6b4b119e..3d0eaecdf0d 100644
--- a/src/metabase/transforms/crud.clj
+++ b/src/metabase/transforms/crud.clj
@@ -137,7 +137,7 @@
(let [methods (try
(driver/supported-index-methods (:engine database) database)
(catch Throwable e
- (log/warn e "Failed to fetch supported index methods for transform" (:id transform))
+ (log/warn "Failed to fetch supported index methods for transform" (:id transform) (ex-message e))
nil))]
(not-empty methods)))))
diff --git a/src/metabase/transforms/freshness.clj b/src/metabase/transforms/freshness.clj
index 7747546de31..fc01b69e0da 100644
--- a/src/metabase/transforms/freshness.clj
+++ b/src/metabase/transforms/freshness.clj
@@ -20,7 +20,7 @@
(when-let [next-fire (.getNextValidTimeAfter (CronExpression. ^String cron) last-success)]
(not (.after next-fire now)))
(catch Exception e
- (log/warnf e "Ignoring unparseable transform job schedule %s" (pr-str cron))
+ (log/warnf "Ignoring unparseable transform job schedule %s: %s" (pr-str cron) (ex-message e))
false)))
(defn fresh-dep-ids
diff --git a/src/metabase/transforms/jobs.clj b/src/metabase/transforms/jobs.clj
index 135f13acdb6..40f4d556644 100644
--- a/src/metabase/transforms/jobs.clj
+++ b/src/metabase/transforms/jobs.clj
@@ -181,7 +181,7 @@
(run-transform! ctx started-run-id transform)
{::status :succeeded ::transform transform}
(catch Throwable t
- (log/errorf t "Transform %s in run %s failed" (pr-str (:id transform)) (pr-str run-id))
+ (log/errorf "Transform %s in run %s failed: %s" (pr-str (:id transform)) (pr-str run-id) (ex-message t))
{::status :failed
::transform transform
::message (or (ex-message t) (str t))
@@ -292,7 +292,7 @@
(try
(cancel-worker! worker)
(catch Throwable t
- (log/warnf t "Error canceling in-flight worker for transform %s" (pr-str id))))))
+ (log/warnf "Error canceling in-flight worker for transform %s: %s" (pr-str id) (ex-message t))))))
(defonce ^:private active-runs
;; job-run-id -> promise, delivered once the run is found terminated externally (e.g. reaped).
@@ -454,13 +454,13 @@
(coordinated-run/fail-started-run! model run-id
{:message (compile-transform-failure-messages (::failures result))})
(catch Exception e
- (log/errorf e "Error when failing %s %s." label (pr-str run-id)))))
+ (log/errorf "Error when failing %s %s: %s" label (pr-str run-id) (ex-message e)))))
result)
(catch Throwable t
(try
(coordinated-run/fail-started-run! model run-id {:message (ex-message t)})
(catch Exception e
- (log/errorf e "Error when failing %s." label)))
+ (log/errorf "Error when failing %s: %s" label (ex-message e))))
(throw t))))
(defn- active-users-to-edit-transform
@@ -550,7 +550,7 @@
(try
(notify-transform-failures job-id failures)
(catch Exception e
- (log/errorf e "Error notifying failures of transform job %s" (pr-str job-id))))))]
+ (log/errorf "Error notifying failures of transform job %s: %s" (pr-str job-id) (ex-message e))))))]
(some-> start-promise (deliver [:started run-id]))
(tracing/with-span :tasks "task.transform.run-job" {:transform.job/id job-id
:transform.job/run-method (name run-method)
diff --git a/src/metabase/transforms/models/transform.clj b/src/metabase/transforms/models/transform.clj
index 2eb7e88db24..c8d15011e4f 100644
--- a/src/metabase/transforms/models/transform.clj
+++ b/src/metabase/transforms/models/transform.clj
@@ -151,7 +151,7 @@
;; serdes-imported transform whose source database is missing), not a
;; misconfiguration. Only warn when an id is supplied but invalid.
(when (and target-db-id (not valid-db-id?))
- (log/warnf "Invalid target database id (%s) ignored for new transform (%s)" target-db-id (:name transform)))
+ (log/warnf "Invalid target database id (%s) ignored for new transform" target-db-id))
(-> transform
(assoc-in [:target :database] target-db-id)
(assoc
diff --git a/src/metabase/transforms/models/transform_run.clj b/src/metabase/transforms/models/transform_run.clj
index 3179e76a186..e0b7491134c 100644
--- a/src/metabase/transforms/models/transform_run.clj
+++ b/src/metabase/transforms/models/transform_run.clj
@@ -132,7 +132,7 @@
(cond-> {:object run}
(:user_id run) (assoc :user-id (:user_id run))))
(catch Throwable t
- (log/warnf t "Failed to publish transform-run-timeout event for run %s" (pr-str (:id run))))))
+ (log/warnf "Failed to publish transform-run-timeout event for run %s: %s" (pr-str (:id run)) (ex-message t)))))
(defn timeout-run!
"Mark a started run as timed out."
diff --git a/src/metabase/transforms/query_impl.clj b/src/metabase/transforms/query_impl.clj
index 90f1f4ac868..eb1f693d85b 100644
--- a/src/metabase/transforms/query_impl.clj
+++ b/src/metabase/transforms/query_impl.clj
@@ -63,7 +63,7 @@
(catch Throwable t
(if (= :already-running (:error (ex-data t)))
(log/warnf "Transform %d is already running" id)
- (log/error t "Error executing transform"))
+ (log/errorf "Error executing transform: %s" (ex-message t)))
(throw t)))))
(defmethod transforms.i/execute! :query [transform opts]
diff --git a/src/metabase/transforms/util.clj b/src/metabase/transforms/util.clj
index 442c42db2da..30ae0775696 100644
--- a/src/metabase/transforms/util.clj
+++ b/src/metabase/transforms/util.clj
@@ -208,7 +208,7 @@
rp
full-incremental?)))
(catch Throwable t
- (log/warnf t "Failed to emit incremental-rows metric for transform %s" (:id transform)))))
+ (log/warnf "Failed to emit incremental-rows metric for transform %s: %s" (:id transform) (ex-message t)))))
ret))
(catch Throwable t
(if (:timeout (ex-data t))
diff --git a/src/metabase/transforms_base/query.clj b/src/metabase/transforms_base/query.clj
index 02448752a0f..06f795a6604 100644
--- a/src/metabase/transforms_base/query.clj
+++ b/src/metabase/transforms_base/query.clj
@@ -149,7 +149,7 @@
{:status :cancelled
:error e}
(do
- (log/error e "Error executing transform")
+ (log/errorf "Error executing transform: %s" (ex-message e))
{:status :failed
:error e}))))))
diff --git a/src/metabase/transforms_base/util.clj b/src/metabase/transforms_base/util.clj
index d2b78ca6213..55eaeb76e03 100644
--- a/src/metabase/transforms_base/util.clj
+++ b/src/metabase/transforms_base/util.clj
@@ -737,7 +737,7 @@
(driver/refresh-table-stats! (:engine database) database (:schema target) (:name target)
(keyword (:type target)))
(catch Throwable t
- (log/warnf t "refresh-table-stats! failed for %s.%s" (:schema target) (:name target))))
+ (log/warnf "refresh-table-stats! failed for %s.%s: %s" (:schema target) (:name target) (ex-message t))))
;; Publish event after sync so the table exists in AppDB.
(when publish-events?
(events/publish-event! :event/transform-run-complete
diff --git a/src/metabase/transforms_rest/api/transform_job.clj b/src/metabase/transforms_rest/api/transform_job.clj
index 9270b12c3d2..51aba42f455 100644
--- a/src/metabase/transforms_rest/api/transform_job.clj
+++ b/src/metabase/transforms_rest/api/transform_job.clj
@@ -99,7 +99,7 @@
{:default :cron/raw}
(ms/enum-decode-keyword ui-display-types)]
[:tag_ids {:optional true} [:sequential ms/PositiveInt]]]]
- (log/info "Creating transform job:" name "with schedule:" schedule)
+ (log/info "Creating transform job with schedule:" schedule)
;; Validate cron expression
(api/check-400 (transforms.core/validate-cron-expression schedule)
(deferred-tru "Invalid cron expression: {0}" schedule))
@@ -148,7 +148,7 @@
(op (:id job))
:ok
(catch Throwable t
- (log/errorf t "Failed to %s transform job %d" verb (:id job))
+ (log/errorf "Failed to %s transform job %d: %s" verb (:id job) (ex-message t))
:failed)))
outcomes (frequencies (map try-op candidates))]
{:updated (get outcomes :ok 0)
diff --git a/src/metabase/transforms_rest/api/transform_tag.clj b/src/metabase/transforms_rest/api/transform_tag.clj
index b8bd7a9fcff..b5e04bca22f 100644
--- a/src/metabase/transforms_rest/api/transform_tag.clj
+++ b/src/metabase/transforms_rest/api/transform_tag.clj
@@ -28,7 +28,7 @@
_query-params
{:keys [name]} :- [:map
[:name ms/NonBlankString]]]
- (log/info "Creating transform tag:" name)
+ (log/info "Creating transform tag")
(api/check-403 (mi/can-create? :model/TransformTag {:name name}))
(api/check-400 (not (transforms.core/tag-name-exists? name))
(deferred-tru "A tag with the name ''{0}'' already exists." name))
@@ -41,7 +41,7 @@
_query-params
{:keys [name]} :- [:map
[:name ms/NonBlankString]]]
- (log/info "Updating transform tag" tag-id "with name:" name)
+ (log/info "Updating transform tag" tag-id)
(api/write-check (t2/select-one :model/TransformTag :id tag-id))
(api/check-400 (not (transforms.core/tag-name-exists-excluding? name tag-id))
(deferred-tru "A tag with the name ''{0}'' already exists." name))
diff --git a/src/metabase/transforms_rest/api/util.clj b/src/metabase/transforms_rest/api/util.clj
index 6c6222f7d62..daaf7be9fea 100644
--- a/src/metabase/transforms_rest/api/util.clj
+++ b/src/metabase/transforms_rest/api/util.clj
@@ -42,7 +42,7 @@
(start! start-promise)
(catch Throwable t
;; post-start failures: the run row was already failed by the runner; this is a fallback log
- (log/error t "Async run failed"))))
+ (log/errorf "Async run failed: %s" (ex-message t)))))
(when (instance? Throwable @start-promise)
(throw @start-promise))
(let [result @start-promise
diff --git a/src/metabase/usage_metadata/extract.clj b/src/metabase/usage_metadata/extract.clj
index 77858d8ca1a..ace3c23ab49 100644
--- a/src/metabase/usage_metadata/extract.clj
+++ b/src/metabase/usage_metadata/extract.clj
@@ -69,7 +69,7 @@
(try
(lib/referenced-columns query stage-number clause)
(catch Throwable e
- (log/debugf e "usage-metadata: referenced-columns failed (stage %s)" stage-number)
+ (log/debugf "usage-metadata: referenced-columns failed (stage %s): %s" stage-number (ex-message e))
nil)))
(defn- field-participants-of-clause
@@ -90,7 +90,7 @@
(try
(:operator (lib/expression-parts query stage-number aggregation))
(catch Throwable e
- (log/debugf e "usage-metadata: aggregation operator extraction failed (stage %s)" stage-number)
+ (log/debugf "usage-metadata: aggregation operator extraction failed (stage %s): %s" stage-number (ex-message e))
nil)))
(defn- breakout-column-safe
@@ -98,7 +98,7 @@
(try
(lib/breakout-column query stage-number breakout)
(catch Throwable e
- (log/debugf e "usage-metadata: breakout-column failed (stage %s)" stage-number)
+ (log/debugf "usage-metadata: breakout-column failed (stage %s): %s" stage-number (ex-message e))
nil)))
(defn- segment-facts-for-clause
diff --git a/src/metabase/usage_metadata/insights.clj b/src/metabase/usage_metadata/insights.clj
index fda4f67ab63..04f3cc85b5e 100644
--- a/src/metabase/usage_metadata/insights.clj
+++ b/src/metabase/usage_metadata/insights.clj
@@ -83,7 +83,7 @@
(try
(vec (lib/all-field-ids predicate))
(catch Throwable e
- (log/debug e "usage-metadata: predicate-field-ids failed")
+ (log/debugf "usage-metadata: predicate-field-ids failed: %s" (ex-message e))
[]))))
;; No SQL LIMIT here: callers filter saved-signature collisions in Clojure, so a SQL LIMIT can under-deliver.
@@ -205,7 +205,7 @@
(try
(lib/query (lib-be/application-database-metadata-provider database-id) query-map)
(catch Throwable e
- (log/debug e "Failed to wrap query for usage-metadata insights")
+ (log/debugf "Failed to wrap query for usage-metadata insights: %s" (ex-message e))
nil))))
(defn- extract-facts
@@ -214,7 +214,7 @@
(try
(usage-metadata.extract/extract-usage-facts q)
(catch Throwable e
- (log/debug e "Failed to extract usage facts for usage-metadata insights")
+ (log/debugf "Failed to extract usage facts for usage-metadata insights: %s" (ex-message e))
nil))))
(def ^:private cache-ttl-ms
diff --git a/src/metabase/usage_metadata/task/process.clj b/src/metabase/usage_metadata/task/process.clj
index a5e51c87118..fbdc4ec127b 100644
--- a/src/metabase/usage_metadata/task/process.clj
+++ b/src/metabase/usage_metadata/task/process.clj
@@ -34,7 +34,7 @@
(try
(usage-metadata.batch/run-batch!)
(catch Throwable e
- (log/error e "Error processing usage metadata batch")
+ (log/errorf "Error processing usage metadata batch: %s" (ex-message e))
(throw e)))))
(defn- job []
diff --git a/src/metabase/user_key_value/models/user_key_value/types.clj b/src/metabase/user_key_value/models/user_key_value/types.clj
index 06e5b6e5997..7b6bde72317 100644
--- a/src/metabase/user_key_value/models/user_key_value/types.clj
+++ b/src/metabase/user_key_value/models/user_key_value/types.clj
@@ -168,4 +168,4 @@
(try
(watch-directory! (io/file (io/resource types-dir)) handle-file-change!)
(catch Exception e
- (log/warn e "Could not watch UserKeyValue schema directory!")))))
+ (log/warnf "Could not watch UserKeyValue schema directory!: %s" (ex-message e))))))
diff --git a/src/metabase/users/events/last_login.clj b/src/metabase/users/events/last_login.clj
index dc0744adfbc..3784bca5707 100644
--- a/src/metabase/users/events/last_login.clj
+++ b/src/metabase/users/events/last_login.clj
@@ -17,4 +17,4 @@
(t2/update! :model/User user-id {:last_login :%now})
(catch Throwable e
;; TODO -- huh? Terrible log message.
- (log/warnf e "Failed to process sync-database event. %s" topic)))))
+ (log/warnf "Failed to process sync-database event. %s: %s" topic (ex-message e))))))
diff --git a/src/metabase/users/models/user_parameter_value.clj b/src/metabase/users/models/user_parameter_value.clj
index ae16359bd61..28c592f2337 100644
--- a/src/metabase/users/models/user_parameter_value.clj
+++ b/src/metabase/users/models/user_parameter_value.clj
@@ -63,7 +63,7 @@
(m/index-by (juxt :user_id :dashboard_id :parameter_id))
vals))
(catch Exception e
- (log/error e "Error saving user parameters for a dashboard"))))
+ (log/errorf "Error saving user parameters for a dashboard: %s" (ex-message e)))))
(defonce ^:private user-parameter-value-queue
(delay (grouper/start!
diff --git a/src/metabase/util/async.clj b/src/metabase/util/async.clj
index 029fc886d5c..d3ffc80cc6d 100644
--- a/src/metabase/util/async.clj
+++ b/src/metabase/util/async.clj
@@ -34,7 +34,7 @@
(let [result (try
(thunk)
(catch Throwable e
- (log/trace e "cancelable-thread-call: caught exception in f")
+ (log/tracef "cancelable-thread-call: caught exception in f: %s" (ex-message e))
e))]
(a/close! done-chan)
(when (some? result)
diff --git a/src/metabase/util/connection.clj b/src/metabase/util/connection.clj
index 0b218575fe8..31a2952f4d0 100644
--- a/src/metabase/util/connection.clj
+++ b/src/metabase/util/connection.clj
@@ -84,7 +84,7 @@
(not (str/includes? (str (.getDatabaseProductVersion md)) "MariaDB"))
(>= (.getDatabaseMajorVersion md) 10)))
(catch Throwable e
- (log/debug e "Could not read server version; assuming statement timeouts work")
+ (log/debugf "Could not read server version; assuming statement timeouts work: %s" (ex-message e))
false))))
(defn set-query-timeout!
diff --git a/src/metabase/util/date_2.clj b/src/metabase/util/date_2.clj
index 485c87a6065..07132fd86be 100644
--- a/src/metabase/util/date_2.clj
+++ b/src/metabase/util/date_2.clj
@@ -52,8 +52,8 @@
result
(let [result-with-timezone (add-zone-to-local result default-timezone-id)]
(when-not (= result result-with-timezone)
- (log/tracef "Applying default timezone %s to temporal literal without timezone '%s' -> %s"
- default-timezone-id s (pr-str result-with-timezone)))
+ (log/tracef "Applying default timezone %s to temporal literal without timezone"
+ default-timezone-id))
result-with-timezone)))))
(defn- temporal->iso-8601-formatter [t]
diff --git a/src/metabase/util/encryption.clj b/src/metabase/util/encryption.clj
index 6191e0c53af..3ad2c973791 100644
--- a/src/metabase/util/encryption.clj
+++ b/src/metabase/util/encryption.clj
@@ -234,9 +234,9 @@
args
(cons default-secret-key args))
log-error-fn (fn [kind ^Throwable e]
- (log/warnf e
- "Cannot decrypt encrypted %s. Have you changed or forgot to set MB_ENCRYPTION_SECRET_KEY?"
- kind))]
+ (log/warnf "Cannot decrypt encrypted %s. Have you changed or forgot to set MB_ENCRYPTION_SECRET_KEY? %s"
+ kind
+ (ex-message e)))]
(cond (nil? secret-key)
v
diff --git a/src/metabase/util/experiment.cljc b/src/metabase/util/experiment.cljc
index 61d68bd9404..af4566983ad 100644
--- a/src/metabase/util/experiment.cljc
+++ b/src/metabase/util/experiment.cljc
@@ -129,7 +129,7 @@
match? (outcomes-match? comparator-fn control-outcome candidate-outcome)]
(when-not match?
(if (contains? candidate-outcome :error)
- (log/warnf "Experiment %s: candidate threw %s" name (str (:error candidate-outcome)))
+ (log/warnf "Experiment %s: candidate threw %s" name (ex-message (:error candidate-outcome)))
(log/warnf "Experiment %s: result MISMATCH" name)))
(when report-fn
(report-fn {:name name
diff --git a/src/metabase/util/files.clj b/src/metabase/util/files.clj
index 57cbfca629c..d43a3633769 100644
--- a/src/metabase/util/files.clj
+++ b/src/metabase/util/files.clj
@@ -101,7 +101,7 @@
(try
(copy-file! source target)
(catch Throwable e
- (log/error e "Failed to copy file")))))
+ (log/errorf "Failed to copy file: %s" (ex-message e))))))
;;; ------------------------------------------ Opening filesystems for URLs ------------------------------------------
diff --git a/src/metabase/util/i18n/impl.clj b/src/metabase/util/i18n/impl.clj
index eda0ea300a0..1403a6e66ac 100644
--- a/src/metabase/util/i18n/impl.clj
+++ b/src/metabase/util/i18n/impl.clj
@@ -206,11 +206,11 @@
(catch Throwable e
;; Not translating this string to prevent an unfortunate stack overflow. If this string happened to be the one
;; that had the typo, we'd just recur endlessly without logging an error.
- (log/errorf e "Unable to translate string %s to %s" (pr-str format-string) (str locale-or-name))
+ (log/errorf "Unable to translate string %s to %s: %s" (pr-str format-string) (str locale-or-name) (ex-message e))
(try
(.format (MessageFormat. format-string) (to-array args))
(catch Throwable _
- (log/errorf e "Invalid format string %s" (pr-str format-string))
+ (log/errorf "Invalid format string %s: %s" (pr-str format-string) (ex-message e))
format-string)))))))
(def ^:private ^:dynamic *in-site-locale-from-setting*
diff --git a/src/metabase/util/malli/fn.clj b/src/metabase/util/malli/fn.clj
index c00b7bbb46d..128c5ea4a86 100644
--- a/src/metabase/util/malli/fn.clj
+++ b/src/metabase/util/malli/fn.clj
@@ -227,10 +227,10 @@
(log/warn
(case error-type
::invalid-input (format "Invalid input - Please report this as an issue on Github: %s"
- (pr-str humanized))
+ (pr-str (me/humanize error)))
::invalid-output (format "Invalid output - Please report this as an issue on Github: %s"
- (pr-str humanized)))
- details))))))
+ (pr-str (me/humanize error))))
+ (dissoc details :value :error :humanized)))))))
(defn validate-input
"Impl for [[metabase.util.malli.fn/fn]]; validates an input argument with `value` against `schema` using a cached
diff --git a/src/metabase/util/queue.clj b/src/metabase/util/queue.clj
index c3e0991f497..9d7c0fb8454 100644
--- a/src/metabase/util/queue.clj
+++ b/src/metabase/util/queue.clj
@@ -142,7 +142,6 @@
(if (seq batch)
(do
(log/debugf "Listener %s processing batch of %d" listener-name (count batch))
- (log/tracef "Listener %s processing batch: %s" listener-name batch)
(let [timer (u/start-timer)
output (handler batch)
duration (u/since-ms timer)]
@@ -154,7 +153,7 @@
(throw e))
(catch Exception e
(err-handler e listener-name)
- (log/errorf e "Error in %s while processing batch" listener-name))))
+ (log/errorf "Error in %s while processing batch: %s" listener-name (ex-message e)))))
(log/infof "Listener %s stopped" listener-name))
(def ^:private ^:const max-restart-backoff-ms 30000)
@@ -172,7 +171,7 @@
(log/debugf "Listener thread %s stopped" listener-name)
(throw (InterruptedException.)))
(catch Throwable e
- (log/errorf e "Listener thread %s crashed, restarting in %dms" listener-name backoff-ms)))
+ (log/errorf "Listener thread %s crashed, restarting in %dms: %s" listener-name backoff-ms (ex-message e))))
(Thread/sleep ^long backoff-ms)
(when-not (.isShutdown ^ExecutorService (get @listeners listener-name))
(recur (min max-restart-backoff-ms (* 2 backoff-ms))))))
@@ -251,7 +250,7 @@
(try
(f k)
(catch Throwable e
- (log/errorf e "Error initializing listener %s" k)))))
+ (log/errorf "Error initializing listener %s: %s" k (ex-message e))))))
(defn stop-listeners!
"Stops all running listeners"
diff --git a/src/metabase/util/quick_task.clj b/src/metabase/util/quick_task.clj
index f40b4318ff5..dc257dccea8 100644
--- a/src/metabase/util/quick_task.clj
+++ b/src/metabase/util/quick_task.clj
@@ -2,7 +2,6 @@
"Namespace with helpers for quick tasks. Intended for quick, one-off tasks like re-syncing a table,
fingerprinting a field, etc."
(:require
- [clojure.string :as str]
[metabase.classloader.core :as classloader]
[metabase.config.core :as config]
[metabase.util :as u]
@@ -46,12 +45,10 @@
(try
(.get fut timeout-ms TimeUnit/MILLISECONDS)
(catch TimeoutException _
- (log/warnf "quick-task exceeded timeout of %d ms, cancelling. Stuck thread stack trace:\n%s"
- timeout-ms
- (str/join "\n" (map #(str " " %) (.getStackTrace t))))
+ (log/warnf "quick-task exceeded timeout of %d ms, cancelling" timeout-ms)
(.cancel fut true))
(catch InterruptedException _
(.interrupt (Thread/currentThread)))
(catch Exception e
- (log/warn e "quick-task threw exception")))))]
+ (log/warnf "quick-task threw exception: %s" (ex-message e))))))]
(.submit ^ExecutorService @executor ^Callable wrapped)))
diff --git a/src/metabase/util/snake_hating_map.clj b/src/metabase/util/snake_hating_map.clj
index 98b05ea44d3..0432570c92b 100644
--- a/src/metabase/util/snake_hating_map.clj
+++ b/src/metabase/util/snake_hating_map.clj
@@ -23,7 +23,7 @@
(pr-str (u/->kebab-case-en k)))
{:k k})]
(if config/is-prod?
- (log/warn e)
+ (log/warn (ex-message e))
(throw e))))
(defn- normalize-key [k]
diff --git a/src/metabase/util/yaml.clj b/src/metabase/util/yaml.clj
index e7e68b792d1..90889a27512 100644
--- a/src/metabase/util/yaml.clj
+++ b/src/metabase/util/yaml.clj
@@ -84,8 +84,8 @@
(or (some-> e
ex-data
(select-keys [:error :value])
- u/pprint-to-str)
- e))
+ pr-str)
+ (ex-message e)))
(throw e)))))
(defn load-dir
diff --git a/src/metabase/version/settings.clj b/src/metabase/version/settings.clj
index 5325eba69c3..686c631af9e 100644
--- a/src/metabase/version/settings.clj
+++ b/src/metabase/version/settings.clj
@@ -62,7 +62,7 @@
(prevent-upgrade? current-major (-> raw-version-info :latest) upgrade-threshold-value)
(dissoc :latest))
(catch Exception e
- (log/error e "Error processing version info")
+ (log/errorf "Error processing version info: %s" (ex-message e))
raw-version-info)))
(defsetting version-info
diff --git a/src/metabase/version/task/upgrade_checks.clj b/src/metabase/version/task/upgrade_checks.clj
index 7c8f7c67e68..453f7af2d36 100644
--- a/src/metabase/version/task/upgrade_checks.clj
+++ b/src/metabase/version/task/upgrade_checks.clj
@@ -39,7 +39,7 @@
(when-let [version-info (get-version-info)]
(version.settings/version-info! version-info))
(catch Throwable e
- (log/error e "Error fetching version info; setting version-info value to nil")
+ (log/errorf "Error fetching version info; setting version-info value to nil: %s" (ex-message e))
(version.settings/version-info! nil)))))
(def ^:private job-key "metabase.task.upgrade-checks.job")
diff --git a/src/metabase/view_log/events/view_log.clj b/src/metabase/view_log/events/view_log.clj
index c7d53fcc933..88aea6b4952 100644
--- a/src/metabase/view_log/events/view_log.clj
+++ b/src/metabase/view_log/events/view_log.clj
@@ -63,7 +63,7 @@
cnt->ids))]}
:where [:in :id (apply concat (vals cnt->ids))]})))))
(catch Exception e
- (log/error e "Failed to increment view counts"))))
+ (log/errorf "Failed to increment view counts: %s" (ex-message e)))))
(def ^:private increment-view-count-interval-seconds 20)
@@ -90,7 +90,7 @@
(try
(t2/insert! :model/ViewLog views)
(catch Exception e
- (log/error e "Failed to record views"))))
+ (log/errorf "Failed to record views: %s" (ex-message e)))))
(defonce ^:private record-view-queue
(delay (grouper/start!
@@ -137,7 +137,7 @@
(increment-view-counts! :model/Card object-id)
(record-views! (generate-view :model :model/Card event))
(catch Throwable e
- (log/warnf e "Failed to process view event. %s" topic)))))
+ (log/warnf "Failed to process view event. %s: %s" topic (ex-message e))))))
(derive ::card-query-model-view :metabase/event)
(derive :event/card-query ::card-query-model-view)
@@ -159,7 +159,7 @@
:user-id user-id
:context :question)))
(catch Throwable e
- (log/warnf e "Failed to process card query view event. %s" topic)))))
+ (log/warnf "Failed to process card query view event. %s: %s" topic (ex-message e))))))
(derive ::dashboard-queried :metabase/event)
(derive :event/dashboard-queried ::dashboard-queried)
@@ -187,7 +187,7 @@
:updated_at :updated_at}
:where [:in :id (keys dashboard-id->timestamp)]}))
(catch Exception e
- (log/error e "Failed to update dashboard last_viewed_at")))))
+ (log/errorf "Failed to update dashboard last_viewed_at: %s" (ex-message e))))))
(def ^:private update-dashboard-last-viewed-at-queue
(delay (grouper/start!
@@ -208,7 +208,7 @@
(try
(update-dashboard-last-viewed-at! object-id)
(catch Throwable e
- (log/warnf e "Failed to process dashboard query event. %s" topic))))
+ (log/warnf "Failed to process dashboard query event. %s: %s" topic (ex-message e)))))
(derive ::collection-read-event :metabase/event)
(derive :event/collection-read ::collection-read-event)
@@ -221,7 +221,7 @@
generate-view
record-views!)
(catch Throwable e
- (log/warnf e "Failed to process view event. %s" topic))))
+ (log/warnf "Failed to process view event. %s: %s" topic (ex-message e)))))
(derive ::read-permission-failure :metabase/event)
(derive :event/read-permission-failure ::read-permission-failure)
@@ -237,7 +237,7 @@
generate-view
record-views!))
(catch Throwable e
- (log/warnf e "Failed to process view event. %s" topic))))
+ (log/warnf "Failed to process view event. %s: %s" topic (ex-message e)))))
(derive ::dashboard-read :metabase/event)
(derive :event/dashboard-read ::dashboard-read)
@@ -253,7 +253,7 @@
(increment-view-counts! :model/Dashboard object-id)
(record-views! (generate-view :model :model/Dashboard event))
(catch Throwable e
- (log/warnf e "Failed to process view event. %s" topic)))))
+ (log/warnf "Failed to process view event. %s: %s" topic (ex-message e))))))
(derive ::table-read :metabase/event)
(derive :event/table-read ::table-read)
@@ -277,4 +277,4 @@
generate-view
record-views!))
(catch Throwable e
- (log/warnf e "Failed to process view event. %s" topic)))))
+ (log/warnf "Failed to process view event. %s: %s" topic (ex-message e))))))
diff --git a/src/metabase/warehouse_schema/models/field_values.clj b/src/metabase/warehouse_schema/models/field_values.clj
index a31d8f203f2..41b2ca386b5 100644
--- a/src/metabase/warehouse_schema/models/field_values.clj
+++ b/src/metabase/warehouse_schema/models/field_values.clj
@@ -397,7 +397,7 @@
qp.reducible/default-rff)]
{:values (-> result :data :rows)})
(catch Throwable e
- (log/error e "Error fetching field values")
+ (log/errorf "Error fetching field values: %s" (ex-message e))
nil)))
(defn- delete-duplicates-and-return-latest!
diff --git a/src/metabase/warehouse_schema_rest/api/table.clj b/src/metabase/warehouse_schema_rest/api/table.clj
index f95a5e7db9b..214f06bb6bd 100644
--- a/src/metabase/warehouse_schema_rest/api/table.clj
+++ b/src/metabase/warehouse_schema_rest/api/table.clj
@@ -226,8 +226,8 @@
(doseq [table tables]
(log/info (u/format-color :green "Table '%s' is now visible. Resyncing." (:name table)))
(sync/sync-table! table))
- (log/warn (u/format-color :red "Cannot connect to database '%s' in order to sync unhidden tables"
- (:name database))))))))))
+ (log/warn (u/format-color :red "Cannot connect to database %s in order to sync unhidden tables"
+ (:id database))))))))))
(defn- update-tables!
[ids {:keys [visibility_type] :as body}]
@@ -551,8 +551,8 @@
(driver.u/can-connect-with-details? (:engine database) (:details database) :throw-exceptions))
nil
(catch Throwable e
- (log/warn (u/format-color :red "Cannot connect to database '%s' in order to sync table '%s'"
- (:name database) (:name table)))
+ (log/warn (u/format-color :red "Cannot connect to database %s in order to sync table '%s'"
+ (:id database) (:name table)))
e))]
(throw (ex-info (ex-message ex) {:status-code 422}))
(do
diff --git a/src/metabase/warehouses/models/database.clj b/src/metabase/warehouses/models/database.clj
index 07dd6c80c64..dba916bafd0 100644
--- a/src/metabase/warehouses/models/database.clj
+++ b/src/metabase/warehouses/models/database.clj
@@ -241,7 +241,7 @@
(when (should-auto-sync? database)
((requiring-resolve 'metabase.sync.task.sync-databases/check-and-schedule-tasks-for-db!) database))
(catch Throwable e
- (log/error e "Error scheduling tasks for DB"))))
+ (log/errorf "Error scheduling tasks for DB: %s" (ex-message e)))))
(defn maybe-test-and-migrate-details!
"When a driver has db-details to test and migrate:
@@ -270,25 +270,24 @@
Reports analytics with the given connection-type label."
[database driver engine details-map connection-type]
(try
- (log/info (u/format-color :cyan "Health check [%s]: checking %s {:id %d}"
- connection-type (:name database) (:id database)))
+ (log/info (u/format-color :cyan "Health check [%s]: checking database {:id %d}"
+ connection-type (:id database)))
(u/with-timeout (driver.settings/db-connection-timeout-ms)
(or (driver/can-connect? driver details-map)
(throw (Exception. (format "Failed to connect to Database (%s)" connection-type)))))
- (log/info (u/format-color :green "Health check [%s]: success %s {:id %d}"
- connection-type (:name database) (:id database)))
+ (log/info (u/format-color :green "Health check [%s]: success database {:id %d}"
+ connection-type (:id database)))
(analytics/inc! :metabase-database/status {:driver engine :healthy true :connection-type connection-type})
true
(catch Throwable e
(let [humanized-message (some->> (u/all-ex-messages e)
(driver/humanize-connection-error-message driver))
reason (if (keyword? humanized-message) "user-input" "exception")]
- (log/error e (u/format-color :red "Health check [%s]: failure with error %s {:id %d :reason %s :message %s}"
- connection-type
- (:name database)
- (:id database)
- reason
- humanized-message))
+ (log/error (u/format-color :red "Health check [%s]: failure {:id %d :reason %s :message %s}"
+ connection-type
+ (:id database)
+ reason
+ humanized-message))
(analytics/inc! :metabase-database/status {:driver engine :healthy false :reason reason :connection-type connection-type}))
false)))
@@ -300,7 +299,7 @@
- cleans-up ambiguous legacy db-details"
[{:keys [engine] :as database}]
(when-not (or (:is_audit database) (:is_sample database))
- (log/info (u/format-color :cyan "Health check: queueing %s {:id %d}" (:name database) (:id database)))
+ (log/info (u/format-color :cyan "Health check: queueing database {:id %d}" (:id database)))
(quick-task/submit-task!
(fn []
(let [details (maybe-test-and-migrate-details! database)
@@ -313,12 +312,12 @@
(let [provider (provider-detection/detect-provider-from-database database)]
(when (not= provider (:provider_name database))
(try
- (log/info (u/format-color :blue "Provider detection: updating %s {:id %d} from '%s' to '%s'"
- (:name database) (:id database)
+ (log/info (u/format-color :blue "Provider detection: updating database {:id %d} from '%s' to '%s'"
+ (:id database)
(:provider_name database) provider))
(t2/update! :model/Database (:id database) {:provider_name provider})
(catch Throwable provider-e
- (log/warnf provider-e "Error during provider detection for database {:id %d}" (:id database)))))))
+ (log/warnf "Error during provider detection for database {:id %d}: %s" (:id database) (ex-message provider-e)))))))
(when (driver.conn/database-write-data-details lib-db)
(let [write-details (driver.conn/without-resolution-telemetry
(driver.conn/with-write-connection
@@ -370,7 +369,7 @@
(try
((requiring-resolve 'metabase.sync.task.sync-databases/unschedule-tasks-for-db!) database)
(catch Throwable e
- (log/error e "Error unscheduling tasks for DB."))))
+ (log/errorf "Error unscheduling tasks for DB: %s" (ex-message e)))))
;; TODO -- consider whether this should live HERE or inside the `permissions` module.
(defn- set-new-database-permissions!
@@ -477,7 +476,7 @@
(try
(driver/notify-database-updated driver database)
(catch Throwable e
- (log/error e "Error sending database deletion notification"))))
+ (log/errorf "Error sending database deletion notification: %s" (ex-message e)))))
(defn- maybe-disable-uploads-for-all-dbs!
"This function maintains the invariant that only one database can have uploads_enabled=true."
@@ -648,8 +647,8 @@
;; there is an known issue with exception is ignored when render API response (#32822)
;; If you see this error, you probably need to define a setting for `setting-name`.
;; But ideally, we should resolve the above issue, and remove this try/catch
- (log/errorf e "Error checking the readability of %s setting. The setting will be hidden in API response."
- setting-name)
+ (log/errorf "Error checking the readability of %s setting. The setting will be hidden in API response. Error: %s"
+ setting-name (ex-message e))
;; let's be conservative and hide it by defaults, if you want to see it,
;; you need to define it :)
false)))
diff --git a/src/metabase/warehouses/util.clj b/src/metabase/warehouses/util.clj
index bf7ec7484da..f79cadadfd9 100644
--- a/src/metabase/warehouses/util.clj
+++ b/src/metabase/warehouses/util.clj
@@ -61,7 +61,7 @@
{:message (tru "Unable to connect to database.")})
(catch Throwable e
(when (and log-exception (not (some->> e ex-cause ex-data ::driver/can-connect-message?)))
- (log/error e "Cannot connect to Database"))
+ (log/errorf "Cannot connect to Database: %s" (ex-message e)))
(if (-> e ex-data :message)
(ex-data e)
{:message (ex-message e)})))))
diff --git a/src/metabase/warehouses_rest/api.clj b/src/metabase/warehouses_rest/api.clj
index b22929a5aef..4abf66dc186 100644
--- a/src/metabase/warehouses_rest/api.clj
+++ b/src/metabase/warehouses_rest/api.clj
@@ -205,7 +205,7 @@
(when-let [db (t2/select-one :model/Database :id db-id)]
(driver.u/supports? (driver.u/database->driver db) :nested-queries db))
(catch Throwable e
- (log/error e "Error determining whether Database supports nested queries"))))
+ (log/errorf "Error determining whether Database supports nested queries: %s" (ex-message e)))))
(t2/select-pks-set :model/Database))))
(mu/defn- source-query-cards
@@ -827,7 +827,7 @@
substring (autocomplete-suggestions id (str "%" substring "%"))
prefix (autocomplete-suggestions id (str prefix "%")))}
(catch Throwable e
- (log/warnf e "Error with autocomplete: %s" (ex-message e)))))
+ (log/warnf "Error with autocomplete: %s" (ex-message e)))))
;; TODO (Cam 10/28/25) -- fix this endpoint route to use kebab-case for consistency with the rest of our REST API
;;
@@ -854,7 +854,7 @@
(filter mi/can-read?)
(map #(select-keys % [:id :name :type :collection_name])))
(catch Throwable e
- (log/warnf e "Error with autocomplete: %s" (ex-message e)))))
+ (log/warnf "Error with autocomplete: %s" (ex-message e)))))
;;; ------------------------------------------ GET /api/database/:id/fields ------------------------------------------
diff --git a/src/metabase/xrays/automagic_dashboards/populate.clj b/src/metabase/xrays/automagic_dashboards/populate.clj
index 143bf0415b8..ac9157b048f 100644
--- a/src/metabase/xrays/automagic_dashboards/populate.clj
+++ b/src/metabase/xrays/automagic_dashboards/populate.clj
@@ -369,10 +369,7 @@
;; safe upper bound.
(make-grid grid-width (* n grid-width))]))
dashboard (update dashboard :dashcards create-dashboard-populate-dashcards)]
- (log/debugf "Adding %s cards to dashboard %s:\n%s"
- (count cards)
- title
- (str/join "; " (map :title cards)))
+ (log/debugf "Adding %s cards to dashboard" (count cards))
(cond-> (update dashboard :dashcards (partial sort-by (juxt :row :col)))
(not-empty filters) (filters/add-filters filters max-filters)))))
diff --git a/src/metabase/xrays/automagic_dashboards/util.clj b/src/metabase/xrays/automagic_dashboards/util.clj
index 5d007ab1d42..fdeb3082656 100644
--- a/src/metabase/xrays/automagic_dashboards/util.clj
+++ b/src/metabase/xrays/automagic_dashboards/util.clj
@@ -98,7 +98,7 @@
(assoc :xrays/database-id (:database root))
(analyze/run-classifiers {}))))
;; otherwise this isn't returning something, and that's probably an error. Log it.
- (log/warnf "Cannot resolve Field %s in automagic analysis context\n%s" field-id-or-name-or-clause (u/pprint-to-str root)))))
+ (log/warnf "Cannot resolve Field %s in automagic analysis context" field-id-or-name-or-clause))))
(defn filter-id-for-field
"Generate a parameter ID for the given field. In X-ray dashboards a parameter is mapped to a single field only."
diff --git a/test/metabase/channel/impl/email_test.clj b/test/metabase/channel/impl/email_test.clj
index f3a85d285b1..ce16e2bbeac 100644
--- a/test/metabase/channel/impl/email_test.clj
+++ b/test/metabase/channel/impl/email_test.clj
@@ -180,16 +180,19 @@
(#'email.impl/notification-recipients->emails recipients {}))))))
(deftest render-body-logging-test
- (testing "rendering a user-provided template logs the template body at debug level"
+ (testing "rendering a user-provided template logs a debug message, without leaking the template body"
(mt/with-log-messages-for-level [messages :debug]
(let [template {:details {:type :email/handlebars-text
:subject "Test"
:body "Hello {{name}}"}}]
(#'email.impl/render-body template {:name "World"})
(is (some (fn [{:keys [message]}]
- (and (re-find #"Rendering user-provided template" message)
- (re-find #"Hello" message)))
- (messages)))))))
+ (re-find #"Rendering user-provided template" message))
+ (messages)))
+ (testing "the template body itself is not logged"
+ (is (not (some (fn [{:keys [message]}]
+ (re-find #"Hello" message))
+ (messages)))))))))
(deftest email-branding-hidden-when-whitelabel-test
(testing "the 'Made with Metabase' footer respects the :whitelabel premium feature"
diff --git a/test/metabase/channel/models/channel_test.clj b/test/metabase/channel/models/channel_test.clj
index 856211209a5..b56a55614b4 100644
--- a/test/metabase/channel/models/channel_test.clj
+++ b/test/metabase/channel/models/channel_test.clj
@@ -95,7 +95,7 @@
{:channel-type :channel/email})))))))
(deftest channel-template-create-logging-test
- (testing "creating a user-provided template logs the template body"
+ (testing "creating a user-provided template logs template metadata, without leaking the template body"
(mt/with-log-messages-for-level [messages :info]
(mt/with-model-cleanup [:model/ChannelTemplate]
(t2/insert-returning-instance! :model/ChannelTemplate
@@ -106,6 +106,9 @@
:body "Secret {{password}}"}})
(is (some (fn [{:keys [message]}]
(and (re-find #"ChannelTemplate create" message)
- (re-find #"handlebars-text" message)
- (re-find #"Secret" message)))
- (messages)))))))
+ (re-find #"handlebars-text" message)))
+ (messages)))
+ (testing "the template body itself is not logged"
+ (is (not (some (fn [{:keys [message]}]
+ (re-find #"Secret" message))
+ (messages)))))))))
diff --git a/test/metabase/channel/render/style_test.clj b/test/metabase/channel/render/style_test.clj
index eee2039dced..d70d2ba0c1e 100644
--- a/test/metabase/channel/render/style_test.clj
+++ b/test/metabase/channel/render/style_test.clj
@@ -43,5 +43,5 @@
#"Error registering fonts: Metabase will not be able to send Pulses"
(#'style/register-fonts!)))
(testing "Should log the Exception"
- (is (=? {:level :error, :e Throwable, :message #"^Error registering fonts: .*"}
+ (is (=? {:level :error, :e nil, :message #"^Error registering fonts: .*Oops!"}
(first (messages)))))))))
diff --git a/test/metabase/driver/util_test.clj b/test/metabase/driver/util_test.clj
index 71df47e1b0a..0c6e5c0c196 100644
--- a/test/metabase/driver/util_test.clj
+++ b/test/metabase/driver/util_test.clj
@@ -448,12 +448,12 @@
feature (keyword (name (ns-name *ns*)) (mt/random-name))]
(mt/with-log-messages-for-level [log-messages [metabase.driver.util :error]]
(is (false? (driver.u/supports? :test-driver feature db)))
- (is (some (fn [{:keys [level e message]}]
+ (is (some (fn [{:keys [level message]}]
(and (= level :error)
- (= (ex-message e) "test exception message")
- (= message (u/format-color 'red "Failed to check feature '%s' for database '%s'"
+ (= message (u/format-color 'red "Failed to check feature '%s' for database %s: %s"
(u/qualified-name feature)
- (:name db)))))
+ (:id db)
+ "test exception message"))))
(log-messages)))))))))
(deftest supports?-failure-test-2
@@ -466,12 +466,12 @@
driver/database-supports? (fn [_ _ _] (Thread/sleep 200) true)]
(mt/with-log-messages-for-level [log-messages [metabase.driver.util :error]]
(is (false? (driver.u/supports? :test-driver feature db)))
- (is (some (fn [{:keys [level e message]}]
+ (is (some (fn [{:keys [level message]}]
(and (= level :error)
- (= (ex-message e) "Timed out after 100.0 ms")
- (= message (u/format-color 'red "Failed to check feature '%s' for database '%s'"
+ (= message (u/format-color 'red "Failed to check feature '%s' for database %s: %s"
(u/qualified-name feature)
- (:name db)))))
+ (:id db)
+ "Timed out after 100.0 ms"))))
(log-messages)))))
(testing "we memoize the results for the same database, so we don't log the error again"
(mt/with-log-messages-for-level [log-messages [metabase.driver.util :error]]
diff --git a/test/metabase/lib/swap_test.cljc b/test/metabase/lib/swap_test.cljc
index e224d0db9e3..c946c5b77f6 100644
--- a/test/metabase/lib/swap_test.cljc
+++ b/test/metabase/lib/swap_test.cljc
@@ -97,7 +97,7 @@
[a1 a2 _a3] (lib/aggregations query)]
(log.capture/with-log-messages-for-level [messages [metabase.lib.swap :warn]]
(lib/swap-clauses query -1 a2 (lib.options/update-options a1 assoc :lib/uuid (str (random-uuid))))
- (is (=? [{:level :warn, :message #"No matching clause in swap-clauses \[:count .*"}]
+ (is (=? [{:level :warn, :message #"No matching clause in swap-clauses"}]
(messages)))))))
(deftest ^:synchronized swap-clauses-ambiguous-test
@@ -111,7 +111,7 @@
query (update-in query [:stages 0 :aggregation] conj a2)]
(log.capture/with-log-messages-for-level [messages [metabase.lib.swap :warn]]
(lib/swap-clauses query -1 a1 a2)
- (is (=? [{:level :warn, :message #"Ambiguous match for clause in swap-clauses \[:sum .*"}]
+ (is (=? [{:level :warn, :message #"Ambiguous match for clause in swap-clauses \(2 matches\)"}]
(messages)))))))
(deftest ^:parallel swap-clauses-aggregations-with-downstream-refs-test
diff --git a/test/metabase/metabot/self_test.clj b/test/metabase/metabot/self_test.clj
index 52b6040a22c..886020471e9 100644
--- a/test/metabase/metabot/self_test.clj
+++ b/test/metabase/metabot/self_test.clj
@@ -1231,7 +1231,7 @@
"retry-delay-ms picks up the 3-second Retry-After through the rethrown exception"))))
(deftest rethrow-api-error!-warn-log-test
- (testing "the full upstream body is emitted at warn level alongside provider and status"
+ (testing "provider and status are emitted at warn level; the body is never logged"
(let [upstream (ex-info "clj-http error"
{:status 502 :reason-phrase "Bad Gateway"
:headers {"content-type" "text/plain"}
@@ -1246,9 +1246,11 @@
(is (nil? more) "exactly one warn line at the failure boundary")
(is (=? {:level :warn :namespace 'metabase.metabot.self.core}
entry))
- (is (re-find #"provider=openrouter status=502 body=\"upstream gateway timeout\""
- (:message entry)))))
- (testing "an oversized body is capped in the warn log, but preserved in full on ex-data"
+ (is (re-find #"provider=openrouter status=502"
+ (:message entry)))
+ (is (not (str/includes? (:message entry) "upstream gateway timeout"))
+ "the response body is not logged")))
+ (testing "the body never reaches the warn log, but is preserved in full on ex-data"
(let [cap @#'self.core/max-body-log-chars
big-body (apply str (repeat (+ cap 1000) \x))
upstream (ex-info "clj-http error"
@@ -1265,11 +1267,9 @@
"the full, untruncated body still survives on ex-data"))
(msgs))]
(is (nil? more) "exactly one warn line at the failure boundary")
- (is (str/ends-with? (:message entry)
- (str "body=" (subs (pr-str big-body) 0 cap) "…"))
- "the warn line's body segment is capped at max-body-log-chars with a trailing ellipsis")
- (is (not (str/includes? (:message entry) big-body))
- "the full oversized body is not spliced into the warn line"))))
+ (is (re-find #"provider=openrouter status=502" (:message entry)))
+ (is (not (str/includes? (:message entry) "xxx"))
+ "no fragment of the body is spliced into the warn line"))))
(deftest rethrow-api-error!-auth-status-body-not-leaked-test
(testing "401/403 bodies are not appended to the user-facing message (may carry sensitive auth/account detail)"
@@ -1294,5 +1294,8 @@
"the full decoded body is still preserved on ex-data for debugging"))
(msgs))]
(is (nil? more) "exactly one warn line at the failure boundary")
- (is (str/includes? (:message entry) secret)
- "the full body is still emitted at warn level for server-side debugging")))))
+ (is (str/includes? (:message entry)
+ (str "provider=anthropic status=" status))
+ "a warn with provider and status is still emitted for server-side debugging")
+ (is (not (str/includes? (:message entry) secret))
+ "the secret-bearing body never appears in the warn log")))))
diff --git a/test/metabase/models/interface_test.clj b/test/metabase/models/interface_test.clj
index f6ed31845d0..843b3e2eaaf 100644
--- a/test/metabase/models/interface_test.clj
+++ b/test/metabase/models/interface_test.clj
@@ -9,9 +9,7 @@
[metabase.util.encryption :as encryption]
[metabase.util.encryption-test :as encryption-test]
[metabase.util.json :as json]
- [toucan2.core :as t2])
- (:import
- (com.fasterxml.jackson.core JsonParseException)))
+ [toucan2.core :as t2]))
;; Let's make sure `transform-metric-segment-definition`/`transform-parameters-list` normalization functions respond
;; gracefully to invalid stuff when pulling them out of the Database. See #8914
@@ -108,19 +106,19 @@
(mi/encrypted-json-out
(encryption/encrypt (encryption/secret-key->hash "qwe") "{\"a\": 1}"))
(is (=? [{:level :error
- :e JsonParseException
+ :e nil
:message "Could not decrypt encrypted field! Have you forgot to set MB_ENCRYPTION_SECRET_KEY?"}]
(messages)))))
(testing "Invalid JSON throws correct error"
(mt/with-log-messages-for-level [messages :error]
(mi/encrypted-json-out "{\"a\": 1")
- (is (=? [{:level :error, :e JsonParseException, :message "Error parsing JSON"}]
+ (is (=? [{:level :error, :e nil, :message #"(?s)^Error parsing JSON: .*"}]
(messages))))
(mt/with-log-messages-for-level [messages :error]
(encryption-test/with-secret-key "qwe"
(mi/encrypted-json-out
(encryption/encrypt (encryption/secret-key->hash "qwe") "{\"a\": 1")))
- (is (=? [{:level :error, :e JsonParseException, :message "Error parsing JSON"}]
+ (is (=? [{:level :error, :e nil, :message #"(?s)^Error parsing JSON: .*"}]
(messages)))))))
(deftest ^:parallel instances-with-hydrated-data-test
diff --git a/test/metabase/session/api_test.clj b/test/metabase/session/api_test.clj
index 960089b4582..2c52055f1e2 100644
--- a/test/metabase/session/api_test.clj
+++ b/test/metabase/session/api_test.clj
@@ -101,12 +101,12 @@
(mt/with-log-messages-for-level [messages :error]
(is (=? {:specific-errors {:username ["missing required key, received: nil"]}}
(mt/client :post 400 "session" {:email (:email user), :password "wooo"})))
- (is (=? {:level :error, :e clojure.lang.ExceptionInfo, :message "Authentication endpoint error"}
+ (is (=? {:level :error, :e nil, :message #"^Authentication endpoint error: .+"}
(or (->> (messages)
;; geojson can throw errors and we want the authentication error
;;
;; TODO -- huh? geojson???? -- Cam
- (m/find-first #(= (:message %) "Authentication endpoint error")))
+ (m/find-first #(re-find #"^Authentication endpoint error" (:message %))))
["no matching message:" (messages)])))))))
(deftest login-validation-username-required-test
@@ -154,7 +154,9 @@
(testing "Error should be logged (#14317)"
(mt/with-log-messages-for-level [messages :error]
(login)
- (is (=? {:level :error, :e clojure.lang.ExceptionInfo, :message "Authentication endpoint error"}
+ (is (=? {:level :error
+ :e nil
+ :message #"^Authentication endpoint error: Too many attempts! You must wait \d+ seconds before trying again\.$"}
(first (messages))))))
(is (re= #"^Too many attempts! You must wait \d+ seconds before trying again\.$"
(login))