solder logging v seam 2 logging
andyredhead Jan 5, 2012 4:16 AMHi,
I've spent some time working with Seam 2.x and am starting to play with CDI\Weld and Seam 3.
I was looking for a sensible way to do some simple logging from my classes and thought solder logging would fit the bill.
Having looked at the code for solder logging I have a couple of questions about the design of solder logging...
In Seam 2.x you can use @Logger to get an instance of seam 2 Log, which turns out to be an instance of LogImp, this class has methods such as:
public void debug(Object object, Object... params)
{
if ( isDebugEnabled() )
{
log.debug( interpolate(object, params) );
}
}
public void debug(Object object, Throwable t, Object... params)
{
if ( isDebugEnabled() )
{
log.debug( interpolate(object, params), t );
}
}I like this because it means I don't need to write all if debug enabled
guards around my debug statements.
Looking at solder Logger, there is code such as:
/**
* Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting.
*
* @param t the throwable
* @param format the message format string
* @param params the parameters
*/
public void tracev(Throwable t, String format, Object... params) {
doLog(Level.TRACE, FQCN, format, params, t);
}
/**
* Issue a log message with a level of TRACE using {@link java.text.MessageFormat}-style formatting.
*
* @param t the throwable
* @param format the message format string
* @param param1 the sole parameter
*/
public void tracev(Throwable t, String format, Object param1) {
if (isEnabled(Level.TRACE)) {
doLog(Level.TRACE, FQCN, format, new Object[] { param1 }, t);
}
} The key point being that some methods check that the requested log level is being recorded and others do not.
I can't work out why!
I had assumed that all the log methods would check to make sure that the log message would be recorded before pressing on with all the string manipulation (as seam 2 logging does).
Can anyone explain to me why solder logging sometimes checks the log level and sometimes doesn't?
Apologies if I've missed some obvious doco on the net, I have tried googling but didn't find anything.
Further apologies if this is the wrong forum - I wasn't sure if I should post here or in the weld forum.
Thanks, Andy