Back

info (clj)

(source)

macro

(info & args)

Examples

timbre
(ns taoensso.timbre.appenders.community.rotor-test
  (:require
    [clojure.test :refer :all]
    [clojure.java.io :as io]
    [clojure.set :as set]
    [taoensso.timbre :as timbre]
    [taoensso.timbre.appenders.community.rotor :as rotor]))

(deftest rotor-test
  (let [n-logs 5]
    (setup n-logs)
    (doseq [i (range 100)]
      (timbre/info "testing..."))
    (check-logs-present n-logs)
    (teardown n-logs)))

      (doseq [i (range n-lines)]
        (timbre/info "testing:" i))

      (let [futures
            (for [i (range n-lines)]
              (future
                (timbre/info "testing:" i)))]
        (doseq [f futures]
          @f))
timbre
(ns taoensso.timbre-tests
  (:require
   [clojure.test    :as test :refer [deftest testing is]]
   [taoensso.encore :as enc]
   [taoensso.timbre :as timbre])

(comment (apn {:min-level :info :ns-filter "*"}))

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

   (is (= (->
            (timbre/set-ns-min-level {:min-level :info} "foo" :debug)
            (timbre/set-ns-min-level "foo" nil))
         {:min-level :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")

      (is (not     (:error-level? (log-data "ns" :info  {:min-level :info}  {} []))))
      (is (boolean (:error-level? (log-data "ns" :error {:min-level :error} {} []))))])

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

   (testing "Levels.appender/basic"
     [(is (map? (log-data "ns" :info {:min-level :info}   {:min-level :info}   [])) "call >= both global and appender")
      (is (nil? (log-data "ns" :info {:min-level :report} {:min-level :info}   [])) "call <  global")
      (is (nil? (log-data "ns" :info {:min-level :info}   {:min-level :report} [])) "call <  appender")])

   (testing "Levels.appender/by-ns"
     [(is (map? (log-data "ns" :info {:min-level [["ns" :info]]}  {:min-level :info}          [])) "call >= both global and appender")
      (is (map? (log-data "ns" :info {:min-level [["ns" :info]]}  {:min-level [["ns" :info]]} [])) "call >= both global and appender")
      (is (nil? (log-data "ns" :info {:min-level [["ns" :warn]]}  {:min-level [["ns" :info]]} [])) "call <  global")
      (is (nil? (log-data "ns" :info {:min-level [["ns" :info]]}  {:min-level [["ns" :warn]]} [])) "call <  appender")])])

(deftest middleware
  [(is (= :bar (:foo (log-data "ns" :info {:middleware [(fn [m] (assoc m :foo :bar))]} {} []))))
   (is (= nil        (log-data "ns" :info {:middleware [(fn [_] nil)]} {} [])))])

(deftest special-args
  [(testing "Special-args/errors"
     [(is (nil?       (:?err  (log-data "ns" :report {} {} ["foo"                  ]))))
      (is (enc/error? (:?err  (log-data "ns" :report {} {} [(ex-info "ex" {}) "foo"]))) "First-arg ex -> :?err")
      (is (enc/error? (:?err  (log-data "ns" :report {} {} [(ex-info "ex" {})      ]))) "First-arg ex -> :?err")
      (is (= ["foo"]  (:vargs (log-data "ns" :report {} {} [(ex-info "ex" {}) "foo"]))) "First-arg ex dropped from vargs")
      (is (= []       (:vargs (log-data "ns" :report {} {} [(ex-info "ex" {})      ]))) "First-arg ex dropped from vargs")])
fulcrologic/fulcro
(ns fulcro-todomvc.server
  (:require
    [com.fulcrologic.fulcro.mutations :as m :refer [defmutation]]
    [clojure.core.async :as async]
    [com.wsscode.pathom.core :as p]
    [com.wsscode.pathom.connect :as pc]
    [taoensso.timbre :as log]))

(pc/defmutation todo-new-item [env {:keys [id list-id text]}]
  {::pc/sym    `fulcro-todomvc.api/todo-new-item
   ::pc/params [:list-id :id :text]
   ::pc/output [:item/id]}
  (log/info "New item on server")
  (let [new-id (random-uuid)]
    (swap! item-db assoc new-id {:item/id new-id :item/label text :item/complete false})
    {:tempids {id new-id}
     :item/id new-id}))
fulcrologic/fulcro
(ns com.fulcrologic.fulcro.cards.multi-root-cards
  (:require
    [com.fulcrologic.fulcro.components :as comp :refer [defsc]]
    [com.fulcrologic.fulcro.dom :as dom]
    [com.fulcrologic.fulcro.mutations :as m]
    [com.fulcrologic.fulcro.react.hooks :as hooks]
    [com.fulcrologic.fulcro.rendering.multiple-roots-renderer :as mroot]
    [nubank.workspaces.card-types.fulcro3 :as ct.fulcro]
    [nubank.workspaces.core :as ws]
    [taoensso.timbre :as log]))

(defsc OtherChild [this {:keys [:other/id :other/n] :as props}]
  {:query         [:other/id :other/n]
   :ident         :other/id
   :initial-state {:other/id :param/id :other/n :param/n}}
  (log/info "OtherChild" (some-> comp/*parent* (comp/component-name)) (comp/depth this))
  (dom/div
    (dom/button
      {:onClick #(m/set-integer! this :other/n :value (inc n))}
      (str n))))

(defsc AltRoot [this props]
  {:use-hooks? true}
  (log/info "AltRoot" (some-> comp/*parent* (comp/component-name)) (comp/depth this))
  (let [id      (hooks/use-generated-id)                    ; Generate an ID to use with floating root
        ;; mount a floating root that renders OtherChild
        factory (hooks/use-fulcro-mount this {:initial-state-params {:id id :n 1}
                                              :child-class          OtherChild})]
    ;; Install a GC handler that will clean up the generated data of OtherChild when this component unmounts
    (hooks/use-gc this [:other/id id] #{})
    (dom/div
      (dom/h4 "ALTERNATE ROOT")
      (when factory
        (factory props)))))

(defsc Child [this {:child/keys [id name] :as props}]
  {:query         [:child/id :child/name]
   :ident         :child/id
   :initial-state {:child/id :param/id :child/name :param/name}}
  (log/info "Child" (some-> comp/*parent* (comp/component-name)) (comp/depth this))
  (dom/div
    (dom/h2 "Regular Tree")
    (dom/label "Child: ")
    (dom/input {:value    (or name "")
                :onChange (fn [evt]
                            (let [v (.. evt -target -value)]
                              (comp/transact! this
                                [(m/set-props {:child/name v})]
                                {:only-refresh [(comp/get-ident this)]})))})
    (ui-alt-root)))

(defsc Root [this {:keys [children] :as props}]
  {:query         [{:children (comp/get-query Child)}]
   :initial-state {:children [{:id 1 :name "Joe"}
                              {:id 2 :name "Sally"}]}}
  (log/info "Root" (some-> comp/*parent* (comp/component-name)) (comp/depth this))
  (let [show? (comp/get-state this :show?)]
    (dom/div
      (dom/button {:onClick (fn [] (comp/set-state! this {:show? (not show?)}))} "Toggle")
      (when show?
        ;; Two children
        (mapv ui-child children)))))
vlaaad/reveal
(ns e07-timbre-tap-appender
  (:require [taoensso.timbre :as log]
            [vlaaad.reveal :as r]))

(log/merge-config!
  {:appenders
   {:println {:enabled? false}
    :reveal {:enabled? true
             :fn (fn [data]
                   (tap> (r/submit
                           (r/as data
                                 (r/raw-string
                                   (format "[%1$tH:%1$tM:%1$tS.%1$tL %2$s:%3$s]: %4$s"
                                           (:instant data)
                                           (:?ns-str data)
                                           (:?line data)
                                           @(:msg_ data))
                                   {:fill ({:info :symbol
                                            :report :symbol
                                            :warn "#db8618"
                                            :error :error
                                            :fatal :error}
                                           (:level data)
                                           :util)})))))}}})

(comment
  (log/info "hi")
  (log/warn "bad")
  (log/error "very bad" (ex-info "nope" {:x 1})))
kelsey-sorrels/robinson
(ns robinson.autoplay
  (:require [robinson.common :as rc]
            [robinson.world :as rw]
            [robinson.npc :as rnpc]
            [robinson.player :as rp]
            [robinson.inventory :as ri]
            [taoensso.timbre :as log]))

(def last-key (atom \l))
(defmethod auto-input
  :normal
  [state]
  (let [adj-npcs (->> state
                   rnpc/npcs-in-viewport
                   (filter (fn [npc] (rw/adjacent-to-player? state (get npc :pos)))))]
    (loop []
      (let [next-key
        ; small chance to not attack monster
        (if (and (< (rand) 0.9)
                 (seq adj-npcs))
          (let [npc (first adj-npcs)
                dir (rc/find-point-relation-ext (rp/player-xy state) (rc/pos->xy (get npc :pos)))
                keyin (case dir
                        :right \l
                        :up-right \u
                        :up \k
                        :up-left \y
                        :left \h
                        :down-left \b
                        :down \j
                        :down-right \n)]
            (log/info "npc-pos" (get npc :pos))
            (log/info "player-pos" (rp/player-pos state))
              keyin)
          (rand-nth [\y \u \h \j \k \l \b \n \. :space
                     \a \e \i \f \z \q \w \W \C \@ \?
                     \t \d \m \/ \* \S \> \< \;]))]
      (if-not (= next-key @last-key)
        (do (reset! last-key next-key)
          next-key)
        (recur))))))
carneades/carneades-3
(ns eu.markosproject.licensing.oss-licensing-theory
  (:require  [carneades.engine.dublin-core :as dc]
             [carneades.engine.theory :as t]
             [carneades.engine.argument :as a]
             [carneades.engine.statement :as s]
             [carneades.owl.import :as owl]
             [carneades.project.fs :as project]
             [taoensso.timbre :as timbre :refer [debug error spy]]))

      (t/make-scheme
       :id 'gpl3-compatibility-with-gpl-le-2
       :header (dc/make-metadata
                :title "Compatiblity of the GPL-3.0 and GPL-LE-2.0 License Templates"
                :description {:en "The GPL-3.0 license template is
                presumably compatible with the earlier GPL-LE-2.0
                version. This presumption does not hold if the
                copyright owner of the software published using the
                GPL-LE-v2 license template did not include the option
                to apply later versions of the GPL in the copyright
                notice attached to the software. The copyright notice
                recommended by the Free Software Foundation includes
                this option. See the gpl3-compatibility-with-gpl2
                rule for further information."})
       :conclusion '(copyright:compatibleWith GPL-3.0 GPL-LE-2.0)
       :premises [])