On 27 July 2015 at 05:25, crocket <[email protected]> wrote:
> How those logs are outputted is stored in a global state called log
> configuration. So, I think the separation was done.
> How else do you want to separate that?
>
Traditionally, logging code is written something like:
(log/info "HTTP request to" (:request-method req) (:uri req))
So the priority of the log (info) and the formatting of the log line is
inlined into the source code.
A less complected piece of code would separate out what we want to monitor
(req) from how we monitor it. So inline we just write:
(monitor/monitor req :ring/request)
This monitors the variable req and associates it with the namespaced
keyword :ring/request. In our logging namespace, we can then later define
how we want to report on that monitor:
(monitor/add-reporter
:ring/request
(fn [req] (log/info "HTTP request to" (:request-method req) (:uri
req))))
This separates *what* we want to monitor from *how* we eventually log it.
It means we can do things like define a set of useful monitoring points in
a library, and then in a separate application decide on what's important.
- James
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.