Back

set-min-level! (clj)

(source)

function

(set-min-level! min-level)

Examples

juji-io/datalevin
(ns datalevin.server-test
  (:require [datalevin.server :as sut]
            [datalevin.client :as cl]
            [taoensso.timbre :as log]
            [datalevin.remote :as r]
            [datalevin.core :as d]
            [datalevin.constants :as c]
            [datalevin.util :as u]
            [datalevin.test.core :as tdc :refer [db-fixture]]
            [clojure.test :refer [deftest testing is use-fixtures]])
  (:import [java.util UUID]
           [java.nio.channels SocketChannel]
           [java.net Socket]
           [datalevin.client Client ConnectionPool Connection]))

(deftest reset-by-peer-test
  (let [dir             (u/tmp-dir (str "reset-test-" (UUID/randomUUID)))
        ^Server server  (sut/create {:port c/default-port
                                     :root dir})
        _               (sut/start server)
        ^Client client1 (cl/new-client "dtlv://datalevin:datalevin@localhost"
                                       {:pool-size 1 :time-out 100})
        ^Client client2 (cl/new-client "dtlv://datalevin:datalevin@localhost")]
    (log/set-min-level! :report)
    (is (= (cl/list-databases client1) []))
    (is (= (cl/list-databases client2) []))

(deftest server-restart-kv-test
  (let [dir            "dtlv://datalevin:datalevin@localhost/server-restart-test"
        root           (u/tmp-dir
                         (str "server-restart-kv-test-" (UUID/randomUUID)))
        ^Server server (sut/create {:port c/default-port :root root})
        _              (sut/start server)
        lmdb           (d/open-kv dir)
        engine         (d/new-search-engine lmdb)
        ^Client client (cl/new-client "dtlv://datalevin:datalevin@localhost"
                                      {:pool-size 1 :time-out 2000})]
    (log/set-min-level! :report)
    (is (= (cl/list-databases client) ["server-restart-test"]))


      (log/set-min-level! :report)
      (is (= (cl/list-databases client) ["server-restart-test"]))

    (log/set-min-level! :report)
    (d/transact! conn [{:name "John" :id 2}
                       {:name "Matt" :id 3}])
    (is (= 2 (d/q '[:find ?i .
                    :in $ ?n
                    :where
                    [?e :name ?n]
                    [?e :id ?i]] (d/db conn) "John")))
    (sut/stop server)

      (log/set-min-level! :report)
      (is (= 2 (d/q '[:find ?i .
                      :in $ ?n
                      :where
                      [?e :name ?n]
                      [?e :id ?i]] (d/db conn) "John")))

    (log/set-min-level! :report)
    (d/transact! conn [{:name "John" :id 2}
                       {:name "Matt" :id 3}])
    (is (thrown? Exception
                 (d/q '[:find ?i ?j
                        :in $ ?n
                        :where
                        [(/ 3 0) ?j]
                        [?e :name ?n]
                        [?e :id ?i]] (d/db conn) "John")))

    (log/set-min-level! :report)
    (is (= (cl/list-databases client) []))
    (sut/stop server1)
    (is (thrown? Exception (cl/list-databases client)))
    (let [server2 (sut/create {:port c/default-port
                               :root root})
          _       (sut/start server2)]

      (log/set-min-level! :report)
      (is (= (cl/list-databases client) []))
      (sut/stop server2))
    (u/delete-files root)))

(deftest idle-timeout-test
  (let [root    (u/tmp-dir (str "idle-timeout-test-" (UUID/randomUUID)))
        server  (sut/create {:port         c/default-port
                             :root         root
                             :idle-timeout 100})
        _       (sut/start server)
        client1 (cl/new-client "dtlv://datalevin:datalevin@localhost")
        client2 (cl/new-client "dtlv://datalevin:datalevin@localhost")
        db      (r/open-kv
                  client2
                  "dtlv://datalevin:datalevin@localhost/db?store=kv"
                  {})]
    ;; (log/set-min-level! :report)
    (d/open-dbi db "a")
    (d/transact-kv db [[:put "a" 1 1]])
    (Thread/sleep 1000)
    (is (= 1 (count (cl/show-clients client1))))
    (is (= 1 (d/get-value db "a" 1)))
    (sut/stop server)
    (u/delete-files root)))
lgessler/glam
(ns glam.client.development-preload
  (:require
    [com.fulcrologic.fulcro.algorithms.timbre-support :as ts]
    [taoensso.timbre :as log]))

(js/console.log "Turning logging to :debug (in app.development-preload)")
(log/set-min-level! :debug)
(log/merge-config! {:output-fn ts/prefix-output-fn
                    :appenders {:console (ts/console-appender)}})
fulcrologic/fulcro-native-template
(ns app.development-preload
  (:require
    [com.fulcrologic.fulcro.algorithms.timbre-support :as ts]
    [taoensso.timbre :as log]))

(js/console.log "Turning logging to :debug (in app.development-preload)")
(log/set-min-level! :debug)
(log/merge-config! {:output-fn ts/prefix-output-fn
                    :appenders {:console (ts/console-appender)}})