I would like to conditionally generate log statements based on run-time checks 
of various application-specific info.

I note  the following:

Logging levels are specified by clojure keywords corresponding to the values 
used in log4j and commons-logging:
:trace, :debug, :info, :warn, :error, :fatal
log
macro
Usage: (log level message)
…
Evaluates and logs a message only if the specified level is enabled. 

So, it occurs to me that for the level argument to log, I could pass in a 
function that would figure out if I really wanted to log anything right then, 
or not.

In the case that I *do* want to log something, that function would return the 
log level, e.g. :info  (this part seems to work fine…)

But what could my function return if it didn't want anything to be logged at 
this point?

Any log level beneath the current level in effect would seem to work, but 
figuring that out feels hackish, and what if the lowest level of logging 
(:trace ?) is enabled, then what?
Nil and/or false did not work at all in my test!

Is there something like a :noop level, that would never be enabled, and could 
be returned by my function whenever it decided it did not want the log to 
happen?

Obviously/alternately I could wrap all my logging in

        (when (log-decision args) (log :level "message"))

But right now I'd rather do all this with just the log call,and I'm hoping 
there is already a way to do what I ask above, or if not, willingness to add 
something like a :noop level 

Don









-- 
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

Reply via email to