/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>cmso</artifactId>
+ <groupId>org.onap.optf.cmso</groupId>
+ <version>2.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>cmso-logger</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ <version>${eelf.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ </exclusion>
+
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>${javax.version.rs.api}</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * 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
+ *
+ * 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.logger;
+
+import com.att.eelf.configuration.EELFLogger;
+import org.apache.logging.log4j.spi.StandardLevel;
+import org.onap.observations.ObservationInterface;
+
+public class Logger {
+
+ private final EELFLogger log;
+ private final EELFLogger metrics;
+ private final EELFLogger audit;
+ private final EELFLogger errors;
+ private final EELFLogger debug;
+
+ public Logger(EELFLogger log, EELFLogger metrics, EELFLogger audit, EELFLogger errors, EELFLogger debug) {
+ this.log = log;
+ this.metrics = metrics;
+ this.audit = audit;
+ this.errors = errors;
+ this.debug = debug;
+ }
+
+ public void report(ObservationInterface obs, Exception except, String... arguments) {
+
+ if (obs.getAudit()) {
+ audit.info(obs, except, arguments);
+ }
+ if (obs.getMetric()) {
+ metrics.info(obs, except, arguments);
+ }
+
+ final StandardLevel standardLevel = obs.getLevel().getStandardLevel();
+
+ switch (standardLevel) {
+ case WARN:
+ errors.warn(obs, arguments);
+ debug.debug(obs, except, arguments);
+ break;
+ case INFO:
+ log.info(obs, except, arguments);
+ debug.debug(obs, except, arguments);
+ break;
+ case ERROR:
+ errors.error(obs, arguments);
+ debug.debug(obs, except, arguments);
+ break;
+ case TRACE:
+ debug.trace(obs, except, arguments);
+ break;
+ case DEBUG:
+ debug.debug(obs, except, arguments);
+ break;
+ default:
+ log.info(obs, except, arguments);
+ }
+
+ }
+
+ public void report(ObservationInterface obs, String... arguments) {
+
+ if (obs.getAudit()) {
+ audit.info(obs, arguments);
+ }
+ if (obs.getMetric()) {
+ metrics.info(obs, arguments);
+ }
+
+ final StandardLevel standardLevel = obs.getLevel().getStandardLevel();
+
+ switch (standardLevel) {
+ case WARN:
+ errors.warn(obs, arguments);
+ debug.debug(obs, arguments);
+ break;
+ case INFO:
+ log.info(obs, arguments);
+ debug.debug(obs, arguments);
+ break;
+ case ERROR:
+ errors.error(obs, arguments);
+ debug.debug(obs, arguments);
+ break;
+ case TRACE:
+ debug.debug(obs, arguments);
+ break;
+ case DEBUG:
+ debug.debug(obs, arguments);
+ break;
+ default:
+ log.info(obs, arguments);
+ }
+ }
+}
/*
* 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
package org.onap.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();
+import com.att.eelf.i18n.EELFResolvableErrorEnum;
+import org.apache.logging.log4j.Level;
- public String name();
+import static javax.ws.rs.core.Response.Status;
- public Boolean getAudit();
+public interface ObservationInterface extends EELFResolvableErrorEnum {
- public Boolean getMetric();
+ Enum<?> getValue();
+ Level getLevel();
+ String getMessage();
+ Status getStatus();
+ String getDomain();
+ String name();
+ Boolean getAudit();
+ Boolean getMetric();
}
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- <version>${eelf.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- </exclusion>
-
- </exclusions>
- </dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<!-- <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId>
<version>2.1.1</version> </dependency> -->
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.1</version>
- </dependency>
<!--Swagger Dependencies -->
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>aaf-cadi-aaf</artifactId>
<version>${aaf.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.optf.cmso</groupId>
+ <artifactId>cmso-logger</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
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.
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.
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;
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)
/*
* 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
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.
*/
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();
}
+
}
+++ /dev/null
-/*
- * 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();
-}
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;
/**
<groupId>com.fasterxml.jackson.dataformat</groupId>\r
<artifactId>jackson-dataformat-yaml</artifactId>\r
</dependency>\r
- <dependency>\r
- <groupId>com.att.eelf</groupId>\r
- <artifactId>eelf-core</artifactId>\r
- <version>${eelf.version}</version>\r
- <exclusions>\r
- <exclusion>\r
- <groupId>org.mockito</groupId>\r
- <artifactId>mockito-core</artifactId>\r
- </exclusion>\r
- <exclusion>\r
- <groupId>org.powermock</groupId>\r
- <artifactId>powermock-module</artifactId>\r
- </exclusion>\r
- <exclusion>\r
- <groupId>org.powermock</groupId>\r
- <artifactId>powermock-api-mockito</artifactId>\r
- </exclusion>\r
- <exclusion>\r
- <groupId>org.powermock</groupId>\r
- <artifactId>powermock-module-junit4</artifactId>\r
- </exclusion>\r
-\r
- </exclusions>\r
- </dependency>\r
<dependency>\r
<groupId>org.yaml</groupId>\r
<artifactId>snakeyaml</artifactId>\r
</dependency>\r
<!-- <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId> \r
<version>2.1.1</version> </dependency> -->\r
- <dependency>\r
- <groupId>javax.ws.rs</groupId>\r
- <artifactId>javax.ws.rs-api</artifactId>\r
- <version>2.1</version>\r
- </dependency>\r
\r
<!--Swagger Dependencies -->\r
<dependency>\r
<groupId>org.onap.aaf.authz</groupId>\r
<artifactId>aaf-cadi-aaf</artifactId>\r
<version>${aaf.version}</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>log4j</groupId>\r
+ <artifactId>log4j</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
</dependency>\r
- </dependencies>\r
+ <dependency>\r
+ <groupId>org.onap.optf.cmso</groupId>\r
+ <artifactId>cmso-logger</artifactId>\r
+ <version>2.2.0-SNAPSHOT</version>\r
+ </dependency>\r
+ </dependencies>\r
\r
<build>\r
<finalName>cmso-service</finalName>\r
/*
* 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
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.optf.cmso.Application;
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 except the e
* @param arguments the arguments
*/
// *************************************************************************************************
- public static void report(ObservationInterface obs, Exception execpt, 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);
- }
- Mdc.clearCaller();
+ public static void report(ObservationInterface obs, Exception except, String... arguments) {
+ Mdc.setCaller(4);
+ Mdc.setObservation(obs);
+ logger.report(obs, except, arguments);
+ Mdc.clearCaller();
}
/**
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();
}
import com.att.eelf.i18n.EELFResolvableErrorEnum;
import com.att.eelf.i18n.EELFResourceManager;
+import org.apache.logging.log4j.Level;
+
import javax.ws.rs.core.Response.Status;
-import org.apache.log4j.Level;
/**
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
import java.nio.file.Files;\r
import java.nio.file.Paths;\r
import javax.ws.rs.core.Response.Status;\r
-import org.apache.log4j.Level;\r
+import org.apache.logging.log4j.Level;\r
import org.onap.observations.ObservationInterface;\r
\r
/**\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
* \r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- <version>${eelf.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- </exclusion>
-
- </exclusions>
- </dependency>
<!-- <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId>
<version>2.1.1</version> </dependency> -->
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.1</version>
- </dependency>
<!--Swagger Dependencies -->
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>aaf-cadi-aaf</artifactId>
<version>${aaf.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.optf.cmso</groupId>
+ <artifactId>cmso-logger</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
/*
* 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.
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.apache.log4j.Level;
+import org.onap.logger.Logger;
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.
*
public static void report(ObservationInterface obs, Exception exc, String... arguments) {
Mdc.setCaller(4);
Mdc.setObservation(obs);
- if (obs.getAudit()) {
- audit.info(obs, exc, arguments);
- }
- if (obs.getMetric()) {
- metrics.info(obs, exc, arguments);
- }
- Level lev = obs.getLevel();
- switch (lev.toInt()) {
- case Level.WARN_INT:
- errors.warn(obs, arguments);
- debug.debug(obs, exc, arguments);
- break;
- case Level.INFO_INT:
- log.info(obs, exc, arguments);
- debug.debug(obs, exc, arguments);
- break;
- case Level.ERROR_INT:
- errors.error(obs, arguments);
- debug.debug(obs, exc, arguments);
- break;
- case Level.TRACE_INT:
- debug.trace(obs, exc, arguments);
- break;
- case Level.DEBUG_INT:
- debug.debug(obs, exc, arguments);
- break;
- default:
- log.info(obs, exc, arguments);
- }
+ logger.report(obs, exc, arguments);
Mdc.clearCaller();
}
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 lev = obs.getLevel();
- switch (lev.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();
}
+++ /dev/null
-/*
- * 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.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();
-}
import com.att.eelf.i18n.EELFResolvableErrorEnum;
import com.att.eelf.i18n.EELFResourceManager;
+import org.apache.logging.log4j.Level;
+
import javax.ws.rs.core.Response.Status;
-import org.apache.log4j.Level;
public class ObservationObject implements ObservationInterface {
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.ws.rs.core.Response.Status;
-import org.apache.log4j.Level;
+import org.apache.logging.log4j.Level;
import org.onap.observations.ObservationInterface;
public enum LogMessages implements ObservationInterface {
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- <version>${eelf.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- </exclusion>
-
- </exclusions>
- </dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<!-- <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId>
<version>2.1.1</version> </dependency> -->
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.1</version>
- </dependency>
<!--Swagger Dependencies -->
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>aaf-cadi-aaf</artifactId>
<version>${aaf.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.optf.cmso</groupId>
+ <artifactId>cmso-logger</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
/*
* 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
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.optf.cmso.topology.Application;
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 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();
}
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();
}
+++ /dev/null
-/*
- * 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.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();
-}
import com.att.eelf.i18n.EELFResolvableErrorEnum;
import com.att.eelf.i18n.EELFResourceManager;
+import org.apache.logging.log4j.Level;
import javax.ws.rs.core.Response.Status;
-import org.apache.log4j.Level;
/**
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.ws.rs.core.Response.Status;
-import org.apache.log4j.Level;
+import org.apache.logging.log4j.Level;
import org.onap.observations.ObservationInterface;
public enum LogMessages implements ObservationInterface {
<eelf.version>1.0.0</eelf.version>
<swagger.core.version>2.0.0</swagger.core.version>
<aaf.version>2.1.4</aaf.version>
+ <log4j.version>2.13.1</log4j.version>
+ <javax.version.rs.api>2.1</javax.version.rs.api>
<docker.push.registry>localhost:5000</docker.push.registry>
<docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
<docker.http_proxy></docker.http_proxy>
<module>cmso-ticketmgt</module>
<module>cmso-robot</module>
<module>cmso-sonar</module>
- </modules>
+ <module>cmso-logger</module>
+ </modules>
<build>
<pluginManagement>