You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/12/27 21:54:43 UTC

[GitHub] [logging-log4j2] ppkarwasz commented on a diff in pull request #1171: [LOG4J2-3645] Minimal changes to allow flow tracing with LogBuilder

ppkarwasz commented on code in PR #1171:
URL: https://github.com/apache/logging-log4j2/pull/1171#discussion_r1057930722


##########
log4j-api-test/src/test/java/org/apache/logging/log4j/LoggerTest.java:
##########
@@ -203,11 +191,18 @@ public String get() {
             }
         });
         logger.traceExit(msg, 3);
-        assertEquals(2, results.size());
-        assertThat("Incorrect Entry", results.get(0), startsWith("ENTER[ FLOW ] TRACE Enter"));
-        assertThat("Missing entry data", results.get(0), containsString("doFoo(a=1, b=2)"));
-        assertThat("Incorrect Exit", results.get(1), startsWith("EXIT[ FLOW ] TRACE Exit"));
-        assertThat("Missing exit data", results.get(1), containsString("doFoo(a=1, b=2): 3"));
+        assertThat(results).hasSize(2);
+        assertThat(results.get(0)).startsWith("ENTER[ FLOW ] TRACE Enter").contains("doFoo(a=1, b=2)");
+        assertThat(results.get(1)).startsWith("EXIT[ FLOW ] TRACE Exit").contains("doFoo(a=1, b=2): 3");
+    }
+
+    @Test
+    public void flowTracingNoFormat() {
+        logger.traceEntry(null, 1, "2", new ObjectMessage(3));
+        logger.traceExit((String) null, 4);
+        assertThat(results).hasSize(2);
+        assertThat(results.get(0)).isEqualTo("ENTER[ FLOW ] TRACE Enter with params: [1, 2, 3]");
+        assertThat(results.get(1)).isEqualTo("EXIT[ FLOW ] TRACE Exit with: 3");

Review Comment:
   The previous code printed "Enter param(1, 2, 3)", but used a format that depended on the number of parameters. The current code uses a `ParameterizedMessage("params: {}", (Object) params)`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org