-
Notifications
You must be signed in to change notification settings - Fork 7
/
api.clj
41 lines (32 loc) · 1.3 KB
/
api.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(ns org.purefn.kurosawa.log.api
(:require [clojure.spec.alpha :as s]
[org.purefn.kurosawa.log.protocol :as proto]))
;;------------------------------------------------------------------------------
;; Logging API
;;------------------------------------------------------------------------------
(defn log-namespaces
"A sequence of one or more string patterns matching the namespaces of
low-level loggers associated with the component."
[comp]
(if (satisfies? proto/Logging comp)
(proto/log-namespaces comp)
[]))
(defn log-configure
"Returns a function which when applied to the Timbre logging configuration
will return a new configuration, possibly modified.
- `dir` The root logging directory."
[comp dir]
(if (satisfies? proto/Logging comp)
(proto/log-configure comp dir)
identity))
;;------------------------------------------------------------------------------
;; Specs
;;------------------------------------------------------------------------------
(def logger? (partial satisfies? proto/Logging))
(s/fdef log-namespaces
:args (s/cat :comp logger?)
:ret (s/coll-of string? :kind vector?))
(s/fdef log-configure
:args (s/cat :comp logger? :dir string?)
:ret (s/fspec :args (s/cat :config map?)
:ret map?))