Commit 04e96814 authored by Preksha Beohar-Slb's avatar Preksha Beohar-Slb
Browse files

reverted formatting

parent 861fd5c0
Pipeline #49603 passed with stages
in 8 minutes and 48 seconds
......@@ -29,21 +29,16 @@ public class DefaultLogWriter implements ILogWriter {
public void writeJsonEntry(String logname, Map<String, Object> json, Map<String, String> labels) {
log.log(Level.INFO, String.format("%s %s", json, labels));
}
public void writeJsonEntry(String logname, Level severity, Map<String, Object> json, Map<String, String> labels) {
log.log(severity, String.format("%s: %s %s", logname, json, labels));
}
public void writeRequestEntry(String logname, String text, Request request, Map<String, String> labels) {
log.log(Level.INFO, String.format("%s %s %s", text, request, labels));
}
public void writeEntry(String logname, Level severity, String text, Map<String, String> labels) {
public void writeEntry(String logname, Level severity, String text, Map<String, String> labels){
log.log(severity, String.format("%s: %s %s", logname, text, labels));
}
@Override
public void close() {
//do nothing
......
......@@ -34,33 +34,29 @@ public class DefaultLogger implements ILogger {
logWriter = new DefaultLogWriter();
this.headersToLog = new HeadersToLog(Collections.emptyList());
}
public DefaultLogger(HeadersToLog headersToLog, ILogWriter logWriter) {
if (headersToLog == null)
if(headersToLog == null)
throw new IllegalArgumentException("Null HeadersToLog provided");
if (logWriter == null)
if(logWriter == null)
throw new IllegalArgumentException("Null Logger provided");
this.logWriter = logWriter;
this.headersToLog = headersToLog;
}
@Override
public void audit(String logPrefix, AuditPayload payload, Map<String, String> headers) {
public void audit(String logPrefix, AuditPayload payload, Map<String, String> headers){
logWriter.writeJsonEntry(logPrefix, payload, headersToLog.createStandardLabelsFromMap(headers));
}
@Override
public void auditDebugLog(String logPrefix, AuditPayload payload, Map<String, String> headers) {
logWriter.writeJsonEntry(logPrefix, Level.FINE, payload, headersToLog.createStandardLabelsFromMap(headers));
}
@Override
public void request(String logPrefix, Request request, Map<String, String> labels) {
logWriter.writeRequestEntry(logPrefix, "#RequestLog", request, headersToLog.createStandardLabelsFromMap(labels));
public void request(String logPrefix, Request request, Map<String, String> labels){
logWriter.writeRequestEntry(logPrefix,"#RequestLog", request, headersToLog.createStandardLabelsFromMap(labels));
}
@Override
public void info(String logPrefix, String message, Map<String, String> labels) {
public void info(String logPrefix, String message, Map<String, String> labels){
logWriter.writeEntry(logPrefix, Level.INFO, message, headersToLog.createStandardLabelsFromMap(labels));
}
......@@ -70,30 +66,26 @@ public class DefaultLogger implements ILogger {
}
@Override
public void warning(String logPrefix, String message, Map<String, String> labels) {
public void warning(String logPrefix, String message, Map<String, String> labels){
logWriter.writeEntry(logPrefix, Level.WARNING, message, headersToLog.createStandardLabelsFromMap(labels));
}
@Override
public void warning(String logPrefix, String message, Exception ex, Map<String, String> labels) {
public void warning(String logPrefix, String message, Exception ex, Map<String, String> labels){
String exString = Throwables.getStackTraceAsString(ex);
logWriter.writeEntry(logPrefix, Level.WARNING, String.format("%s\n%s", message, exString), headersToLog.createStandardLabelsFromMap(labels));
}
@Override
public void error(String logPrefix, String message, Map<String, String> labels) {
public void error(String logPrefix, String message, Map<String, String> labels){
logWriter.writeEntry(logPrefix, Level.SEVERE, message, headersToLog.createStandardLabelsFromMap(labels));
}
@Override
public void error(String logPrefix, String message, Exception ex, Map<String, String> labels) {
public void error(String logPrefix, String message, Exception ex, Map<String, String> labels){
String exString = Throwables.getStackTraceAsString(ex);
logWriter.writeEntry(logPrefix, Level.SEVERE, String.format("%s\n%s", message, exString), headersToLog.createStandardLabelsFromMap(labels));
}
@Override
public void close() throws Exception {
if (logWriter != null) {
if(logWriter != null) {
logWriter.close();
}
}
......
......@@ -18,10 +18,10 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHeaders;
import org.opengroup.osdu.core.common.model.AppEngineHeaders;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.http.HeadersToLog;
import org.opengroup.osdu.core.common.model.http.Request;
import org.opengroup.osdu.core.common.logging.audit.AuditPayload;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.logging.LogLevel;
import org.springframework.stereotype.Component;
import org.springframework.web.context.annotation.RequestScope;
......@@ -41,7 +41,7 @@ public class JaxRsDpsLog implements AutoCloseable {
private DpsHeaders headers;
@Inject
public JaxRsDpsLog(ILogger log, DpsHeaders headers) {
public JaxRsDpsLog(ILogger log, DpsHeaders headers){
this.log = log;
this.headers = headers;
}
......
......@@ -24,7 +24,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.opengroup.osdu.core.common.logging.audit.AuditPayload;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.http.Request;
import org.springframework.boot.logging.LogLevel;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
......
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