Skip to content

Commit

Permalink
fix: invalid loggerName (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
duke-bartholomew authored Nov 26, 2020
1 parent f0a4623 commit ebfa1c0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.batch.escalog</groupId>
<artifactId>escalog</artifactId>
<version>1.1.4-KLARRIO</version>
<version>1.1.4-0.1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -57,7 +57,7 @@
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<version>2.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/batch/escalog/LogFmtLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public LogFmtLayout()
appenders.put(MESSAGE.toString(), this::msgAppender);
appenders.put(TNAME.toString(), this::threadAppender);
appenders.put(EXCEPTION.toString(), this::errorAppender);
appenders.put(LOGGER.toString(), this::classAppender);
appenders.put("custom", this::customFieldsAppender);
appenders.put(LOGGER.toString(), this::loggerAppender);
appenders.put("custom", this::customFieldsAppender);

this.defaultAppenders = new ArrayList<>(Arrays.asList(
this::timeAppender, this::levelAppender,this::threadAppender, this::classAppender, this::msgAppender, this::errorAppender, this::customFieldsAppender
this::timeAppender, this::levelAppender,this::threadAppender, this::loggerAppender, this::msgAppender, this::errorAppender, this::customFieldsAppender
));
}

Expand Down Expand Up @@ -150,6 +150,10 @@ public String doLayout(ILoggingEvent iLoggingEvent)
return sb.toString();
}

private void loggerAppender(StringBuilder sb, ILoggingEvent iLoggingEvent)
{
appendKeyValueAndEscape(sb, LOGGER.toString(), iLoggingEvent.getLoggerName());
}

private void levelAppender(StringBuilder sb, ILoggingEvent iLoggingEvent)
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/batch/escalog/LogFmtLayoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void logFmtLayoutTest()


assertEquals(
"prefix=\"prefix\" pname=escalog time=\"2017-11-30T15:10:25.123Z\" level=debug tname=thread0 msg=\"message with \\\"double quotes\\\"\" key1=value1 key2=\"val ue2\"\n",
"prefix=\"prefix\" pname=escalog time=\"2017-11-30T15:10:25.123Z\" level=debug tname=thread0 logger=loggerName msg=\"message with \\\"double quotes\\\"\" key1=value1 key2=\"val ue2\"\n",
logFmtLayout.doLayout(loggingEvent)
);

Expand All @@ -81,7 +81,7 @@ public void timeZoneTest()


assertEquals(
"prefix=\"prefix\" pname=escalog time=\"2017-11-30T11:10:25.123Z\" level=debug tname=thread0 msg=\"message with \\\"double quotes\\\"\" key1=value1 key2=\"val ue2\"\n",
"prefix=\"prefix\" pname=escalog time=\"2017-11-30T11:10:25.123Z\" level=debug tname=thread0 logger=loggerName msg=\"message with \\\"double quotes\\\"\" key1=value1 key2=\"val ue2\"\n",
logFmtLayout.doLayout(loggingEvent)
);

Expand Down

0 comments on commit ebfa1c0

Please sign in to comment.