Hi,

logging is a side-effect and I try to keep it out of the functional parts 
of my code.

But even for the parts where I want to introduce logging I find that it 
renders code less readable.


As an example, say you've got an 'if-let' somewhere

(if-let [a (do-something-non-trivial-with-some-local-args)]
  (make-use-of-a)
  (return-a-reasonable-default))

That piece of code is concise, readable, nicely indented, etc.  However, 
when logging comes along, it becomes ugly quickly, at least to my eye:


(if-let [a (do-something-non-trivial-with-some-local-args)]
  (do (log/debug "got a reasonable a:" a)
      (make-use-of-a))
  (do (log/warn "using a dangerous default")
      (return-a-reasonable-default)))

I wonder, how you deal with such situations.  Do you get rid of all those 
do's, e.g. with a 'logged' ('debugged', 'warned', etc) macro which takes 
some logging args and a body in any way? Do you wrap functions in 
tracing-like logging entities and log e.g. at the level of '
do-something-non-trivial-with-some-local-args'? Or are you just happy with 
the 'do'?

The only other thread I could find on this list which discussed related 
issues was https://groups.google.com/d/msg/clojure/B2Wo5Oe1OrI/Y_eznCx3R7YJ 
and I will think a bit about Herwig's reader tag approach.


Regards,
stefan

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to