aboutsummaryrefslogtreecommitdiffstats
path: root/common-logging/src
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2017-09-19 11:59:31 -0400
committerPamela Dragosh <pdragosh@research.att.com>2017-09-19 11:59:40 -0400
commit2d158654567be9382d0361cda319deebaf1e88d9 (patch)
treee255e7c536f68d0f70676e1431050a1ffca41cff /common-logging/src
parentdd1df5fdcc8fe69f7ae310d9ffb29c2116973bd0 (diff)
Remove sonar critical for public static
I think that making these private and using accessor functions we can remove the sonar critical for them. Issue-ID: POLICY-237 Change-Id: I4edbf909935fe17b0ef087b5cd0e384d78d104d6 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'common-logging/src')
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java58
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java4
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java4
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java12
4 files changed, 59 insertions, 19 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
index e2ab31c8..a4bd821e 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java
@@ -91,11 +91,11 @@ public class PolicyLogger {
private static boolean isOverrideLogbackLevel = false;
- public static Level DEBUG_LEVEL = Level.INFO;
- public static Level AUDIT_LEVEL = Level.INFO;
- public static Level METRICS_LEVEL = Level.INFO;
- public static Level ERROR_LEVEL = Level.ERROR;
- public static String CLASS_NAME = "ClassName";
+ private static Level DEBUG_LEVEL = Level.INFO;
+ private static Level AUDIT_LEVEL = Level.INFO;
+ private static Level METRICS_LEVEL = Level.INFO;
+ private static Level ERROR_LEVEL = Level.ERROR;
+ private static String CLASS_NAME = "ClassName";
static{
@@ -109,6 +109,46 @@ public class PolicyLogger {
}
}
+ public static Level getDebugLevel() {
+ return DEBUG_LEVEL;
+ }
+
+ public synchronized static void setDebugLevel(Level level) {
+ DEBUG_LEVEL = level;
+ }
+
+ public static Level getAuditLevel() {
+ return AUDIT_LEVEL;
+ }
+
+ public synchronized static void setAuditLevel(Level level) {
+ AUDIT_LEVEL = level;
+ }
+
+ public static Level getMetricsLevel() {
+ return METRICS_LEVEL;
+ }
+
+ public synchronized static void setMetricsLevel(Level level) {
+ METRICS_LEVEL = level;
+ }
+
+ public static Level getErrorLevel() {
+ return ERROR_LEVEL;
+ }
+
+ public synchronized static void setErrorLevel(Level level) {
+ ERROR_LEVEL = level;
+ }
+
+ public static String getClassname() {
+ return CLASS_NAME;
+ }
+
+ public synchronized static void setClassname(String name) {
+ CLASS_NAME = name;
+ }
+
/**
* Populates MDC info
* @param transId
@@ -1140,25 +1180,25 @@ public class PolicyLogger {
if (debugLevel != null && !debugLevel.isEmpty()){
- DEBUG_LEVEL = Level.valueOf(debugLevel);
+ PolicyLogger.setDebugLevel(Level.valueOf(debugLevel));
}
//Only check if it is to turn off or not
if (errorLevel != null && errorLevel.equalsIgnoreCase(Level.OFF.toString())){
- ERROR_LEVEL = Level.valueOf(errorLevel);
+ PolicyLogger.setErrorLevel(Level.valueOf(errorLevel));
}
//Only check if it is to turn off or not
if (metricsLevel != null && metricsLevel.equalsIgnoreCase(Level.OFF.toString())){
- METRICS_LEVEL = Level.valueOf(metricsLevel);
+ PolicyLogger.setMetricsLevel(Level.valueOf(metricsLevel));
}
//Only check if it is to turn off or not
if (auditLevel != null && auditLevel.equalsIgnoreCase(Level.OFF.toString())){
- AUDIT_LEVEL = Level.valueOf(auditLevel);
+ PolicyLogger.setAuditLevel(Level.valueOf(auditLevel));
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
index fbc0ae1d..cc3dba30 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java
@@ -227,7 +227,7 @@ public class EelfLogger implements Logger, Serializable {
*/
@Override
public boolean isAuditEnabled(){
- if(PolicyLogger.AUDIT_LEVEL != null && PolicyLogger.AUDIT_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getAuditLevel() != null && PolicyLogger.getAuditLevel().toString().equals(Level.OFF.toString())){
return false;
}else {
return true;
@@ -240,7 +240,7 @@ public class EelfLogger implements Logger, Serializable {
*/
@Override
public boolean isMetricsEnabled(){
- if(PolicyLogger.METRICS_LEVEL != null && PolicyLogger.METRICS_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getMetricsLevel() != null && PolicyLogger.getMetricsLevel().toString().equals(Level.OFF.toString())){
return false;
}else {
return true;
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java
index 2e67a735..9fcd47af 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/Logger4J.java
@@ -183,7 +183,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
*/
@Override
public boolean isAuditEnabled(){
- if(PolicyLogger.AUDIT_LEVEL != null && PolicyLogger.AUDIT_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getAuditLevel() != null && PolicyLogger.getAuditLevel().toString().equals(Level.OFF.toString())){
return false;
}else {
return true;
@@ -196,7 +196,7 @@ public class Logger4J implements org.onap.policy.common.logging.flexlogger.Logge
*/
@Override
public boolean isMetricsEnabled(){
- if(PolicyLogger.METRICS_LEVEL != null && PolicyLogger.METRICS_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getMetricsLevel() != null && PolicyLogger.getMetricsLevel().toString().equals(Level.OFF.toString())){
return false;
}else {
return true;
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
index f1acc042..aeb26017 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java
@@ -76,7 +76,7 @@ public class SystemOutLogger implements Logger, Serializable {
*/
private void initLevel(){
- if(PolicyLogger.DEBUG_LEVEL != null && PolicyLogger.DEBUG_LEVEL.toString().equals(Level.DEBUG.toString())){
+ if(PolicyLogger.getDebugLevel() != null && PolicyLogger.getDebugLevel().toString().equals(Level.DEBUG.toString())){
isDebugEnabled = true;
isInfoEnabled = true;
isWarnEnabled = true;
@@ -84,27 +84,27 @@ public class SystemOutLogger implements Logger, Serializable {
isDebugEnabled = false;
}
- if(PolicyLogger.DEBUG_LEVEL != null && PolicyLogger.DEBUG_LEVEL.toString().equals(Level.INFO.toString())){
+ if(PolicyLogger.getDebugLevel() != null && PolicyLogger.getDebugLevel().toString().equals(Level.INFO.toString())){
isInfoEnabled = true;
isWarnEnabled = true;
isDebugEnabled = false;
}
- if(PolicyLogger.DEBUG_LEVEL != null && PolicyLogger.DEBUG_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getDebugLevel() != null && PolicyLogger.getDebugLevel().toString().equals(Level.OFF.toString())){
isInfoEnabled = false;
isWarnEnabled = false;
isDebugEnabled = false;
}
- if(PolicyLogger.ERROR_LEVEL != null && PolicyLogger.ERROR_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getErrorLevel() != null && PolicyLogger.getErrorLevel().toString().equals(Level.OFF.toString())){
isErrorEnabled = false;
}
- if(PolicyLogger.AUDIT_LEVEL != null && PolicyLogger.AUDIT_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getAuditLevel() != null && PolicyLogger.getAuditLevel().toString().equals(Level.OFF.toString())){
isAuditEnabled = false;
}
- if(PolicyLogger.METRICS_LEVEL != null && PolicyLogger.METRICS_LEVEL.toString().equals(Level.OFF.toString())){
+ if(PolicyLogger.getMetricsLevel() != null && PolicyLogger.getMetricsLevel().toString().equals(Level.OFF.toString())){
isMetricsEnabled = false;
}
}