Back

debug (clj)

(source)

macro

(debug & args)

Examples

timbre
(ns taoensso.timbre-tests
  (:require
   [clojure.test    :as test :refer [deftest testing is]]
   [taoensso.encore :as enc]
   [taoensso.timbre :as timbre])

(deftest _set-ns-min-level
  [(is (= (timbre/set-ns-min-level {:min-level :info         } "a" :trace) {:min-level [["a" :trace] ["*" :info]]}))
   (is (= (timbre/set-ns-min-level {:min-level [["a" :debug]]} "a" :trace) {:min-level [["a" :trace]]}))
   (is (= (timbre/set-ns-min-level {:min-level [["a" :debug]]} "a" nil)    {:min-level nil}))

   (is (= (timbre/set-ns-min-level {:min-level [["a.b" :trace] ["a.c" :debug] ["a.*" :info] ["a.c" :error]]}
            "a.c" :report)
         {:min-level [["a.c" :report] ["a.b" :trace] ["a.*" :info]]}))

   (is (= (->
            (timbre/set-ns-min-level {:min-level :info} "foo" :debug)
            (timbre/set-ns-min-level "foo" nil))
         {:min-level :info}))])
replikativ/datahike
(ns datahike.http.writer
  "Remote writer implementation for datahike.http.server through datahike.http.client."
  (:require [datahike.writer :refer [PWriter create-writer create-database delete-database]]
            [datahike.http.client :refer [request-json] :as client]
            [datahike.json :as json]
            [datahike.tools :as dt :refer [throwable-promise]]
            [taoensso.timbre :as log]
            [clojure.core.async :refer [promise-chan put!]]))

(defrecord DatahikeServerWriter [remote-peer conn]
  PWriter
  (-dispatch! [_ arg-map]
    (let [{:keys [op args]} arg-map
          p (promise-chan)
          config (:config @(:wrapped-atom conn))]
      (log/debug "Sending operation to datahike-server:" op)
      (log/trace "Arguments:" arg-map)
      (put! p
            (try
              (request-json :post
                            (str op "-writer")
                            remote-peer
                            (vec (concat [config] args))
                            json/mapper)
              (catch Exception e
                e)))
      p))
  (-shutdown [_])
  (-streaming? [_] false))

(defmethod create-writer :datahike-server
  [config connection]
  (log/debug "Creating datahike-server writer for " connection config)
  (->DatahikeServerWriter config connection))
ingesolvoll/kee-frame
(ns ^:no-doc kee-frame.event-logger
  (:require [re-frame.interceptor :as i]
            [clojure.data :as data]
            [taoensso.timbre :as log]))

              (log/debug (merge {:event event}
                                (when (seq effects)
                                  {:side-effects effects})
                                (when (not= new-db ::not-found)
                                  (let [[only-before only-after] (data/diff orig-db new-db)
                                        db-changed? (or (some? only-before) (some? only-after))]
                                    (when db-changed?
                                      {:db-diff {:only-before only-before
                                                 :only-after  only-after}})))))
              context))))
eponai/sulolive
(ns eponai.common.ui.streams
  (:require
    [eponai.common.ui.common :as common]
    [eponai.common.ui.dom :as my-dom]
    [om.next :as om :refer [defui]]
    [taoensso.timbre :refer [debug]]
    [eponai.common.ui.elements.css :as css]
    [eponai.common.ui.elements.grid :as grid]
    [eponai.common.ui.router :as router]
    [eponai.client.routes :as routes]
    [eponai.web.ui.photo :as photo]
    [eponai.common.ui.dom :as dom]
    [eponai.web.ui.button :as button]
    [eponai.web.ui.content-item :as ci]
    [eponai.common.format.date :as date]))

(defui Streams
  static om/IQuery
  (query [_]
    [
     {:query/streams (om/get-query ci/OnlineChannel)}
     {:query/stores (om/get-query ci/StoreItem)}
     {:query/online-stores (om/get-query ci/StoreItem)}])
  Object
  (render [this]
    (let [{:query/keys [streams stores online-stores]} (om/props this)
          streaming-stores (set (map #(get-in % [:stream/store :db/id]) streams))
          online-not-live (remove #(contains? streaming-stores (:db/id %)) online-stores)
          offline-stores (remove #(contains? (set (map :db/id online-not-live)) (:db/id %)) stores)
          online-right-now (filter #(let [online (-> % :store/owners :store.owner/user :user/online?)]
                                      (or (= true online)
                                          (> 60000 (- (date/current-millis) online))))
                                   online-not-live)]
      (debug "Live props: " (om/props this))
      (dom/div
        {:classes ["sulo-browse"]}
        (grid/row
          (css/add-class :section)
          (grid/column
            nil
            (my-dom/div
              (css/add-class :section-title)
              (my-dom/h2 nil "LIVE right now"))
            (if (not-empty streams)
              (my-dom/div {:classes ["sulo-items-container"]}
                          (grid/row
                            (grid/columns-in-row {:small 2 :medium 3 :large 4})
                            (map (fn [s]
                                   (grid/column
                                     nil
                                     (ci/->OnlineChannel s)))
                                 streams)))
              (my-dom/div
                {:classes ["sulo-items-container empty-container"]}
                (my-dom/span (css/add-class :shoutout) "No stores are LIVE right now :'(")))
eponai/sulolive
(ns eponai.client.parser.mutate
  (:require
    [eponai.common.parser :as parser :refer [client-mutate client-auth-role]]
    [eponai.common.format :as format]
    [eponai.common.auth :as auth]
    [eponai.client.chat :as client.chat]
    [eponai.client.auth :as client.auth]
    [eponai.client.cart :as client.cart]
    [eponai.common.shared :as shared]
    [eponai.common.database :as db]
    [datascript.core :as datascript]
    [eponai.common :as c]
    [taoensso.timbre :refer [debug warn]]))

(defmethod client-mutate 'login-modal/show
  [{:keys [state target]} _ _]
  (when-not target
    {:action (fn []
               (debug "Transact show login")
               (db/transact state [{:ui/singleton                   :ui.singleton/login-modal
                                    :ui.singleton.login-modal/show? true}]))}))

(defmethod client-mutate 'notification/receive
  [{:keys [state target]} _ notification]
  (when-not target
    {:action (fn []
               (debug "Firebase - notification/receive: " notification)
               (let [db-notification (assoc notification :db/id -1)]
                 (db/transact state [db-notification
                                     [:db/add [:ui/singleton :ui.singleton/notify] :ui.singleton.notify/notifications -1]])))}))

(defmethod client-mutate 'notification/remove
  [{:keys [state target]} _ {:keys [id]}]
  (when-not target
    {:action (fn []
               (debug "Firebase - notification/remove: " id)
               (when-let [notification (db/one-with (db/db state) {:where   '[[?e :notification/id ?id]]
                                                                   :symbols {'?id id}})]
                 (db/transact state [[:db.fn/retractEntity notification]])))}))

(defmethod client-mutate 'search/search
  [{:keys [target]} _ {:keys [search-string]}]
  (if target
    {:remote true}
    {:action (fn []
               (debug "Mutate search string: " search-string))}))

(defmethod client-mutate 'routes/set-route!
  [{:keys [state]} _ {:keys [route route-params query-params]}]
  {:action (fn []
             (debug "Setting route: " route " route-params: " route-params)
             (let [id (:db/id (db/entity (db/db state) [:ui/singleton :ui.singleton/routes]))]
               (db/transact state [[:db/add id :ui.singleton.routes/current-route route]
                                   (if (seq route-params)
                                     [:db/add id :ui.singleton.routes/route-params route-params]
                                     [:db.fn/retractAttribute id :ui.singleton.routes/route-params])
                                   (if (seq query-params)
                                     [:db/add id :ui.singleton.routes/query-params query-params]
                                     [:db.fn/retractAttribute id :ui.singleton.routes/query-params])])))})

(defmethod client-mutate 'beta/vendor
  [{:keys [target]} _ p]
  (debug "beta/vendor with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'beta/customer
  [{:keys [target]} _ p]
  (debug "beta/customer with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'location/suggest
  [{:keys [target]} _ p]
  (debug "location/suggest with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'photo/upload
  [{:keys [target]} _ p]
  (debug "photo/upload with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'user.info/update
  [{:keys [target]} _ p]
  (debug "user.info/update with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store.photo/upload
  [{:keys [target]} _ p]
  (debug "store.photo/upload with params: " p)
  (if target
    {:remote (some? (:photo p))}))

(defmethod client-mutate 'store/update-info
  [{:keys [target]} _ p]
  (debug "store/update-info with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-sections
  [{:keys [target]} _ p]
  (debug "store/update-sections with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-product-order
  [{:keys [state target]} _ {:keys [items] :as p}]
  (debug "store/update-sections with params: " p)
  (if target
    {:remote true}
    {:action (fn []
               (db/transact state (map (fn [p]
                                         [:db/add (:db/id p) :store.item/index (:store.item/index p)])
                                       items)))}))

(defmethod client-mutate 'stripe/create-account
  [{:keys [target]} _ p]
  (debug "stripe/create-account with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'stripe/update-account
  [{:keys [target]} _ p]
  (debug "stripe/update-account with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'stripe/update-customer
  [{:keys [target]} _ p]
  (debug "stripe/update-customer with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'stripe/upload-identity-document
  [{:keys [target]} _ p]
  (debug "stripe/upload-identity-document with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/create-product
  [{:keys [target]} _ p]
  (debug "store/create-product with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-product
  [{:keys [target]} _ p]
  (debug "store/update-product with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/delete-product
  [{:keys [target]} _ p]
  (debug "store/delete-product with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/create-order
  [{:keys [target]} _ p]
  (debug "store/create-order with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-order
  [{:keys [target]} _ p]
  (debug "store/update-order with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/save-shipping-rule
  [{:keys [target]} _ p]
  (debug "store/save-shipping-rule with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/delete-shipping-rule
  [{:keys [target]} _ p]
  (debug "store/delete-shipping-rule with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-shipping-rule
  [{:keys [target]} _ p]
  (debug "store/update-shipping-rule with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-shipping
  [{:keys [target]} _ p]
  (debug "store/update-shipping with params: " p)
  (if target
    {:remote true}))

(defmethod client-mutate 'store/update-tax
  [{:keys [target state]} _ {:keys [store-id tax] :as p}]
  (debug "store/update-tax with params: " p)
  (if target
    {:remote true}
    {:action (fn []
               (let [{old-tax :store/tax} (db/pull (db/db state) [{:store/tax [:db/id :tax/rules]}] store-id)
                     new-tax (cond-> (format/tax tax)
                                     (some? (:db/id old-tax))
                                     (assoc :db/id (:db/id old-tax)))

                     txs (cond-> [new-tax]
                                 (db/tempid? (:db/id new-tax))
                                 (conj [:db/add store-id :store/tax (:db/id new-tax)]))]
                 (debug "Transacting new tax: " txs)
                 (db/transact state txs)))}))

(defmethod client-mutate 'store/update-username
  [{:keys [target]} _ p]
  (debug "store/update-username with params: " p)
  (if target
    {:remote true}))
phylogeography/spread
(ns tests.integration.continuous-tree-with-time-slicer-test
  (:require [clj-http.client :as http]
            [clojure.java.io :as io]
            [clojure.string :as string]
            [clojure.test :refer [deftest is use-fixtures]]
            [shared.time :as time]
            [taoensso.timbre :as log]
            [tests.integration.continuous-tree-test :refer [block-on-status]]
            [tests.integration.utils :refer [db-fixture run-query]]))

    (log/debug "response" {:id         continuous-tree-id
                           :name       readableName
                           :created-on createdOn
                           :status     status
                           :timeSlicer timeSlicer})