Skip to content

Commit

Permalink
[LOGMGR-204] Fix short host name to be first instead of last part
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Oct 2, 2018
1 parent 496e7bc commit 79131e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static FormatStep[] getSteps(final String formatString, ColorMap colors)
break;
}
case 'h': {
stepList.add(Formatters.hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, argument == null ? "1" : argument));
stepList.add(Formatters.hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, false));
break;
}
case 'H': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,13 @@ public void renderRaw(final StringBuilder builder, final ExtLogRecord record) {
* @return the format step
*/
public static FormatStep hostnameFormatStep(final boolean leftJustify, final int minimumWidth, final boolean truncateBeginning, final int maximumWidth, final boolean qualified) {
return hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, qualified ? null : "1");
return qualified ? hostnameFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) : new SegmentedFormatStep(leftJustify, minimumWidth, truncateBeginning, maximumWidth, null) {
public String getSegmentedSubject(final ExtLogRecord record) {
final String hostName = record.getHostName();
final int idx = hostName.indexOf('.');
return idx == -1 ? hostName :hostName.substring(0, idx);
}
};
}

/**
Expand Down

0 comments on commit 79131e8

Please sign in to comment.