You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2018/02/09 17:13:12 UTC

asterixdb git commit: [NO ISSUE][TEST] Use log4j for TestMethodTracer tracing

Repository: asterixdb
Updated Branches:
  refs/heads/master 841b8124b -> d41ce5403


[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>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/d41ce540
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/d41ce540
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/d41ce540

Branch: refs/heads/master
Commit: d41ce5403f9d69bb35c6c1ff822ee2906b8c30b3
Parents: 841b812
Author: Michael Blow <mb...@apache.org>
Authored: Fri Feb 9 12:11:47 2018 -0500
Committer: Michael Blow <mb...@apache.org>
Committed: Fri Feb 9 09:12:21 2018 -0800

----------------------------------------------------------------------
 .../asterix/test/base/TestMethodTracer.java     | 28 +++++++++++---------
 1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/d41ce540/asterixdb/asterix-common/src/test/java/org/apache/asterix/test/base/TestMethodTracer.java
----------------------------------------------------------------------
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());
     }
 }