fix Logging test for tails=true build

In the tails=true build, the calling method cannot always be
determined due to stack frames being optimized away, so we must be
prepared for LogRecord.getSourceMethodName to return null.
This commit is contained in:
Joel Dice 2011-08-05 18:04:38 -06:00
parent 792653e190
commit 5dbcbb825b

View File

@ -49,8 +49,12 @@ public class Logging {
StringBuilder sb = new StringBuilder();
sb.append(r.getLoggerName());
indent(sb, NAME_WIDTH - r.getLoggerName().length());
sb.append(r.getSourceMethodName());
indent(sb, METHOD_WIDTH - r.getSourceMethodName().length());
String methodName = r.getSourceMethodName();
if (methodName == null) {
methodName = "<unknown>";
}
sb.append(methodName);
indent(sb, METHOD_WIDTH - methodName.length());
sb.append(r.getLevel().getName());
indent(sb, LEVEL_WIDTH - r.getLevel().getName().length());
sb.append(r.getMessage());