summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-lifecycle/pom.xml7
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java8
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java8
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java10
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java4
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java8
-rw-r--r--policy-management/pom.xml6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/Main.java11
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java5
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java8
-rw-r--r--policy-utils/pom.xml5
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java77
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java58
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java5
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java6
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java19
-rw-r--r--policy-utils/src/test/resources/interpolation.properties4
18 files changed, 71 insertions, 182 deletions
diff --git a/feature-lifecycle/pom.xml b/feature-lifecycle/pom.xml
index 5775afe1..9bec81e9 100644
--- a/feature-lifecycle/pom.xml
+++ b/feature-lifecycle/pom.xml
@@ -136,6 +136,13 @@
</dependency>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${policy.common.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-examples</artifactId>
<version>${policy.models.version}</version>
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
index 7201d62e..df9e5eed 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
@@ -36,12 +36,12 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.common.utils.time.PseudoScheduledExecutorService;
import org.onap.policy.common.utils.time.TestTimeMulti;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -101,9 +101,9 @@ public class LifecycleFsmTest {
*/
@Before
public void beforeTest() throws CoderException, IOException {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
- LoggerUtil.setLevel("org.onap.policy.drools", "INFO");
+ LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
+ LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
+ LoggerUtils.setLevel("org.onap.policy.drools", "INFO");
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
fsm = new LifecycleFsm() {
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
index 15af959a..c97133b5 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
@@ -46,6 +46,7 @@ import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.common.utils.time.PseudoScheduledExecutorService;
import org.onap.policy.common.utils.time.TestTimeMulti;
@@ -54,7 +55,6 @@ import org.onap.policy.drools.domain.models.controller.ControllerPolicy;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -117,9 +117,9 @@ public class LifecycleFsmUpdateTest {
*/
@BeforeClass
public static void setUp() throws IOException {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
- LoggerUtil.setLevel("org.onap.policy.drools", "INFO");
+ LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
+ LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
+ LoggerUtils.setLevel("org.onap.policy.drools", "INFO");
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
index 67c78985..eeac888d 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -31,12 +31,12 @@ import org.junit.BeforeClass;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.common.utils.time.PseudoScheduledExecutorService;
import org.onap.policy.common.utils.time.TestTimeMulti;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyControllerConstants;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -56,9 +56,9 @@ public abstract class LifecycleStateRunningTest {
*/
@BeforeClass
public static void setUp() throws IOException {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
- LoggerUtil.setLevel("org.onap.policy.drools", "INFO");
+ LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
+ LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
+ LoggerUtils.setLevel("org.onap.policy.drools", "INFO");
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
controllerSupport.createController();
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
index cf6f451a..3d8d08b7 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
@@ -33,9 +33,9 @@ import java.util.Collections;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -49,7 +49,7 @@ public class LifecycleStateTerminatedTest {
@BeforeClass
public static void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
- LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
+ LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
}
@AfterClass
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
index de67c027..65228a9b 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
@@ -49,6 +49,7 @@ import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.JacksonHandler;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.drools.lifecycle.ControllerSupport;
@@ -56,7 +57,6 @@ import org.onap.policy.drools.lifecycle.LifecycleFeature;
import org.onap.policy.drools.lifecycle.LifecycleFsm;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyControllerConstants;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -105,9 +105,9 @@ public class RestLifecycleManagerTest {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
fsm = newFsmInstance();
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
- LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN");
- LoggerUtil.setLevel("org.onap.policy.drools", "INFO");
+ LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
+ LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
+ LoggerUtils.setLevel("org.onap.policy.drools", "INFO");
HttpServletServerFactoryInstance.getServerFactory().destroy();
HttpClientFactoryInstance.getClientFactory().destroy();
diff --git a/policy-management/pom.xml b/policy-management/pom.xml
index fa603734..6aa7b87f 100644
--- a/policy-management/pom.xml
+++ b/policy-management/pom.xml
@@ -148,6 +148,12 @@
</dependency>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-pdp</artifactId>
<version>${policy.models.version}</version>
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index 4374eb81..dfcfe438 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -65,6 +65,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.features.PolicyControllerFeatureApi;
import org.onap.policy.drools.features.PolicyEngineFeatureApi;
@@ -79,7 +80,6 @@ import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyControllerConstants;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.system.PolicyEngineConstants;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -2071,7 +2071,7 @@ public class RestManager {
.entity(new Error("logger level: " + NOT_ACCEPTABLE_MSG))
.build();
}
- newLevel = LoggerUtil.setLevel(loggerName, loggerLevel);
+ newLevel = LoggerUtils.setLevel(loggerName, loggerLevel);
} catch (final IllegalArgumentException e) {
logger.warn("{}: invalid operation for logger {} and level {}", this, loggerName, loggerLevel, e);
return Response.status(Status.NOT_FOUND).build();
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
index c28d4c96..e92d05d2 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
@@ -28,6 +28,7 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.resources.MessageConstants;
import org.onap.policy.common.utils.security.CryptoUtils;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
@@ -142,7 +143,7 @@ public class Main {
if (!success) {
trans.setStatusCode(false).setResponseDescription("partial start").flush();
logger.warn(
- LoggerUtil.TRANSACTION_LOG_MARKER,
+ LoggerUtils.TRANSACTION_LOG_MARKER,
"Main: {} has been partially started",
PolicyEngineConstants.getManager());
throw new PolicyDroolsPdpRuntimeException(
@@ -157,7 +158,7 @@ public class Main {
.setResponseDescription(e.getMessage())
.flush();
logger.warn(
- LoggerUtil.TRANSACTION_LOG_MARKER,
+ LoggerUtils.TRANSACTION_LOG_MARKER,
"Main: cannot start {} (bad state)",
PolicyEngineConstants.getManager());
throw new PolicyDroolsPdpRuntimeException(
@@ -169,7 +170,7 @@ public class Main {
.setResponseDescription(e.getMessage())
.flush();
logger.warn(
- LoggerUtil.TRANSACTION_LOG_MARKER,
+ LoggerUtils.TRANSACTION_LOG_MARKER,
"Main: cannot start {}",
PolicyEngineConstants.getManager());
throw new PolicyDroolsPdpRuntimeException(
@@ -205,7 +206,7 @@ public class Main {
.setResponseDescription(e.getMessage())
.flush();
logger.error(
- LoggerUtil.TRANSACTION_LOG_MARKER,
+ LoggerUtils.TRANSACTION_LOG_MARKER,
"Main: cannot instantiate policy-controller {}",
controllerName);
throw new PolicyDroolsPdpRuntimeException(
@@ -217,7 +218,7 @@ public class Main {
.setResponseDescription(e.getMessage())
.flush();
logger.warn(
- LoggerUtil.TRANSACTION_LOG_MARKER,
+ LoggerUtils.TRANSACTION_LOG_MARKER,
"Main: cannot instantiate policy-controller {} (linkage)",
controllerName);
throw new PolicyDroolsPdpRuntimeException(
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
index 664f7c7f..d5f7ae05 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
@@ -56,6 +56,7 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInst
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.gson.annotation.GsonJsonProperty;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.services.FeatureApiUtils;
import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.core.PolicyContainer;
@@ -398,7 +399,7 @@ class PolicyEngineManager implements PolicyEngine {
} else {
final String msg = "Configuration Entity is not supported: " + entity;
mdcTrans.resetSubTransaction().setStatusCode(false).setResponseDescription(msg).flush();
- logger.warn(LoggerUtil.TRANSACTION_LOG_MARKER, msg);
+ logger.warn(LoggerUtils.TRANSACTION_LOG_MARKER, msg);
throw new IllegalArgumentException(msg);
}
}
@@ -468,7 +469,7 @@ class PolicyEngineManager implements PolicyEngine {
} catch (final Exception e) {
mdcTrans.setStatusCode(false).setResponseCode(e.getClass().getName())
.setResponseDescription(e.getMessage()).flush();
- logger.error(LoggerUtil.TRANSACTION_LOG_MARKER,
+ logger.error(LoggerUtils.TRANSACTION_LOG_MARKER,
"{}: cannot update-policy-controllers because of {}", this, e.getMessage(), e);
}
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java
index db2062f4..b71403e7 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -51,9 +51,9 @@ import org.kie.api.event.rule.ObjectUpdatedEvent;
import org.kie.api.event.rule.RuleFlowGroupActivatedEvent;
import org.kie.api.event.rule.RuleFlowGroupDeactivatedEvent;
import org.kie.api.event.rule.RuleRuntimeEventListener;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.util.KieUtils;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,8 +105,8 @@ public class MavenDroolsControllerUpgradesTest {
Paths.get(DROOLS_RESOURCES_DIR + "rules2" + DRL_EXT).toFile())
.collect(Collectors.toList()));
- LoggerUtil.setLevel("ROOT", "WARN");
- LoggerUtil.setLevel("org.onap.policy.drools.controller.internal", "INFO");
+ LoggerUtils.setLevel("ROOT", "WARN");
+ LoggerUtils.setLevel("org.onap.policy.drools.controller.internal", "INFO");
}
/**
diff --git a/policy-utils/pom.xml b/policy-utils/pom.xml
index 5bbcded9..fd337002 100644
--- a/policy-utils/pom.xml
+++ b/policy-utils/pom.xml
@@ -67,6 +67,11 @@
<version>${policy.common.version}</version>
</dependency>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${policy.common.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java
deleted file mode 100644
index 7468b523..00000000
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2017-2018, 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.
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.utils.logging;
-
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.filter.AbstractMatcherFilter;
-import ch.qos.logback.core.spi.FilterReply;
-import lombok.AccessLevel;
-import lombok.AllArgsConstructor;
-import org.slf4j.Marker;
-
-/**
- * Logger Marker Filters to be used in logback.xml configuration
- * to accept/deny metric or transaction (audit) events
- */
-@AllArgsConstructor(access = AccessLevel.PROTECTED)
-public abstract class LoggerMarkerFilter extends AbstractMatcherFilter<ILoggingEvent> {
-
- protected final Marker marker;
-
- @Override
- public FilterReply decide(ILoggingEvent event) {
-
- if (this.marker == null || !isStarted()) {
- return FilterReply.DENY;
- }
-
- if (event == null || event.getMarker() == null) {
- return FilterReply.DENY;
- }
-
- if (event.getMarker().equals(marker)) {
- return FilterReply.ACCEPT;
- } else {
- return FilterReply.DENY;
- }
- }
-
- /**
- * Metric Logger Marker Filter.
- */
- public static class MetricLoggerMarkerFilter extends LoggerMarkerFilter {
-
- public MetricLoggerMarkerFilter() {
- super(LoggerUtil.METRIC_LOG_MARKER);
- }
-
- }
-
- /**
- * Transaction Logger Marker Filter.
- */
- public static class TransactionLoggerMarkerFilter extends LoggerMarkerFilter {
-
- public TransactionLoggerMarkerFilter() {
- super(LoggerUtil.TRANSACTION_LOG_MARKER);
- }
- }
-}
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
index eef0fa3d..9c6dad79 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
@@ -20,13 +20,10 @@
package org.onap.policy.drools.utils.logging;
-import ch.qos.logback.classic.LoggerContext;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
/**
* Loger Utils.
@@ -46,58 +43,5 @@ public final class LoggerUtil {
*/
public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
- /**
- * Root logger.
- */
- public static final String ROOT_LOGGER = "ROOT";
-
- /**
- * Metric Log Marker Name.
- */
- public static final String METRIC_LOG_MARKER_NAME = "metric";
-
- /**
- * Transaction Log Marker Name.
- */
- public static final String TRANSACTION_LOG_MARKER_NAME = "transaction";
-
- /**
- * Marks a logging record as a metric.
- */
- public static final Marker METRIC_LOG_MARKER = MarkerFactory.getMarker(METRIC_LOG_MARKER_NAME);
-
- /**
- * Marks a logging record as an end-to-end transaction.
- */
- public static final Marker TRANSACTION_LOG_MARKER = MarkerFactory.getMarker(TRANSACTION_LOG_MARKER_NAME);
-
- /**
- * Set the log level of a logger.
- *
- * @param loggerName logger name
- * @param loggerLevel logger level
- */
- public static String setLevel(String loggerName, String loggerLevel) {
- if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) {
- throw new IllegalStateException("The SLF4J logger factory is not configured for logback");
- }
-
- final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- final var logger = context.getLogger(loggerName);
- if (logger == null) {
- throw new IllegalArgumentException("no logger " + loggerName);
- }
-
- LOGGER.warn("setting {} logger to level {}", loggerName, loggerLevel);
-
- // use the current log level if the string provided cannot be converted to a valid Level.
-
- // NOSONAR: this method is currently used by the telemetry api (which should be authenticated).
- // It is no more or no less dangerous than an admin changing the logback level on the fly.
- // This is a controlled admin function that should not cause any risks when the system
- // is configured properly.
- logger.setLevel(ch.qos.logback.classic.Level.toLevel(loggerLevel, logger.getLevel())); // NOSONAR
-
- return logger.getLevel().toString();
- }
}
+
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
index 583360b3..819e5e32 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
@@ -54,6 +54,7 @@ import java.time.Instant;
import lombok.Getter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.drools.metrics.Metric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -234,14 +235,14 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public MdcTransaction metric() {
flush();
- logger.info(LoggerUtil.METRIC_LOG_MARKER, "");
+ logger.info(LoggerUtils.METRIC_LOG_MARKER, "");
return this;
}
@Override
public MdcTransaction transaction() {
flush();
- logger.info(LoggerUtil.TRANSACTION_LOG_MARKER, "");
+ logger.info(LoggerUtils.TRANSACTION_LOG_MARKER, "");
return this;
}
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java
index 4b4b9d64..c19adea4 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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.
@@ -34,8 +34,8 @@ import org.apache.commons.lang3.StringUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.security.CryptoUtils;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -244,7 +244,7 @@ public class PropertyUtilTest {
assertEquals(System.getenv("HOME"), props.getProperty(INTERPOLATION_ENVD));
assertEquals(StringUtils.EMPTY, props.getProperty(INTERPOLATION_ENVD_NONE));
assertEquals(StringUtils.EMPTY, props.getProperty(INTERPOLATION_ENVD_NO_DEFAULT));
- assertEquals(LoggerUtil.ROOT_LOGGER, props.getProperty(INTERPOLATION_CONST));
+ assertEquals(LoggerUtils.ROOT_LOGGER, props.getProperty(INTERPOLATION_CONST));
assertEquals(System.getProperty("user.home"), props.getProperty(INTERPOLATION_SYS));
assertEquals(INTERPOLATION_ENVD_DEFAULT_VALUE, props.getProperty(INTERPOLATION_ENVD_DEFAULT));
}
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java
index be1a8a97..195a7add 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-utils
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 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.
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
+import org.onap.policy.common.utils.logging.LoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,20 +38,20 @@ public class LoggerUtilTest {
assertTrue(logger.isInfoEnabled());
logger.info("line 1");
- logger.info(LoggerUtil.METRIC_LOG_MARKER, "line 1 Metric");
- logger.info(LoggerUtil.TRANSACTION_LOG_MARKER, "line 1 Transaction");
+ logger.info(LoggerUtils.METRIC_LOG_MARKER, "line 1 Metric");
+ logger.info(LoggerUtils.TRANSACTION_LOG_MARKER, "line 1 Transaction");
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "warn");
+ LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "warn");
logger.info("line 2");
- logger.info(LoggerUtil.METRIC_LOG_MARKER, "line 2 Metric");
- logger.info(LoggerUtil.TRANSACTION_LOG_MARKER, "line 2 Transaction");
+ logger.info(LoggerUtils.METRIC_LOG_MARKER, "line 2 Metric");
+ logger.info(LoggerUtils.TRANSACTION_LOG_MARKER, "line 2 Transaction");
assertFalse(logger.isInfoEnabled());
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "debug");
+ LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "debug");
logger.debug("line 3");
- logger.debug(LoggerUtil.METRIC_LOG_MARKER, "line 3 Metric");
- logger.debug(LoggerUtil.TRANSACTION_LOG_MARKER, "line 3 Transaction");
+ logger.debug(LoggerUtils.METRIC_LOG_MARKER, "line 3 Metric");
+ logger.debug(LoggerUtils.TRANSACTION_LOG_MARKER, "line 3 Transaction");
assertTrue(logger.isDebugEnabled());
}
diff --git a/policy-utils/src/test/resources/interpolation.properties b/policy-utils/src/test/resources/interpolation.properties
index 78ec546b..aeb88a9b 100644
--- a/policy-utils/src/test/resources/interpolation.properties
+++ b/policy-utils/src/test/resources/interpolation.properties
@@ -2,7 +2,7 @@
# ============LICENSE_START=======================================================
# ONAP
# ================================================================================
-# Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 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.
@@ -20,7 +20,7 @@
interpolation.no=no
interpolation.env=${env:HOME}
-interpolation.const=${const:org.onap.policy.drools.utils.logging.LoggerUtil.ROOT_LOGGER}
+interpolation.const=${const:org.onap.policy.common.utils.logging.LoggerUtils.ROOT_LOGGER}
interpolation.sys=${sys:user.home}
interpolation.envd=${envd:HOME}
interpolation.envd.default=${envd:BLAH:default}