-
Notifications
You must be signed in to change notification settings - Fork 1
/
log.cljc
112 lines (92 loc) · 3.41 KB
/
log.cljc
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
(ns prpr3.a-frame.log
"overrides of the timbre logging macros
which set a context from an a-frame
interceptor-context key, or app-ctx key"
#?(:cljs (:require-macros [prpr3.a-frame.log]))
(:require
[taoensso.timbre :as timbre]
[prpr3.a-frame.schema :as af.schema]))
(defmacro with-a-frame-log-context
[context-src & body]
`(do
(when (not (map? ~context-src))
(throw
(ex-info
"context-src must be a map"
{:context-src ~context-src})))
(timbre/with-context (get ~context-src af.schema/a-frame-log-ctx)
~@body)))
;;; Log using print-style args
(defmacro log*
[context-src config level & args]
`(with-a-frame-log-context ~context-src
(timbre/log! ~level :p ~args ~{:?line (@#'timbre/fline &form) :config config})))
(defmacro log
[context-src level & args]
`(with-a-frame-log-context ~context-src
(timbre/log! ~level :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro trace
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :trace :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro debug
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :debug :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro info
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :info :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro warn
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :warn :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro error
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :error :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro fatal
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :fatal :p ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro report
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :report :p ~args ~{:?line (@#'timbre/fline &form)})))
;;; Log using format-style args
(defmacro logf*
[context-src config level & args]
`(with-a-frame-log-context ~context-src
(timbre/log! ~level :f ~args ~{:?line (@#'timbre/fline &form) :config config})))
(defmacro logf
[context-src level & args]
`(with-a-frame-log-context ~context-src
(timbre/log! ~level :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro tracef
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :trace :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro debugf
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :debug :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro infof
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :info :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro warnf
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :warn :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro errorf
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :error :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro fatalf
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :fatal :f ~args ~{:?line (@#'timbre/fline &form)})))
(defmacro reportf
[context-src & args]
`(with-a-frame-log-context ~context-src
(timbre/log! :report :f ~args ~{:?line (@#'timbre/fline &form)})))