carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [1/2] incubator-carbondata git commit: remove unnecessary property
Date Wed, 07 Dec 2016 10:58:53 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master fa6b6e43e -> 5612a3a59


remove unnecessary property

fix style


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/85dd1522
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/85dd1522
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/85dd1522

Branch: refs/heads/master
Commit: 85dd1522cb8d57eabec282563f088e43f26f689a
Parents: fa6b6e4
Author: jackylk <jacky.likun@huawei.com>
Authored: Fri Nov 25 15:08:08 2016 +0800
Committer: chenliang613 <chenliang613@apache.org>
Committed: Wed Dec 7 18:55:53 2016 +0800

----------------------------------------------------------------------
 .../common/logging/impl/StandardLogService.java | 119 ++++---------------
 .../logging/impl/StandardLogServiceTest_UT.java |  14 ---
 2 files changed, 21 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/85dd1522/common/src/main/java/org/apache/carbondata/common/logging/impl/StandardLogService.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/carbondata/common/logging/impl/StandardLogService.java
b/common/src/main/java/org/apache/carbondata/common/logging/impl/StandardLogService.java
index 8684e28..26e3151 100644
--- a/common/src/main/java/org/apache/carbondata/common/logging/impl/StandardLogService.java
+++ b/common/src/main/java/org/apache/carbondata/common/logging/impl/StandardLogService.java
@@ -22,7 +22,6 @@ package org.apache.carbondata.common.logging.impl;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.util.Properties;
 
 import org.apache.carbondata.common.logging.LogService;
 
@@ -36,15 +35,6 @@ import org.apache.log4j.MDC;
 public final class StandardLogService implements LogService {
 
   private static final String PARTITION_ID = "[partitionID:";
-  private static final String CARBON_AUDIT_LOG_PATH = "carbon.auditlog.file.path";
-  private static final String AUDIT_LOG_DEFAULT_PATH = "logs/CarbonAudit.log";
-  private static final String CARBON_AUDIT_LOG_ROLLING_UP_SIZE = "carbon.auditlog.max.file.size";
-  private static final String AUDIT_LOG_DEFAULT_ROLLING_UP_SIZE = "10MB";
-  private static final String CARBON_AUDIT_LOG_MAX_BACKUP = "carbon.auditlog.max.backup.files";
-  private static final String AUDIT_LOG_DEFAULT_MAX_BACKUP = "10";
-  private static final String CARBON_AUDIT_LOG_LEVEL = "carbon.logging.level";
-  private static final String AUDIT_LOG_DEFAULT_LEVEL = "INFO";
-  private static boolean doLog = true;
   private Logger logger;
 
   /**
@@ -53,78 +43,13 @@ public final class StandardLogService implements LogService {
    * @param clazzName for which the Logging is required
    */
   public StandardLogService(String clazzName) {
-    String auditLogPath = AUDIT_LOG_DEFAULT_PATH;
-    String rollupSize = AUDIT_LOG_DEFAULT_ROLLING_UP_SIZE;
-    String maxBackup = AUDIT_LOG_DEFAULT_MAX_BACKUP;
-    String logLevel = AUDIT_LOG_DEFAULT_LEVEL;
-
-    Properties props = new Properties();
-    Properties carbonProps = FileUtil.getCarbonProperties();
-
-    if (null != carbonProps) {
-      if (null != carbonProps.getProperty(CARBON_AUDIT_LOG_PATH)) {
-        auditLogPath = carbonProps.getProperty(CARBON_AUDIT_LOG_PATH);
-      }
-
-      if (null != carbonProps.getProperty(CARBON_AUDIT_LOG_ROLLING_UP_SIZE)) {
-        rollupSize = carbonProps.getProperty(CARBON_AUDIT_LOG_ROLLING_UP_SIZE);
-      }
-
-      if (null != carbonProps.getProperty(CARBON_AUDIT_LOG_MAX_BACKUP)) {
-        maxBackup = carbonProps.getProperty(CARBON_AUDIT_LOG_MAX_BACKUP);
-      }
-
-      if (null != carbonProps.getProperty(CARBON_AUDIT_LOG_LEVEL)) {
-        logLevel = carbonProps.getProperty(CARBON_AUDIT_LOG_LEVEL);
-      }
-    }
-
-    props.setProperty("log4j.rootLogger", logLevel + ",stdout,AUDL");
-
-    props.setProperty("log4j.appender.stdout", "org.apache.log4j.ConsoleAppender");
-    props.setProperty("log4j.appender.stdout.layout.ConversionPattern", "%d %-5p [%c] %m%n");
-    props.setProperty("log4j.appender.stdout.layout", "org.apache.log4j.PatternLayout");
-    props.setProperty("log4j.appender.AUDL",
-        "AuditExtendedRollingFileAppender");
-
-    props.setProperty("log4j.appender.AUDL.File", auditLogPath);
-    props.setProperty("log4j.appender.AUDL.threshold",
-        "AUDIT#AuditLevel");
-    props.setProperty("log4j.appender.AUDL.layout.ConversionPattern",
-        "%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n");
-    props.setProperty("log4j.appender.AUDL.layout", "org.apache.log4j.PatternLayout");
-    props.setProperty("log4j.appender.AUDL.MaxFileSize", rollupSize);
-    props.setProperty("log4j.appender.AUDL.MaxBackupIndex", maxBackup);
-
-    props.setProperty("log4j.logger.com.huawei", logLevel + ",stdout");
-    props.setProperty("log4j.logger.com.huawei", logLevel + ",AUDL");
-
     logger = Logger.getLogger(clazzName);
-
   }
 
   public StandardLogService() {
     this("Carbon");
   }
 
-  /**
-   * returns is DO Log
-   *
-   * @return the doLog
-   */
-  public static boolean isDoLog() {
-    return doLog;
-  }
-
-  /**
-   * set Do Log
-   *
-   * @param doLog the doLog to set
-   */
-  public static void setDoLog(boolean doLog) {
-    StandardLogService.doLog = doLog;
-  }
-
   public static String getPartitionID(String tableName) {
     return tableName.substring(tableName.lastIndexOf('_') + 1, tableName.length());
   }
@@ -187,30 +112,28 @@ public final class StandardLogService implements LogService {
    * Utility Method to log the the Message.
    */
   private void logMessage(Level logLevel, Throwable throwable, String message) {
-    if (StandardLogService.doLog) {
-      try {
-        //Append the partition id and query id if exist
-        StringBuilder buff = new StringBuilder(Thread.currentThread().getName());
-        buff.append(" ");
-        buff.append(message);
-        message = buff.toString();
-        if (Level.ERROR.toString().equalsIgnoreCase(logLevel.toString())) {
-          logErrorMessage(throwable, message);
-        } else if (Level.DEBUG.toString().equalsIgnoreCase(logLevel.toString())) {
-          logDebugMessage(throwable, message);
-        } else if (Level.INFO.toString().equalsIgnoreCase(logLevel.toString())) {
-          logInfoMessage(throwable, message);
-        } else if (Level.WARN.toString().equalsIgnoreCase(logLevel.toString())) {
-          logWarnMessage(throwable, message);
-        } else if (Level.AUDIT.toString().equalsIgnoreCase(logLevel.toString())) {
-          audit(message);
-        } else if (Level.STATISTICS == logLevel) {
-          statistic(message);
-        }
-
-      } catch (Throwable t) {
-        logger.error(t);
+    try {
+      //Append the partition id and query id if exist
+      StringBuilder buff = new StringBuilder(Thread.currentThread().getName());
+      buff.append(" ");
+      buff.append(message);
+      message = buff.toString();
+      if (Level.ERROR.toString().equalsIgnoreCase(logLevel.toString())) {
+        logErrorMessage(throwable, message);
+      } else if (Level.DEBUG.toString().equalsIgnoreCase(logLevel.toString())) {
+        logDebugMessage(throwable, message);
+      } else if (Level.INFO.toString().equalsIgnoreCase(logLevel.toString())) {
+        logInfoMessage(throwable, message);
+      } else if (Level.WARN.toString().equalsIgnoreCase(logLevel.toString())) {
+        logWarnMessage(throwable, message);
+      } else if (Level.AUDIT.toString().equalsIgnoreCase(logLevel.toString())) {
+        audit(message);
+      } else if (Level.STATISTICS == logLevel) {
+        statistic(message);
       }
+
+    } catch (Throwable t) {
+      logger.error(t);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/85dd1522/common/src/test/java/org/apache/carbondata/common/logging/impl/StandardLogServiceTest_UT.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/carbondata/common/logging/impl/StandardLogServiceTest_UT.java
b/common/src/test/java/org/apache/carbondata/common/logging/impl/StandardLogServiceTest_UT.java
index 0ad4bd7..9187a93 100644
--- a/common/src/test/java/org/apache/carbondata/common/logging/impl/StandardLogServiceTest_UT.java
+++ b/common/src/test/java/org/apache/carbondata/common/logging/impl/StandardLogServiceTest_UT.java
@@ -135,20 +135,6 @@ public class StandardLogServiceTest_UT extends TestCase {
     Assert.assertTrue(true);
   }
 
-  @Test public void testIsDoLog() {
-    StandardLogService.setDoLog(true);
-    Assert.assertEquals(true, StandardLogService.isDoLog());
-
-    StandardLogService.setDoLog(false);
-    Assert.assertEquals(false, StandardLogService.isDoLog());
-
-  }
-
-  @Test public void testSetDoLog() {
-    StandardLogService.setDoLog(true);
-    Assert.assertEquals(true, StandardLogService.isDoLog());
-  }
-
   @Test public void testAuditString() {
     logService.audit("audit message");
     Assert.assertTrue(true);


Mime
View raw message