|
25 | 25 | (format-body "Error data" (:data error))
|
26 | 26 | (format-body "Result" result)))
|
27 | 27 |
|
28 |
| -(defn ^:private format-header [at direction message-type header-details] |
29 |
| - (str (format-tag at) " " direction " " message-type " " header-details)) |
30 |
| - |
31 |
| -(defn ^:private basic-trace [at direction message-type header-details] |
32 |
| - [:debug |
33 |
| - (format-header at direction message-type header-details)]) |
34 |
| - |
35 |
| -(defn ^:private verbose-trace [at direction message-type header-details body] |
36 |
| - [:debug |
37 |
| - (str (format-header at direction message-type header-details) "\n" |
38 |
| - body "\n\n\n")]) |
39 |
| - |
40 | 28 | (defn ^:private latency [^java.time.Instant started ^java.time.Instant finished]
|
41 | 29 | (format "%sms" (- (.toEpochMilli finished) (.toEpochMilli started))))
|
42 | 30 |
|
|
47 | 35 | (latency started finished)
|
48 | 36 | (:message error) (:code error)))
|
49 | 37 |
|
50 |
| -(defn ^:private format-unmatched-notif-header-details [notif] |
51 |
| - (format "for unmatched request (%s):" (:id (:params notif)))) |
52 |
| - |
53 |
| -(defn ^:private verbose-notification [direction notif at] |
54 |
| - (verbose-trace at direction "notification" (format-notification-signature notif) |
55 |
| - (format-params notif))) |
56 |
| - |
57 |
| -(defn ^:private verbose-request [direction req at] |
58 |
| - (verbose-trace at direction "request" (format-request-signature req) |
59 |
| - (format-params req))) |
| 38 | +(defn ^:private basic-trace [at direction message-type header-details] |
| 39 | + (str (format-tag at) " " direction " " message-type " " header-details)) |
60 | 40 |
|
61 |
| -(defn ^:private verbose-response [direction req resp started finished] |
62 |
| - (verbose-trace finished direction "response" |
63 |
| - (format-response-header-details req resp started finished) |
64 |
| - (format-response-body resp))) |
| 41 | +(defn ^:private verbose-trace [header body] |
| 42 | + (str header "\n" body "\n\n\n")) |
65 | 43 |
|
66 | 44 | (defn ^:private basic-notification [direction notif at]
|
67 | 45 | (basic-trace at direction "notification" (format-notification-signature notif)))
|
|
72 | 50 | (defn ^:private basic-response [direction req resp started finished]
|
73 | 51 | (basic-trace finished direction "response" (format-response-header-details req resp started finished)))
|
74 | 52 |
|
| 53 | +(defn ^:private basic-received-unmatched-response [at] |
| 54 | + (basic-trace at "Received" "response" "for unmatched request")) |
| 55 | + |
| 56 | +(defn ^:private basic-received-unmatched-cancellation [at notif] |
| 57 | + (basic-trace at "Received" "cancellation notification" (format "for unmatched request (%s):" (:id (:params notif))))) |
| 58 | + |
| 59 | +(defn ^:private verbose-notification [direction notif at] |
| 60 | + (verbose-trace (basic-notification direction notif at) |
| 61 | + (format-params notif))) |
| 62 | + |
| 63 | +(defn ^:private verbose-request [direction req at] |
| 64 | + (verbose-trace (basic-request direction req at) |
| 65 | + (format-params req))) |
| 66 | + |
| 67 | +(defn ^:private verbose-response [direction req resp started finished] |
| 68 | + (verbose-trace (basic-response direction req resp started finished) |
| 69 | + (format-response-body resp))) |
| 70 | + |
75 | 71 | (defprotocol ITracer
|
76 | 72 | (received-notification [this notif at])
|
77 | 73 | (received-request [this req at])
|
|
91 | 87 | (received-response [_this req resp started finished]
|
92 | 88 | (verbose-response "Received" req resp started finished))
|
93 | 89 | (received-unmatched-response [_this resp at]
|
94 |
| - (verbose-trace at "Received" "response" "for unmatched request:" |
95 |
| - (format-body "Body" resp))) |
| 90 | + (verbose-trace (basic-received-unmatched-response at) (format-body "Body" resp))) |
96 | 91 | (received-unmatched-cancellation-notification [_this notif at]
|
97 |
| - (verbose-trace at "Received" "cancellation notification" (format-unmatched-notif-header-details notif) |
98 |
| - (format-params notif))) |
| 92 | + (verbose-trace (basic-received-unmatched-cancellation at notif) (format-params notif))) |
99 | 93 | (sending-notification [_this notif at]
|
100 | 94 | (verbose-notification "Sending" notif at))
|
101 | 95 | (sending-request [_this req at]
|
|
112 | 106 | (received-response [_this req resp started finished]
|
113 | 107 | (basic-response "Received" req resp started finished))
|
114 | 108 | (received-unmatched-response [_this _resp at]
|
115 |
| - (basic-trace at "Received" "response" "for unmatched request:")) |
| 109 | + (basic-received-unmatched-response at)) |
116 | 110 | (received-unmatched-cancellation-notification [_this notif at]
|
117 |
| - (basic-trace at "Received" "cancellation notification" (format-unmatched-notif-header-details notif))) |
| 111 | + (basic-received-unmatched-cancellation at notif)) |
118 | 112 | (sending-notification [_this notif at]
|
119 | 113 | (basic-notification "Sending" notif at))
|
120 | 114 | (sending-request [_this req at]
|
|
0 commit comments