add logp methods to Logger

This commit is contained in:
Zsombor
2009-02-16 18:11:05 -07:00
committed by Joel Dice
parent 7c1a5fe57d
commit 8c68bc0e1b

View File

@ -67,6 +67,21 @@ public class Logger {
log(level, Method.getCaller(), message, exception); log(level, Method.getCaller(), message, exception);
} }
public void logp(Level level, String sourceClass, String sourceMethod, String msg) {
if (!isLoggable(level)) {
return;
}
publish(new LogRecord(name, sourceMethod, level, msg, null));
}
public void logp(Level level, String sourceClass, String sourceMethod,
String msg, Throwable thrown) {
if (!isLoggable(level)) {
return;
}
publish(new LogRecord(name, sourceMethod, level, msg, thrown));
}
private void log(Level level, Method caller, String message, private void log(Level level, Method caller, String message,
Throwable exception) { Throwable exception) {
if (level.intValue()<levelValue) { if (level.intValue()<levelValue) {
@ -74,8 +89,12 @@ public class Logger {
} }
LogRecord r = new LogRecord(name, caller.getName(), level, message, LogRecord r = new LogRecord(name, caller.getName(), level, message,
exception); exception);
publish(r);
}
private void publish(LogRecord logRecord) {
for (Handler h : handlers) { for (Handler h : handlers) {
h.publish(r); h.publish(logRecord);
} }
} }