Skip to content

Commit

Permalink
Merge pull request #98 from jamezp/LOGMGR-141
Browse files Browse the repository at this point in the history
[LOGMGR-141] Fix ending deletion length when truncating format parts.
  • Loading branch information
jamezp authored Jun 28, 2016
2 parents 521ea2f + c728e14 commit ef5f5f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void render(final StringBuilder builder, final ExtLogRecord record) {
final int overflow = writtenLen - maximumWidth;
if (overflow > 0) {
if (truncateBeginning) {
builder.delete(oldLen, overflow + 1);
builder.delete(oldLen, oldLen + overflow);
}
builder.setLength(newLen - overflow);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ public void truncation() throws Exception {

formatter = new PatternFormatter("%-5.10m");
Assert.assertEquals("test ", formatter.format(record));

// Exact length truncation
final String msg = "test message";
formatter = new PatternFormatter("%c %-5.-7m");
Assert.assertEquals(CATEGORY + " message", formatter.format(createLogRecord(msg)));
}

@Test
Expand Down

0 comments on commit ef5f5f4

Please sign in to comment.