aboutsummaryrefslogtreecommitdiffstats
path: root/common-logging/src/main/java/org/onap/policy/common/logging/eelf
diff options
context:
space:
mode:
Diffstat (limited to 'common-logging/src/main/java/org/onap/policy/common/logging/eelf')
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java27
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java30
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java15
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java4
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java11
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java13
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java77
7 files changed, 63 insertions, 114 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java
index 32bb6fec..0eaa06b0 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2020 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,9 @@
package org.onap.policy.common.logging.eelf;
import java.util.EnumMap;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
/**
* ErrorCodeMap contains a HashMap of ErrorCodeInfo (error code and error description).
@@ -32,7 +36,8 @@ import java.util.EnumMap;
* 500 – business process errors
* 900 – unknown errors
*/
-public class ErrorCodeMap {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ErrorCodeMap {
private static final EnumMap<MessageCodes, ErrorCodeInfo> hm = new EnumMap<>(MessageCodes.class);
@@ -83,7 +88,6 @@ public class ErrorCodeMap {
new ErrorCodeInfo(MISS_PROPERTY_ERROR, MISS_PROPERTY_ERROR_DESCRIPTION));
hm.put(MessageCodes.UPDATE_ERROR, new ErrorCodeInfo(UPDATE_ERROR, UPDATE_ERROR_DESCRIPTION));
hm.put(MessageCodes.ERROR_SYSTEM_ERROR, new ErrorCodeInfo(ERROR_SYSTEM_ERROR, ERROR_SYSTEM_ERROR_DESCRIPTION));
- hm.put(MessageCodes.ERROR_DATA_ISSUE, new ErrorCodeInfo(ERROR_DATA_ISSUE, ERROR_DATA_ISSUE_DESCRIPTION));
hm.put(MessageCodes.ERROR_PERMISSIONS, new ErrorCodeInfo(ERROR_PERMISSIONS, ERROR_PERMISSIONS_DESCRIPTION));
hm.put(MessageCodes.ERROR_DATA_ISSUE, new ErrorCodeInfo(ERROR_DATA_ISSUE, ERROR_DATA_ISSUE_DESCRIPTION));
hm.put(MessageCodes.ERROR_PROCESS_FLOW, new ErrorCodeInfo(ERROR_PROCESS_FLOW, ERROR_PROCESS_FLOW_DESCRIPTION));
@@ -93,32 +97,21 @@ public class ErrorCodeMap {
hm.put(MessageCodes.ERROR_AUDIT, new ErrorCodeInfo(ERROR_AUDIT, ERROR_AUDIT_DESCRIPTION));
}
- private ErrorCodeMap() {
- // Private constructor to prevent subclassing
- }
-
public static ErrorCodeInfo getErrorCodeInfo(MessageCodes messageCode) {
return hm.get(messageCode);
}
+ @Getter
static class ErrorCodeInfo {
- private String errorCode;
- private String errorDesc;
+ private final String errorCode;
+ private final String errorDesc;
public ErrorCodeInfo(String errorCode, String errorDesc) {
this.errorCode = errorCode;
this.errorDesc = errorDesc;
}
- public String getErrorCode() {
- return errorCode;
- }
-
- public String getErrorDesc() {
- return errorDesc;
- }
-
}
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
index 23be38ba..87a96a19 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,9 @@
package org.onap.policy.common.logging.eelf;
import java.time.Instant;
+import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
/**
@@ -29,32 +31,14 @@ import lombok.Setter;
*/
@Getter
@Setter
+@NoArgsConstructor
+@AllArgsConstructor
public class EventData {
private String requestId = null;
private Instant startTime = null;
private Instant endTime = null;
- // Default constructor takes no arguments.
- // Is empty because instance variables are assigned
- // their default values upon declaration.
- public EventData() {
- // See above comments for the reason this constructor is empty
- }
-
- /**
- * Create an instance.
- *
- * @param requestId the request ID
- * @param startTime the start time
- * @param endTime the end time
- */
- public EventData(String requestId, Instant startTime, Instant endTime) {
- this.requestId = requestId;
- this.startTime = startTime;
- this.endTime = endTime;
- }
-
@Override
public String toString() {
return requestId + " Starting Time : " + this.startTime + " Ending Time : " + this.endTime;
@@ -62,8 +46,8 @@ public class EventData {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
return result;
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
index 71476c6a..f6f38d0d 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +22,14 @@ package org.onap.policy.common.logging.eelf;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import lombok.Getter;
/**
* EventTrackInfo contains a ConcurrentHashMap of EventData.
*/
public class EventTrackInfo {
+ @Getter
private final ConcurrentMap<String, EventData> eventInfo;
/**
@@ -66,9 +68,7 @@ public class EventTrackInfo {
return;
}
// in case override the start time, check the original event was already stored or not
- if (!eventInfo.containsKey(id)) {
- eventInfo.put(id, event);
- }
+ eventInfo.putIfAbsent(id, event);
}
}
@@ -82,11 +82,4 @@ public class EventTrackInfo {
eventInfo.remove(eventId);
}
}
-
- /**
- * Returns a ConcurrentHashMap of EventData.
- */
- public ConcurrentMap<String, EventData> getEventInfo() {
- return eventInfo;
- }
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
index 1a87de53..f5203683 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfoHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class EventTrackInfoHandler extends TimerTask {
*/
private void cleanUp() {
- EventTrackInfo eventTrackInfo = PolicyLogger.getEventTracker();
+ var eventTrackInfo = PolicyLogger.getEventTracker();
if (eventTrackInfo == null) {
return;
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
index 629ead82..0535b9d7 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/MessageCodes.java
@@ -3,13 +3,14 @@
* ONAP-Logging
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -73,12 +74,6 @@ public enum MessageCodes implements EELFResolvableResourceEnum {
RULE_METRICS_INFO,
- UEB_AUDIT_EXEC_INFO,
-
- UEB_AUDIT_BEGIN_INFO,
-
- UEB_AUDIT_END_INFO,
-
UPDATE_ERROR,
GENERAL_ERROR,
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
index 47c027c2..cfb14643 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,11 @@
package org.onap.policy.common.logging.eelf;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
-public class OnapConfigProperties {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class OnapConfigProperties {
/**
* The Date-time of the start of a transaction.
@@ -58,7 +61,7 @@ public class OnapConfigProperties {
public static final String RESPONSE_CODE = "ResponseCode";
/**
- * Human readable description of the application specific response code.
+ * Human-readable description of the application specific response code.
*/
public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
@@ -81,8 +84,4 @@ public class OnapConfigProperties {
public static final String SERVER_NAME = "ServerName";
public static final String INVOCATION_ID = "InvocationID";
-
- private OnapConfigProperties() {
- // do nothing
- }
}
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 3f94483b..662ca764 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,6 +61,10 @@ import java.util.Timer;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Consumer;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.logging.OnapLoggingUtils;
import org.onap.policy.common.logging.flexlogger.LoggerType;
@@ -69,6 +73,7 @@ import org.slf4j.MDC;
/**
* PolicyLogger contains all the static methods for EELF logging.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PolicyLogger {
private static EELFLogger errorLogger = EELFManager.getErrorLogger();
@@ -110,7 +115,9 @@ public class PolicyLogger {
// size drops to this point, stop the Timer
private static int stopCheckPoint = 2500;
- private static boolean isOverrideLogbackLevel = false;
+ @Getter
+ @Setter
+ private static boolean overrideLogbackLevel = false;
private static Level debugLevel = Level.INFO;
private static Level auditLevel = Level.INFO;
@@ -133,10 +140,6 @@ public class PolicyLogger {
}
}
- private PolicyLogger() {
-
- }
-
public static synchronized Level getDebugLevel() {
return debugLevel;
}
@@ -150,7 +153,7 @@ public class PolicyLogger {
*/
public static synchronized void setDebugLevel(String newDebugLevel) {
- if (isOverrideLogbackLevel) {
+ if (overrideLogbackLevel) {
PolicyLogger.debugLevel = Level.valueOf(newDebugLevel);
debugLogger.setLevel(debugLevel);
}
@@ -170,7 +173,7 @@ public class PolicyLogger {
*/
public static synchronized void setAuditLevel(String newAuditLevel) {
- if (isOverrideLogbackLevel) {
+ if (overrideLogbackLevel) {
if ("OFF".equalsIgnoreCase(newAuditLevel)) {
PolicyLogger.auditLevel = Level.OFF;
auditLogger.setLevel(auditLevel);
@@ -195,7 +198,7 @@ public class PolicyLogger {
*/
public static synchronized void setMetricsLevel(String newMetricsLevel) {
- if (isOverrideLogbackLevel) {
+ if (overrideLogbackLevel) {
if ("OFF".equalsIgnoreCase(newMetricsLevel)) {
PolicyLogger.metricsLevel = Level.OFF;
metricsLogger.setLevel(metricsLevel);
@@ -221,7 +224,7 @@ public class PolicyLogger {
*/
public static synchronized void setErrorLevel(String newErrorLevel) {
- if (isOverrideLogbackLevel) {
+ if (overrideLogbackLevel) {
if ("OFF".equalsIgnoreCase(newErrorLevel)) {
PolicyLogger.errorLevel = Level.OFF;
errorLogger.setLevel(errorLevel);
@@ -301,8 +304,8 @@ public class PolicyLogger {
setMdcHostInfo();
- Instant startTime = Instant.now();
- Instant endTime = Instant.now();
+ var startTime = Instant.now();
+ var endTime = Instant.now();
seTimeStamps(startTime, endTime);
@@ -334,8 +337,8 @@ public class PolicyLogger {
MDC.put(MDC_INSTANCE_UUID, "");
MDC.put(MDC_ALERT_SEVERITY, "");
- Instant startTime = Instant.now();
- Instant endTime = Instant.now();
+ var startTime = Instant.now();
+ var endTime = Instant.now();
seTimeStamps(startTime, endTime);
@@ -348,7 +351,7 @@ public class PolicyLogger {
}
private static void seTimeStamps(Instant startTime, Instant endTime) {
- SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+ var sdf = new SimpleDateFormat(DATE_FORMAT);
String formatedTime = sdf.format(Date.from(startTime));
MDC.put(BEGIN_TIME_STAMP, formatedTime);
@@ -874,7 +877,7 @@ public class PolicyLogger {
if (eventTracker == null) {
eventTracker = new EventTrackInfo();
}
- EventData event = new EventData();
+ var event = new EventData();
event.setRequestId(eventId);
event.setStartTime(Instant.now());
eventTracker.storeEventData(event);
@@ -1007,7 +1010,7 @@ public class PolicyLogger {
return;
}
- EventData event = eventTracker.getEventDataByRequestId(eventId);
+ var event = eventTracker.getEventDataByRequestId(eventId);
if (event != null) {
Instant endTime = event.getEndTime();
@@ -1035,7 +1038,7 @@ public class PolicyLogger {
return;
}
- EventData event = eventTracker.getEventDataByRequestId(eventId.toString());
+ var event = eventTracker.getEventDataByRequestId(eventId.toString());
if (event != null) {
Instant endTime = event.getEndTime();
@@ -1226,13 +1229,13 @@ public class PolicyLogger {
* @param arguments the messages
*/
private static String getNormalizedStackTrace(Throwable throwable, String... arguments) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
+ var sw = new StringWriter();
+ var pw = new PrintWriter(sw);
throwable.printStackTrace(pw);
String newStValue = sw.toString().replace('|', '!').replace("\n", " - ");
int curSize = arguments == null ? 0 : arguments.length;
- StringBuilder newArgument = new StringBuilder();
- for (int i = 0; i < curSize; i++) {
+ var newArgument = new StringBuilder();
+ for (var i = 0; i < curSize; i++) {
newArgument.append(arguments[i]);
newArgument.append(":");
}
@@ -1246,7 +1249,7 @@ public class PolicyLogger {
private static void startCleanUp() {
if (!isEventTrackerRunning) {
- EventTrackInfoHandler ttrcker = new EventTrackInfoHandler();
+ var ttrcker = new EventTrackInfoHandler();
timer = new Timer(true);
timer.scheduleAtFixedRate(ttrcker, timerDelayTime, checkInterval);
debugLogger.info("EventTrackInfoHandler begins! : {}", new Date());
@@ -1279,7 +1282,7 @@ public class PolicyLogger {
*/
public static LoggerType init(Properties properties) {
- Properties loggerProperties = getLoggerProperties(properties);
+ var loggerProperties = getLoggerProperties(properties);
// fetch and verify definitions of some properties
try {
@@ -1321,7 +1324,7 @@ public class PolicyLogger {
}
private static int getIntProp(Properties properties, String propName, int defaultValue) {
- final int propValue = Integer.parseInt(properties.getProperty(propName, String.valueOf(defaultValue)));
+ final var propValue = Integer.parseInt(properties.getProperty(propName, String.valueOf(defaultValue)));
debugLogger.info("{} value: {}", propName, propValue);
@@ -1373,10 +1376,10 @@ public class PolicyLogger {
}
private static void setOverrideLogbackLevels(Properties loggerProperties) {
- final String overrideLogbackLevel = loggerProperties.getProperty("override.logback.level.setup");
+ final var overrideLogbackLevelText = loggerProperties.getProperty("override.logback.level.setup");
- if (!StringUtils.isBlank(overrideLogbackLevel)) {
- isOverrideLogbackLevel = "TRUE".equalsIgnoreCase(overrideLogbackLevel);
+ if (!StringUtils.isBlank(overrideLogbackLevelText)) {
+ overrideLogbackLevel = "TRUE".equalsIgnoreCase(overrideLogbackLevelText);
}
}
@@ -1395,24 +1398,6 @@ public class PolicyLogger {
}
}
-
- /**
- * Returns true for overriding logback levels; returns false for not.
- */
- public static boolean isOverrideLogbackLevel() {
-
- return isOverrideLogbackLevel;
- }
-
- /**
- * Sets true for overriding logback levels; sets false for not.
- */
- public static void setOverrideLogbackLevel(boolean odl) {
-
- isOverrideLogbackLevel = odl;
-
- }
-
/**
* Sets server information to MDC.
*/