Commit 159494d4 authored by Kelly Domico's avatar Kelly Domico
Browse files

Removed info throwable method

parent 5b05f304
Pipeline #14458 failed with stage
package org.opengroup.osdu.azure.logging;
import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.telemetry.ExceptionTelemetry;
import com.microsoft.applicationinsights.telemetry.SeverityLevel;
import org.opengroup.osdu.core.common.logging.audit.AuditPayload;
import org.slf4j.Logger;
......@@ -17,7 +15,7 @@ public class CoreLogger implements ICoreLogger {
private Logger logger;
/**
* @param traceLogger the logger instance
* @param traceLogger the logger instance
* @param appInsightsClient the Application Insights telemetry client
*/
public CoreLogger(final Logger traceLogger, final TelemetryClient appInsightsClient) {
......@@ -46,18 +44,6 @@ public class CoreLogger implements ICoreLogger {
this.logger.info(format, arguments);
}
/**
* Log an exception (throwable) at the INFO level with an accompanying message.
*
* @param msg the message accompanying the exception
* @param t the exception (throwable) to log
*/
@Override
public void info(String msg, Throwable t) {
ExceptionTelemetry et = this.getExceptionTelemetry(SeverityLevel.Information, t);
this.telemetryClient.trackException(et);
}
/**
* Log a message at the WARN level.
*
......@@ -87,7 +73,7 @@ public class CoreLogger implements ICoreLogger {
*/
@Override
public void warn(String msg, Throwable t) {
this.telemetryClient.trackException(this.getExceptionTelemetry(SeverityLevel.Warning, t));
this.logger.warn(msg, t);
}
/**
......@@ -119,7 +105,7 @@ public class CoreLogger implements ICoreLogger {
*/
@Override
public void error(String msg, Throwable t) {
this.telemetryClient.trackException(this.getExceptionTelemetry(SeverityLevel.Error, t));
this.logger.error(msg, t);
}
/**
......@@ -146,10 +132,4 @@ public class CoreLogger implements ICoreLogger {
public void logDependency(String name, String data, Duration duration, boolean success, Map<String, String> additionalProperties) {
// To be implemented
}
public ExceptionTelemetry getExceptionTelemetry(SeverityLevel severityLevel, Throwable t) {
ExceptionTelemetry et = new ExceptionTelemetry(t);
et.setSeverityLevel(severityLevel);
return et;
}
}
......@@ -21,14 +21,6 @@ public interface ICoreLogger {
*/
public void info(String format, Object... arguments);
/**
* Log an exception (throwable) at the INFO level with an accompanying message.
*
* @param msg the message accompanying the exception
* @param t the exception (throwable) to log
*/
public void info(String msg, Throwable t);
/**
* Log a message at the WARN level.
*
......
package org.opengroup.osdu.azure.logging;
import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.telemetry.ExceptionTelemetry;
import com.microsoft.applicationinsights.telemetry.SeverityLevel;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -53,17 +51,6 @@ public class CoreLoggerTest {
verify(spySlf4jLogger).info("{} {} {}", ARG1, ARG2, ARG3);
}
@Test
public void testInfoWithThrowable() {
Exception e = new Exception(EXCEPTION_MESSAGE);
ExceptionTelemetry et = new ExceptionTelemetry(e);
et.setSeverityLevel(SeverityLevel.Information);
when(coreLogger.getExceptionTelemetry(eq(SeverityLevel.Information), any())).thenReturn(et);
coreLogger.info(LOG_MESSAGE, e);
verify(telemetryClient).trackException(eq(et));
}
@Test
public void testWarnWithMessage() {
coreLogger.warn(LOG_MESSAGE);
......@@ -79,12 +66,9 @@ public class CoreLoggerTest {
@Test
public void testWarnWithThrowable() {
Exception e = new Exception(EXCEPTION_MESSAGE);
ExceptionTelemetry et = new ExceptionTelemetry(e);
et.setSeverityLevel(SeverityLevel.Warning);
when(coreLogger.getExceptionTelemetry(eq(SeverityLevel.Warning), any())).thenReturn(et);
coreLogger.warn(LOG_MESSAGE, e);
verify(telemetryClient).trackException(eq(et));
verify(spySlf4jLogger).warn(LOG_MESSAGE, e);
}
@Test
......@@ -102,12 +86,9 @@ public class CoreLoggerTest {
@Test
public void testErrorWithThrowable() {
Exception e = new Exception(EXCEPTION_MESSAGE);
ExceptionTelemetry et = new ExceptionTelemetry(e);
et.setSeverityLevel(SeverityLevel.Error);
when(coreLogger.getExceptionTelemetry(eq(SeverityLevel.Error), any())).thenReturn(et);
coreLogger.error(LOG_MESSAGE, e);
verify(telemetryClient).trackException(eq(et));
verify(spySlf4jLogger).error(LOG_MESSAGE, e);
}
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment