Small adjustments for logging.

This commit is contained in:
asofold 2012-09-30 13:54:26 +02:00
parent aecf3a6f1f
commit 4a26f741df
2 changed files with 13 additions and 5 deletions

View File

@ -59,13 +59,20 @@ public abstract class ActionWithParameters extends Action {
*/
protected String getMessage(final ViolationData violationData) {
// Should be big enough most of the time.
final StringBuilder log = new StringBuilder(100);
final StringBuilder log = new StringBuilder(150);
for (final Object part : messageParts)
if (part instanceof String)
log.append((String) part);
else
log.append(violationData.getParameter((ParameterName) part));
else if (part == null) log.append("[???]");
else{
try{
log.append(violationData.getParameter((ParameterName) part));
}
catch (Exception e){
log.append(part.toString());
}
}
return log.toString();
}
@ -89,7 +96,7 @@ public abstract class ActionWithParameters extends Action {
if (parts2.length != 2)
messageParts.add(message);
else {
final ParameterName w = ParameterName.get(parts2[0]);
final ParameterName w = ParameterName.get(parts2[0].toLowerCase());
if (w != null) {
// Found an existing wildcard inbetween the braces.

View File

@ -131,13 +131,14 @@ public class ViolationData {
* @return Will always return some string, if not set: "<?PARAMETERNAME>".
*/
public String getParameter(final ParameterName parameterName){
if (parameterName == null) return "<???>";
switch (parameterName) {
case CHECK:
return check.getClass().getSimpleName();
case PLAYER:
return player.getName();
case VIOLATIONS:
return String.valueOf(Math.round(vL));
return String.valueOf((long) Math.round(vL));
default:
break;
}