diff options
Diffstat (limited to 'cmso-optimizer/src')
6 files changed, 25 insertions, 123 deletions
diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java index e6aa29e..faba1df 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java @@ -34,8 +34,8 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; -import org.onap.optf.cmso.optimizer.observations.ObservationInterface; +import org.apache.logging.log4j.Level; +import org.onap.observations.ObservationInterface; /** * The Enum LogMessages. diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java index f780390..d2d1cc7 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java @@ -30,8 +30,8 @@ import com.att.eelf.i18n.EELFResourceManager; import java.util.ArrayList; import java.util.List; import javax.ws.rs.core.Response.Status; +import org.onap.observations.ObservationInterface; import org.onap.optf.cmso.optimizer.common.CmsoRequestError; -import org.onap.optf.cmso.optimizer.observations.ObservationInterface; /** * The Class CMSException. diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java index 66834fa..e994d18 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java @@ -38,10 +38,9 @@ import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY; import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME; import com.att.eelf.utils.Stopwatch; -import java.net.URI; -import java.util.Date; -import java.util.Map; -import java.util.UUID; +import org.onap.observations.ObservationInterface; +import org.onap.optf.cmso.optimizer.observations.MessageHeaders.HeadersEnum; +import org.slf4j.MDC; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; @@ -49,8 +48,10 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response.StatusType; -import org.onap.optf.cmso.optimizer.observations.MessageHeaders.HeadersEnum; -import org.slf4j.MDC; +import java.net.URI; +import java.util.Date; +import java.util.Map; +import java.util.UUID; /** * EELF logging MDC fields not defined in the MDC Configuration (i.e. MDC_ALERT_SEVERITY) diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java index cb36e40..baedf3a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java @@ -1,5 +1,6 @@ /* * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. * * 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 @@ -28,10 +29,10 @@ package org.onap.optf.cmso.optimizer.observations; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.apache.log4j.Level; +import org.onap.logger.Logger; +import org.onap.observations.ObservationInterface; import org.onap.optf.cmso.optimizer.Application; - /** * The Class Observation. */ @@ -42,88 +43,36 @@ public class Observation { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + private static Logger logger = new Logger(log, metrics, audit, errors, debug); + + /** * Report. * - * @param obs the o - * @param execpt the e + * @param obs the o + * @param except the e * @param arguments the arguments */ // ************************************************************************************************* - public static void report(ObservationInterface obs, Exception execpt, String... arguments) { + public static void report(ObservationInterface obs, Exception except, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, execpt, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, execpt, arguments); - } - Level lev = obs.getLevel(); - switch (lev.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.INFO_INT: - log.info(obs, execpt, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.TRACE_INT: - debug.trace(obs, execpt, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, execpt, arguments); - break; - default: - log.info(obs, execpt, arguments); - } + logger.report(obs, except, arguments); Mdc.clearCaller(); } /** * Report. * - * @param obs the o + * @param obs the o * @param arguments the arguments */ public static void report(ObservationInterface obs, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, arguments); - } - Level levl = obs.getLevel(); - switch (levl.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.INFO_INT: - log.info(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.TRACE_INT: - debug.debug(obs, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, arguments); - break; - default: - log.info(obs, arguments); - } + logger.report(obs, arguments); Mdc.clearCaller(); } + } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationInterface.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationInterface.java deleted file mode 100644 index 2b4ff58..0000000 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationInterface.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2019 AT&T Intellectual Property. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed under the Creative - * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except - * in compliance with the License. You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation 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. - */ - -package org.onap.optf.cmso.optimizer.observations; - -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; - -public interface ObservationInterface extends EELFResolvableErrorEnum { - public Enum<?> getValue(); - - public Level getLevel(); - - public String getMessage(); - - public Status getStatus(); - - public String getDomain(); - - public String name(); - - public Boolean getAudit(); - - public Boolean getMetric(); -} diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java index 60ba2a1..7d8ee69 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java @@ -28,8 +28,9 @@ package org.onap.optf.cmso.optimizer.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; import com.att.eelf.i18n.EELFResourceManager; +import org.apache.logging.log4j.Level; +import org.onap.observations.ObservationInterface; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; /** |