Michael Blow has submitted this change and it was merged.

Change subject: [NO ISSUE][TEST] Use log4j for TestMethodTracer tracing
......................................................................


[NO ISSUE][TEST] Use log4j for TestMethodTracer tracing

Change-Id: I9d1ebc072e9d0d5d3930a0eb3cb6d884af4d5b06
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2374
Reviewed-by: Michael Blow <mb...@apache.org>
Contrib: Michael Blow <mb...@apache.org>
Integration-Tests: Michael Blow <mb...@apache.org>
Tested-by: Michael Blow <mb...@apache.org>
---
M 
asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
1 file changed, 16 insertions(+), 12 deletions(-)

Approvals:
  Michael Blow: Looks good to me, approved; Verified; No violations found; 
Verified



diff --git 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
index 692805f..b762517 100644
--- 
a/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
+++ 
b/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
@@ -18,45 +18,49 @@
  */
 package org.apache.asterix.test.base;
 
-import java.io.PrintStream;
-
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
 
 /*
- * Traces method entry/exit to System.out (or supplied PrintStream).  To use, 
add the following to your test class:
+ * Traces method entry/exit to Log4j2 at org.apache.logging.log4j.Level.WARN 
(or supplied) level.  To use,
+ * add the following to your test class:
  *
+ * <code>
  *   @Rule
  *   public TestRule watcher = new TestMethodTracer();
  *
  *   @Rule
- *   public TestRule watcher = new TestMethodTracer(System.err);
+ *   public TestRule watcher = new TestMethodTracer(Level.INFO);
+ * </code>
  */
 
 public class TestMethodTracer extends TestWatcher {
+    private static final Logger LOGGER = LogManager.getLogger();
+    private final Level level;
 
-    private final PrintStream out;
-
-    public TestMethodTracer(PrintStream out) {
-        this.out = out;
+    public TestMethodTracer(Level level) {
+        this.level = level;
     }
 
     public TestMethodTracer() {
-        this(System.out);
+        this(Level.WARN);
     }
 
     @Override
     protected void starting(Description description) {
-        out.println("## " + description.getMethodName() + " START");
+        LOGGER.log(level, "### {} START", description.getMethodName());
     }
 
     @Override
     protected void failed(Throwable e, Description description) {
-        out.println("## " + description.getMethodName() + " FAILED (" + 
e.getClass().getName() + ")");
+        LOGGER.log(level, "### {} FAILED ({})", description.getMethodName(), 
e.getClass().getName());
     }
 
     @Override
     protected void succeeded(Description description) {
-        out.println("## " + description.getMethodName() + " SUCCEEDED");
+        LOGGER.log(level, "### {} SUCCEEDED", description.getMethodName());
     }
 }

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2374
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9d1ebc072e9d0d5d3930a0eb3cb6d884af4d5b06
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Murtadha Hubail <mhub...@apache.org>

Reply via email to