On Sep 16, 2011, at 4:41 PM, Joern Huxhorn wrote:
> But what about tracing messages? Those could have a TraceMessageType
> (ENTERING, EXITING, THROWING).
> Shouldn't we add that to the Message interface, too, and just return null in
> case of every other Message implementation?
>
> Sorry about my sarcasm (and yes, that's only sarcasm. I'm not suggesting to
> add this to the Message interface ;)) but I just don't see the reason and
> rationale for those methods.
It may be sarcasm but I really could see logger.entry being implemented as
public void entry(Object... params) {
if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object) null, null)) {
log(ENTRY_MARKER, getFQCN(), Level.TRACE, new EntryMessage(params),
null);
}
}
public class EntryMessage extends SimpleMessage {
public EntryMessage(Object[] params) {
super(getMsg(params));
}
private String getMsg(Object[] params) {
if (params == null) {
return " entry";
}
StringBuilder sb = new StringBuilder(" entry parms(");
int i = 0;
for (Object parm : params) {
if (parm != null) {
sb.append(parm.toString());
} else {
sb.append("null");
}
if (++i < params.length) {
sb.append(", ");
}
}
sb.append(")");
return sb.toString();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]