parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject parquet-mr git commit: PARQUET-305: Update logging to SLF4J.
Date Tue, 08 Dec 2015 18:39:56 GMT
Repository: parquet-mr
Updated Branches:
  refs/heads/master dcd1c33f0 -> a24d624aa


PARQUET-305: Update logging to SLF4J.

This removes the Log implementation based on java.util.logging and
replaces it with SLF4J. The compiler removal of debug log messages still
works because Log.DEBUG and similar final constants are unchanged.

This commit adds slf4j-simple as the test logger implementation.
Configuration for slf4j-simple is in the root pom. Two modules can't use
slf4j-simple, parquet-pig and parquet-thrift, and use slf4j-log4j12
instead because pig depends on log4j and tests die without it.

Author: Ryan Blue <blue@apache.org>

Closes #290 from rdblue/PARQUET-305-update-logging and squashes the following commits:

89257e8 [Ryan Blue] PARQUET-305: Remove deprecation annotations on Log.
9f9b99a [Ryan Blue] PARQUET-305: Update logging to SLF4J.


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

Branch: refs/heads/master
Commit: a24d624aaabc14a455d18450d9127f88d1b4f8be
Parents: dcd1c33
Author: Ryan Blue <blue@apache.org>
Authored: Tue Dec 8 10:39:47 2015 -0800
Committer: Ryan Blue <blue@apache.org>
Committed: Tue Dec 8 10:39:47 2015 -0800

----------------------------------------------------------------------
 parquet-avro/pom.xml                            |  6 ++
 parquet-benchmarks/pom.xml                      |  6 ++
 parquet-cascading/pom.xml                       |  6 --
 parquet-column/pom.xml                          |  6 ++
 parquet-common/pom.xml                          | 21 ++++-
 .../src/main/java/org/apache/parquet/Log.java   | 87 ++++----------------
 parquet-encoding/pom.xml                        |  7 ++
 parquet-hadoop/pom.xml                          | 31 +++----
 parquet-pig/pom.xml                             | 12 +--
 parquet-protobuf/pom.xml                        |  6 ++
 parquet-scala/pom.xml                           |  6 ++
 parquet-scrooge/pom.xml                         |  6 --
 parquet-thrift/pom.xml                          | 12 +--
 parquet-tools/pom.xml                           |  5 ++
 pom.xml                                         | 11 ++-
 15 files changed, 112 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-avro/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-avro/pom.xml b/parquet-avro/pom.xml
index eb8d3b1..9434343 100644
--- a/parquet-avro/pom.xml
+++ b/parquet-avro/pom.xml
@@ -81,6 +81,12 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-benchmarks/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-benchmarks/pom.xml b/parquet-benchmarks/pom.xml
index f0deba3..ae50b5b 100644
--- a/parquet-benchmarks/pom.xml
+++ b/parquet-benchmarks/pom.xml
@@ -63,6 +63,12 @@
         <version>${jmh.version}</version>
         <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-cascading/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-cascading/pom.xml b/parquet-cascading/pom.xml
index 81b955c..0cd8588 100644
--- a/parquet-cascading/pom.xml
+++ b/parquet-cascading/pom.xml
@@ -68,12 +68,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>${log4j.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.apache.parquet</groupId>
       <artifactId>parquet-column</artifactId>
       <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-column/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-column/pom.xml b/parquet-column/pom.xml
index f2a0f4c..ccceafa 100644
--- a/parquet-column/pom.xml
+++ b/parquet-column/pom.xml
@@ -77,6 +77,12 @@
       <version>1.3.149</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-common/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-common/pom.xml b/parquet-common/pom.xml
index 6697e3b..d4fb8ee 100644
--- a/parquet-common/pom.xml
+++ b/parquet-common/pom.xml
@@ -37,10 +37,23 @@
 
   <dependencies>
     <dependency>
-        <groupId>org.semver</groupId>
-        <artifactId>api</artifactId>
-        <version>${semver.api.version}</version>
-        <scope>test</scope>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${slf4j.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.semver</groupId>
+      <artifactId>api</artifactId>
+      <version>${semver.api.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-common/src/main/java/org/apache/parquet/Log.java
----------------------------------------------------------------------
diff --git a/parquet-common/src/main/java/org/apache/parquet/Log.java b/parquet-common/src/main/java/org/apache/parquet/Log.java
index a39f4b2..e05465b 100644
--- a/parquet-common/src/main/java/org/apache/parquet/Log.java
+++ b/parquet-common/src/main/java/org/apache/parquet/Log.java
@@ -18,16 +18,9 @@
  */
 package org.apache.parquet;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-import java.util.logging.StreamHandler;
 
 /**
  * Simple wrapper around java.util.logging
@@ -53,61 +46,11 @@ public class Log {
   public static final boolean WARN = (LEVEL.intValue() <= Level.WARNING.intValue());
   public static final boolean ERROR = (LEVEL.intValue() <= Level.SEVERE.intValue());
 
-  static {
-    // add a default handler in case there is none
-    Logger logger = Logger.getLogger(Log.class.getPackage().getName());
-    Handler[] handlers = logger.getHandlers();
-    if (handlers == null || handlers.length == 0) {
-      logger.setUseParentHandlers(false);
-      StreamHandler handler = new StreamHandler(System.out, new Formatter() {
-        Date dat = new Date();
-        private final static String format = "{0,date} {0,time}";
-        private MessageFormat formatter = new MessageFormat(format);
-
-        private Object args[] = new Object[1];
-
-        /**
-         * Format the given LogRecord.
-         * @param record the log record to be formatted.
-         * @return a formatted log record
-         */
-        public synchronized String format(LogRecord record) {
-          StringBuffer sb = new StringBuffer();
-          // Minimize memory allocations here.
-          dat.setTime(record.getMillis());
-          args[0] = dat;
-          formatter.format(args, sb, null);
-          sb.append(" ");
-          sb.append(record.getLevel().getLocalizedName());
-          sb.append(": ");
-          sb.append(record.getLoggerName());
-
-          sb.append(": ");
-          sb.append(formatMessage(record));
-          sb.append("\n");
-          if (record.getThrown() != null) {
-            try {
-              StringWriter sw = new StringWriter();
-              PrintWriter pw = new PrintWriter(sw);
-              record.getThrown().printStackTrace(pw);
-              pw.close();
-              sb.append(sw.toString());
-            } catch (Exception ex) {
-            }
-          }
-          return sb.toString();
-        }
-      });
-      handler.setLevel(LEVEL);
-      logger.addHandler(handler);
-    }
-    logger.setLevel(LEVEL);
-  }
-
   /**
    *
    * @param c the current class
    * @return the corresponding logger
+   * @deprecated will be removed in 2.0.0; use org.slf4j.LoggerFactory instead.
    */
   public static Log getLog(Class<?> c) {
     return new Log(c);
@@ -116,7 +59,7 @@ public class Log {
   private Logger logger;
 
   public Log(Class<?> c) {
-    this.logger = Logger.getLogger(c.getName());
+    this.logger = LoggerFactory.getLogger(c);
   }
 
   /**
@@ -125,9 +68,9 @@ public class Log {
    */
   public void debug(Object m) {
     if (m instanceof Throwable) {
-      logger.log(Level.FINE, "", (Throwable)m);
+      logger.debug("", (Throwable) m);
     } else {
-      logger.fine(String.valueOf(m));
+      logger.debug(String.valueOf(m));
     }
   }
 
@@ -137,7 +80,7 @@ public class Log {
    * @param t
    */
   public void debug(Object m, Throwable t) {
-    logger.log(Level.FINE, String.valueOf(m), t);
+    logger.debug(String.valueOf(m), t);
   }
 
   /**
@@ -146,7 +89,7 @@ public class Log {
    */
   public void info(Object m) {
     if (m instanceof Throwable) {
-      logger.log(Level.INFO, "", (Throwable)m);
+      logger.info("", (Throwable) m);
     } else {
       logger.info(String.valueOf(m));
     }
@@ -158,7 +101,7 @@ public class Log {
    * @param t
    */
   public void info(Object m, Throwable t) {
-    logger.log(Level.INFO, String.valueOf(m), t);
+    logger.info(String.valueOf(m), t);
   }
 
   /**
@@ -167,9 +110,9 @@ public class Log {
    */
   public void warn(Object m) {
     if (m instanceof Throwable) {
-      logger.log(Level.WARNING, "", (Throwable)m);
+      logger.warn("", (Throwable) m);
     } else {
-      logger.warning(String.valueOf(m));
+      logger.warn(String.valueOf(m));
     }
   }
 
@@ -179,7 +122,7 @@ public class Log {
    * @param t
    */
   public void warn(Object m, Throwable t) {
-    logger.log(Level.WARNING, String.valueOf(m), t);
+    logger.warn(String.valueOf(m), t);
   }
 
   /**
@@ -188,9 +131,9 @@ public class Log {
    */
   public void error(Object m) {
     if (m instanceof Throwable) {
-      logger.log(Level.SEVERE, "", (Throwable)m);
+      logger.error("", (Throwable) m);
     } else {
-      logger.warning(String.valueOf(m));
+      logger.error(String.valueOf(m));
     }
   }
 
@@ -200,7 +143,7 @@ public class Log {
    * @param t
    */
   public void error(Object m, Throwable t) {
-    logger.log(Level.SEVERE, String.valueOf(m), t);
+    logger.error(String.valueOf(m), t);
   }
 
 }

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-encoding/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-encoding/pom.xml b/parquet-encoding/pom.xml
index 7765535..f872374 100644
--- a/parquet-encoding/pom.xml
+++ b/parquet-encoding/pom.xml
@@ -47,6 +47,13 @@
       <version>1.5</version>
       <scope>compile</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-hadoop/pom.xml b/parquet-hadoop/pom.xml
index 2f2e932..4c43182 100644
--- a/parquet-hadoop/pom.xml
+++ b/parquet-hadoop/pom.xml
@@ -53,12 +53,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>${log4j.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.apache.parquet</groupId>
       <artifactId>parquet-jackson</artifactId>
       <version>${project.version}</version>
@@ -74,12 +68,6 @@
       <version>${jackson.version}</version>
     </dependency>
     <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-      <version>11.0</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>org.xerial.snappy</groupId>
       <artifactId>snappy-java</artifactId>
       <version>1.1.1.6</version>
@@ -87,15 +75,28 @@
       <scope>compile</scope>
     </dependency>
     <dependency>
+      <groupId>commons-pool</groupId>
+      <artifactId>commons-pool</artifactId>
+      <version>1.5.4</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>11.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
       <version>1.9.5</version>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-pool</groupId>
-      <artifactId>commons-pool</artifactId>
-      <version>1.5.4</version>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-pig/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-pig/pom.xml b/parquet-pig/pom.xml
index afab22d..9b6371e 100644
--- a/parquet-pig/pom.xml
+++ b/parquet-pig/pom.xml
@@ -80,12 +80,6 @@
       <version>${jackson.version}</version>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>${log4j.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.apache.parquet</groupId>
       <artifactId>parquet-column</artifactId>
       <version>${project.version}</version>
@@ -110,6 +104,12 @@
       <version>11.0</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-protobuf/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-protobuf/pom.xml b/parquet-protobuf/pom.xml
index 55c38fe..b3e4e50 100644
--- a/parquet-protobuf/pom.xml
+++ b/parquet-protobuf/pom.xml
@@ -76,6 +76,12 @@
       <version>${hadoop.version}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <developers>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-scala/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-scala/pom.xml b/parquet-scala/pom.xml
index 9b842e1..38ceb1b 100644
--- a/parquet-scala/pom.xml
+++ b/parquet-scala/pom.xml
@@ -64,6 +64,12 @@
       <version>2.2.1</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-scrooge/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-scrooge/pom.xml b/parquet-scrooge/pom.xml
index 244302d..7e587f1 100644
--- a/parquet-scrooge/pom.xml
+++ b/parquet-scrooge/pom.xml
@@ -67,12 +67,6 @@
       <version>${jackson.version}</version>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>${log4j.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.apache.parquet</groupId>
       <artifactId>parquet-column</artifactId>
       <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-thrift/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-thrift/pom.xml b/parquet-thrift/pom.xml
index fd4668b..2583870 100644
--- a/parquet-thrift/pom.xml
+++ b/parquet-thrift/pom.xml
@@ -79,12 +79,6 @@
       <version>${jackson.version}</version>
     </dependency>
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>${log4j.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>org.apache.parquet</groupId>
       <artifactId>parquet-column</artifactId>
       <version>${project.version}</version>
@@ -121,6 +115,12 @@
       <version>${thrift.version}</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>test</scope>
+    </dependency>
 
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/parquet-tools/pom.xml
----------------------------------------------------------------------
diff --git a/parquet-tools/pom.xml b/parquet-tools/pom.xml
index e7cfbb7..5d3f7c9 100644
--- a/parquet-tools/pom.xml
+++ b/parquet-tools/pom.xml
@@ -72,6 +72,11 @@
       <artifactId>guava</artifactId>
       <version>11.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j.version}</version>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/parquet-mr/blob/a24d624a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c769ad3..3588de5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,7 +80,6 @@
     <hadoop.version>1.1.0</hadoop.version>
     <cascading.version>2.5.3</cascading.version>
     <parquet.format.version>2.3.0-incubating</parquet.format.version>
-    <log4j.version>1.2.17</log4j.version>
     <previous.version>1.7.0</previous.version>
     <thrift.executable>thrift</thrift.executable>
     <scala.version>2.10.4</scala.version>
@@ -352,6 +351,16 @@
         <version>2.10</version>
         <configuration>
           <argLine>-Xmx512m</argLine>
+          <systemPropertyVariables>
+            <!-- Configure Parquet logging during tests
+                 See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
+                 -->
+            <org.slf4j.simpleLogger.defaultLogLevel>info</org.slf4j.simpleLogger.defaultLogLevel>
+            <org.slf4j.simpleLogger.showDateTime>true</org.slf4j.simpleLogger.showDateTime>
+            <org.slf4j.simpleLogger.dateTimeFormat>YYYY-MM-dd HH:mm:ss</org.slf4j.simpleLogger.dateTimeFormat>
+            <org.slf4j.simpleLogger.showThreadName>false</org.slf4j.simpleLogger.showThreadName>
+            <org.slf4j.simpleLogger.showShortLogName>true</org.slf4j.simpleLogger.showShortLogName>
+          </systemPropertyVariables>
           <excludes>
             <exclude>**/benchmark/*.java</exclude>
           </excludes>


Mime
View raw message