Replaced MsoLogger with plain slf4j.
Refactored login output.
Change-Id: I3ff1882406782d64cf0f572c574ab1068449f76b
Issue-ID: LOG-631
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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 javax.ws.rs.NotFoundException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RestRequest implements Callable<Response> {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RestRequest.class);
+ private static final Logger logger = LoggerFactory.getLogger(RestRequest.class);
private final RestClient client;
private final String method;
mapper.get().map(response);
} catch (NotFoundException e) {
if (this.client.props.mapNotFoundToEmpty() && "GET".equals(method)) {
- msoLogger.debug("RestClient recieved not found on URL: " + this.client.getWebTarget().getUri());
+ logger.debug("RestClient recieved not found on URL: {}", this.client.getWebTarget().getUri());
return response;
} else {
throw e;
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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 java.net.InetAddress;
import java.net.UnknownHostException;
-import org.onap.so.utils.UUIDChecker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.LoggerContextListener;
import ch.qos.logback.core.Context;
@Component
public class LoggerStartupListener extends ContextAwareBase implements LoggerContextListener, LifeCycle {
- private boolean started = false;
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, LoggerStartupListener.class);
+ private boolean started = false;
+ private static final Logger logger = LoggerFactory.getLogger(LoggerStartupListener.class);
@Override
public void start() {
try {
addr = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
- LOGGER.error("UnknownHostException",e);
+ logger.error("UnknownHostException",e);
}
Context context = getContext();
return true;
}
- @Override
- public void onLevelChange(Logger arg0, Level arg1) {
- }
-
@Override
public void onReset(LoggerContext arg0) {
}
@Override
public void onStop(LoggerContext arg0) {
}
+
+ @Override
+ public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) {
+ }
}
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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.so.openpojo.rules;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
-import org.onap.so.logger.MsoLogger;
import com.openpojo.reflection.PojoField;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HasAnnotationPropertyWithValueMatcher<T extends PojoField> extends TypeSafeDiagnosingMatcher<T> {
- private MsoLogger logger=MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, HasAnnotationPropertyWithValueMatcher.class);
+ private Logger logger = LoggerFactory.getLogger(HasAnnotationPropertyWithValueMatcher.class);
private final String attribute;
private final Matcher<?> annotationMatcher;
private final Class<? extends Annotation> annotationClass;
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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 org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.crypto.Cipher;
import javax.crypto.spec.GCMParameterSpec;
*/
public final class CryptoUtils {
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CryptoUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger(CryptoUtils.class);
+
private static final String AES = "AES";
private static final String CLOUD_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
try {
return CryptoUtils.encrypt(message, CLOUD_KEY);
} catch (GeneralSecurityException e) {
- LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e);
- return null;
- }
+ logger.error("{} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(),
+ MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in encryptPassword ", e);
+ return null;
+ }
}
public static String decryptCloudConfigPassword(String message) {
try {
return CryptoUtils.decrypt(message, CLOUD_KEY);
} catch (GeneralSecurityException e) {
- LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e);
- return null;
- }
+ logger.error("{} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(),
+ MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in encryptPassword ", e);
+ return null;
+ }
}
private static SecretKeySpec getSecretKeySpec (String keyString) {
byte[] key = hexStringToByteArray (keyString);
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*/
public class UUIDChecker {
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, UUIDChecker.class);
+
+ private static final Logger logger = LoggerFactory.getLogger(UUIDChecker.class);
+
private UUIDChecker() {
UUID uuid = UUID.fromString(id);
return uuid.toString().equalsIgnoreCase(id);
} catch (IllegalArgumentException iae) {
- LOGGER.debug("IllegalArgumentException", iae);
+ logger.debug("IllegalArgumentException", iae);
return false;
}
}
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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 org.onap.so.exceptions.MarshallerException;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
public class XmlMarshaller {
- private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, XmlMarshaller.class);
+ private static Logger logger = LoggerFactory.getLogger(XmlMarshaller.class);
public static String marshal(Object object) throws MarshallerException {
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.marshal(object, stringWriter);
} catch (JAXBException e) {
- logger.error(MessageEnum.GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.SchemaError, e.getMessage(), e);
+ logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(),
+ MsoLogger.ErrorCode.SchemaError.getValue(), e.getMessage(), e);
throw new MarshallerException(e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e);
}
SAXSource source = new SAXSource(xmlReader, inputSource);
object = jaxbUnmarshaller.unmarshal(source, object.getClass()).getValue();
} catch (Exception e) {
- logger.error(MessageEnum.GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.SchemaError, e.getMessage(), e);
+ logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(),
+ MsoLogger.ErrorCode.SchemaError.getValue(), e.getMessage(), e);
throw new MarshallerException(e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e);
}
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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 javax.ws.rs.ext.ExceptionMapper;
-import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
- private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RuntimeExceptionMapper.class);
+ private static Logger logger = LoggerFactory.getLogger(RuntimeExceptionMapper.class);
@Override
public Response toResponse(RuntimeException exception) {
if (exception instanceof NotFoundException) {
return Response.status(Status.NOT_FOUND).build();
} else {
-
- logger.error(exception);
+ logger.error("Error occured", exception);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(new ExceptionResponse("Unexpected Internal Exception")).build();
}
}