Back

trace (clj)

(source)

macro

(trace & args)

Examples

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

(comment (macroexpand '(log-data "my-ns" :info {:min-level :trace} {} ["x"])))

(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]]}))

(deftest levels
  [(testing "Levels.global/basic"
     [(is (map? (log-data "ns" :trace {:min-level nil}    {} [])) "call >= default (:trace)")
      (is (map? (log-data "ns" :trace {:min-level :trace} {} [])) "call >= min")
      (is (nil? (log-data "ns" :trace {:min-level :info}  {} [])) "call <  min")
      (is (map? (log-data "ns" :info  {:min-level :info}  {} [])) "call >= min")

   (testing "Levels.global/by-ns"
     [(is (map? (log-data "ns.2" :trace  {:min-level [["ns.1" :info]                         ]} {} [])) "call >= default (:trace)")
      (is (map? (log-data "ns.2" :info   {:min-level [["ns.1" :warn] ["ns.2"           :info]]} {} [])) "call >= match")
      (is (map? (log-data "ns.2" :info   {:min-level [["ns.1" :warn] [#{"ns.3" "ns.2"} :info]]} {} [])) "call >= match")
      (is (map? (log-data "ns.2" :info   {:min-level [["ns.1" :warn] ["*"              :info]]} {} [])) "call >= *")
      (is (map? (log-data "ns.1" :info   {:min-level [["ns.1" :info] ["*"              :warn]]} {} [])) "Ordered pattern search")])

(deftest namespaces
  [(testing "Namespaces/global"
     [(is (map? (log-data "ns.1.a" :report {:min-level :trace :ns-filter "ns.1.*"}                         {} [])))
      (is (nil? (log-data "ns.1.b" :report {:min-level :trace :ns-filter "ns.2.*"}                         {} [])))
      (is (nil? (log-data "ns.1.c" :report {:min-level :trace :ns-filter {:allow "ns.1.*" :deny "ns.1.c"}} {} [])) ":deny match")])

   (testing "Namespaces/appender"
     [(is (map? (log-data "ns.1.a" :report {:min-level :trace :ns-filter "ns.1.*"} {:ns-filter "ns.1.*"} [])) "both global and appender allowed")
      (is (nil? (log-data "ns.1.a" :report {:min-level :trace :ns-filter "ns.2.*"} {:ns-filter "ns.1.*"} [])) "global   denied")
      (is (nil? (log-data "ns.1.a" :report {:min-level :trace :ns-filter "ns.1.*"} {:ns-filter "ns.2.*"} [])) "appender denied")])])
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))
samply/blaze
(ns blaze.scheduler-test
  (:require
   [blaze.executors :as ex]
   [blaze.module.test-util :refer [with-system]]
   [blaze.scheduler :as sched]
   [blaze.scheduler-spec]
   [blaze.test-util :as tu]
   [clojure.spec.test.alpha :as st]
   [clojure.test :as test :refer [deftest is testing]]
   [integrant.core :as ig]
   [java-time.api :as time]
   [taoensso.timbre :as log]))

(set! *warn-on-reflection* true)
(st/instrument)
(log/set-level! :trace)
samply/blaze
(ns blaze.db.tx-log.spec-test
  (:require
   [blaze.db.tx-log.spec]
   [blaze.fhir.hash :as hash]
   [blaze.fhir.hash-spec]
   [blaze.fhir.test-util]
   [blaze.test-util :as tu]
   [clojure.spec.alpha :as s]
   [clojure.spec.test.alpha :as st]
   [clojure.test :as test :refer [are deftest]]
   [taoensso.timbre :as log]))

(st/instrument)
(log/set-level! :trace)
samply/blaze
(ns blaze.page-store.local-test
  (:require
   [blaze.anomaly-spec]
   [blaze.fhir.test-util :refer [given-failed-future]]
   [blaze.metrics.core :as metrics]
   [blaze.metrics.spec]
   [blaze.module.test-util :refer [with-system]]
   [blaze.page-store :as page-store]
   [blaze.page-store-spec]
   [blaze.page-store.local]
   [blaze.page-store.spec :refer [page-store?]]
   [blaze.test-util :as tu :refer [given-thrown]]
   [clojure.spec.alpha :as s]
   [clojure.spec.test.alpha :as st]
   [clojure.string :as str]
   [clojure.test :as test :refer [deftest is testing]]
   [cognitect.anomalies :as anom]
   [integrant.core :as ig]
   [java-time.api :as time]
   [juxt.iota :refer [given]]
   [taoensso.timbre :as log]))

(st/instrument)
(log/set-level! :trace)
siilisolutions/hedge
(ns hedge.azure.timbre-test
  (:require [cljs.test :refer-macros [deftest is testing run-tests]]
            [taoensso.timbre :as timbre
                              :refer (log  trace  debug  info  warn  error  fatal  report
                                      logf tracef debugf infof warnf errorf fatalf reportf
                                      spy get-env log-env)]
            [hedge.azure.timbre-appender :refer [timbre-appender]]
            [hedge.azure.common :refer [azure-context-logger-mock]]))
(comment
  (deftest foo
    (cljs.pprint/pprint timbre/*config*)
    (info "aaa")
    (debug "bbb")
    (warn "ccc")
    (trace "xyz")
  
    ; note: only this prints stack
    (timbre/with-merged-config {:level :trace}
      (trace "a"))
  
    ; TODO: maybe add stack print if required for azure appender
    (timbre/with-merged-config {:level :trace
                                :appenders {:console nil
                                            :azure (timbre-appender azure-context-logger-mock)}}
      (cljs.pprint/pprint timbre/*config*)
      (trace "halp"))

    ; does not show, reverted back to default configuration with default appender
    (trace "not")))