Skip to content
Snippets Groups Projects
Commit 51818b2a authored by Allen Gilliland's avatar Allen Gilliland
Browse files

fix up logging config so that it's useful and defaults to printing to stdout. ...

fix up logging config so that it's useful and defaults to printing to stdout.  use logging calls instead of printlns.
parent f374321a
No related branches found
No related tags found
No related merge requests found
log4j.rootLogger=INFO, corvus
log4j.appender.corvus=org.apache.log4j.RollingFileAppender
log4j.appender.corvus.File=${logfile.path}/corvus.log
log4j.appender.corvus.MaxFileSize=500MB
log4j.appender.corvus.MaxBackupIndex=2
log4j.appender.corvus.layout=org.apache.log4j.PatternLayout
log4j.appender.corvus.layout.ConversionPattern=%d [%t] %-5p%c - %m%n
\ No newline at end of file
log4j.rootLogger=INFO, console
# log to the console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%-5p] %c :: %m%n
# log to a file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${logfile.path}/corvus.log
log4j.appender.file.MaxFileSize=500MB
log4j.appender.file.MaxBackupIndex=2
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p%c - %m%n
# customizations to logging by package
log4j.logger.metabase=DEBUG
\ No newline at end of file
(ns metabase.api.common.internal
"Internal functions used by `metabase.api.common`."
(:require [metabase.util :refer [fn-> regex?]])
(:require [clojure.tools.logging :as log]
[metabase.util :refer [fn-> regex?]])
(:import com.metabase.corvus.api.ApiException))
;;; # DEFENDPOINT HELPER FUNCTIONS + MACROS
......@@ -125,8 +126,7 @@
(let [message# (.getMessage e#)
stacktrace# (->> (map str (.getStackTrace e#))
(filter (partial re-find #"metabase")))]
(println message#)
(clojure.pprint/pprint stacktrace#)
(log/debug message# "\n" (with-out-str (clojure.pprint/pprint stacktrace#)))
{:status 500
:body {:message message#
:stacktrace stacktrace#}}))))
......
......@@ -36,7 +36,6 @@
(hydrate :organization)))
(defendpoint PUT "/:id" [id :as {{:keys [name engine details]} :body}]
(println name engine details)
(write-check Database id)
(check-500 (upd Database id :name name :engine engine :details details)))
......
(ns metabase.api.session
"/api/session endpoints"
(:require [cemerick.friend.credentials :as creds]
[clojure.tools.logging :as log]
[compojure.core :refer [defroutes POST DELETE]]
[korma.core :as korma]
[metabase.api.common :refer :all]
......@@ -15,7 +16,6 @@
(let-400 [user (sel :one :fields [User :id :password_salt :password] :email email (korma/where {:is_active true}))]
(check (creds/bcrypt-verify (str (:password_salt user) password) (:password user)) [400 "password mismatch"])
(let [session-id (str (java.util.UUID/randomUUID))]
(println "SESSION ID: " session-id)
(ins Session
:id session-id
:user_id (:id user))
......@@ -37,7 +37,7 @@
(check-404 user-id)
(upd User user-id :reset_token reset-token :reset_triggered (System/currentTimeMillis))
;; TODO - send email
(println (str "/auth/reset_password/" reset-token))))
(log/info (str "/auth/reset_password/" reset-token))))
;; set password from reset token
......
......@@ -163,7 +163,7 @@
(default-fields entity#))) ; tell korma which fields to grab. If `field-keys` weren't passed in vector
(merge *entity-overrides*))] ; then do a `default-fields` lookup at runtime
(when *log-db-calls*
(println "DB CALL: " (:name entity#)
(log/debug "DB CALL: " (:name entity#)
(or (:fields entity-select-form#) "*")
~@(mapv (fn [[form & args]]
`[~(name form) ~(apply str (interpose " " args))])
......
(ns metabase.driver
(:require [clojure.data.json :as json]
[clojure.tools.logging :as log]
[medley.core :refer :all]
[metabase.db :refer [exists? ins sel upd]]
[metabase.driver.query-processor :as qp]
......@@ -74,7 +75,7 @@
(when (= :failed (:status query-result)) (throw (Exception. (get query-result :error "general error"))))
(query-complete query-execution query-result (:cache_result options)))
(catch Exception ex
(.printStackTrace ex)
(log/warn ex)
(query-fail query-execution (.getMessage ex))))))
......
(ns metabase.driver.generic-sql.query-processor
"The Query Processor is responsible for translating the Metabase Query Language into korma SQL forms."
(:require [clojure.core.match :refer [match]]
[clojure.tools.logging :as log]
[korma.core :refer :all]
[metabase.db :refer :all]
[metabase.driver.generic-sql.query-processor.annotate :as annotate]
......@@ -180,10 +181,8 @@
(defn- log-query
"Log QUERY Dictionary and the korma form and SQL that the Query Processor translates it to."
[{:keys [source_table] :as query} forms]
(println "\nQUERY ->")
(clojure.pprint/pprint query)
(println "\nKORMA FORM ->")
(clojure.pprint/pprint `(select (table-id->korma-entity ~source_table) ~@forms))
(log/debug
"\nQUERY ->" (with-out-str (clojure.pprint/pprint query))
"\nKORMA FORM ->" (with-out-str (clojure.pprint/pprint `(select (table-id->korma-entity ~source_table) ~@forms))))
(eval `(let [entity# (table-id->korma-entity ~source_table)]
(println "\nSQL ->")
(println (sql-only (select entity# ~@forms)) "\n"))))
(log/debug "\nSQL ->" (sql-only (select entity# ~@forms)) "\n"))))
(ns metabase.driver.generic-sql.sync
"Generic implementations of `metabase.driver.sync` functions that should work across any SQL database supported by Korma."
(:require [korma.core :refer :all]
(:require [clojure.tools.logging :as log]
[korma.core :refer :all]
[metabase.db :refer :all]
(metabase.models [database :refer [with-jdbc-metadata]]
[field :refer [Field]]
......@@ -54,5 +55,5 @@
:active true))] ; creating dozens of them, which was causing issues with too
(update-table-row-count table) ; many open connections.
(sync-fields table)
(println "Synced" table-name)))))
(log/debug "Synced" table-name)))))
dorun)))))
(ns metabase.driver.native
"The `native` query processor."
(:import com.metabase.corvus.api.ApiException)
(:require [metabase.api.common :refer :all]
(:require [clojure.tools.logging :as log]
[metabase.api.common :refer :all]
[metabase.db :refer [sel]]
(metabase.models [database :refer [Database]])))
......@@ -29,7 +30,7 @@
:base_type (value->base-type v)}))))
(defn process-and-run [{:keys [native database] :as query}]
(println "QUERY: " query)
(log/debug "QUERY: " query)
(let [db (sel :one Database :id database)
sql (:query native)
results ((:native-query db) sql)]
......
(ns metabase.middleware.log-api-call
"Middleware to log API calls. Primarily for debugging purposes."
(:require [clojure.pprint :refer [pprint]]))
(:require [clojure.pprint :refer [pprint]]
[clojure.tools.logging :as log]))
(declare api-call?
log-request)
......@@ -18,7 +19,7 @@
(log-request request))
(let [response (time (handler request))]
(when log-response?
(pprint response))
(log/debug (with-out-str (pprint response))))
response))))))
(defn- api-call?
......@@ -28,7 +29,5 @@
(= (.substring uri 0 4) "/api")))
(defn- log-request [{:keys [uri request-method params]}]
(println "\n----------------------------------------")
(println (.toUpperCase (name request-method)) uri)
(when-not (empty? params)
(pprint params)))
(log/debug (.toUpperCase (name request-method)) uri) (when-not (empty? params)
(with-out-str (pprint params))))
(ns metabase.models.database
(:require [clojure.data.json :as json]
[clojure.java.jdbc :as jdbc]
[clojure.tools.logging :as log]
(korma [core :refer :all]
[db :as kdb])
[metabase.api.common :refer :all]
......@@ -34,7 +35,7 @@
(defn korma-db
"Return a Korma database definition for DATABASE."
[{:keys [connection]}]
(println "CREATING A NEW DB CONNECTION...")
(log/debug "CREATING A NEW DB CONNECTION...")
(kdb/create-db @connection))
(defn table-names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment