Commit 2fec6092 authored by Dmitriy Novikov's avatar Dmitriy Novikov
Browse files

Replace @Value with config property

parent 3e61810d
......@@ -27,6 +27,6 @@ import org.springframework.context.annotation.Configuration;
@Setter
@Getter
public class IndexerConfigProperties {
private String logPrefix;
private String recordsTopicName;
}
......@@ -28,7 +28,7 @@ import org.opengroup.osdu.core.common.logging.audit.AuditPayload;
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.Request;
import org.springframework.beans.factory.annotation.Value;
import org.opengroup.osdu.indexer.config.IndexerConfigProperties;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
......@@ -42,48 +42,47 @@ import org.springframework.stereotype.Component;
@Primary
public class JaxRsDpsLog implements AutoCloseable {
@Value("${LOG_PREFIX}")
private String LOG_PREFIX;
private ILogger log;
private DpsHeaders headers;
private final IndexerConfigProperties properties;
private final ILogger log;
private final DpsHeaders headers;
@Inject
public JaxRsDpsLog(ILogger log, DpsHeaders headers) {
public JaxRsDpsLog(IndexerConfigProperties properties, ILogger log, DpsHeaders headers) {
this.properties = properties;
this.log = log;
this.headers = headers;
}
public void audit(AuditPayload auditPayload) {
log.audit(LOG_PREFIX + ".audit", auditPayload, this.getLabels());
log.audit(properties.getLogPrefix() + ".audit", auditPayload, this.getLabels());
}
public void audit(final String loggerName, final AuditPayload auditPayload) {
log.audit(loggerName, LOG_PREFIX + ".audit", auditPayload, this.getLabels());
log.audit(loggerName, properties.getLogPrefix() + ".audit", auditPayload, this.getLabels());
}
public void request(Request httpRequest) {
log.request(LOG_PREFIX + ".request", httpRequest, this.getLabels());
log.request(properties.getLogPrefix() + ".request", httpRequest, this.getLabels());
}
public void request(final String loggerName, final Request httpRequest) {
log.request(loggerName, LOG_PREFIX + ".request", httpRequest, this.getLabels());
log.request(loggerName, properties.getLogPrefix() + ".request", httpRequest, this.getLabels());
}
public void info(String message) {
log.info(LOG_PREFIX + ".app", message, this.getLabels());
log.info(properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void info(final String loggerName, final String message) {
log.info(loggerName, LOG_PREFIX + ".app", message, this.getLabels());
log.info(loggerName, properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void debug(String message) {
log.debug(LOG_PREFIX + ".app", message, this.getLabels());
log.debug(properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void debug(final String loggerName, final String message) {
log.debug(loggerName, LOG_PREFIX + ".app", message, this.getLabels());
log.debug(loggerName, properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void debug(List<String> messages) {
......@@ -91,15 +90,15 @@ public class JaxRsDpsLog implements AutoCloseable {
return;
}
log.debug(LOG_PREFIX + ".app", prepareLoggingMessage(messages), this.getLabels());
log.debug(properties.getLogPrefix() + ".app", prepareLoggingMessage(messages), this.getLabels());
}
public void warning(String message) {
log.warning(LOG_PREFIX + ".app", message, this.getLabels());
log.warning(properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void warning(final String loggerName, final String message) {
log.warning(loggerName, LOG_PREFIX + ".app", message, this.getLabels());
log.warning(loggerName, properties.getLogPrefix() + ".app", message, this.getLabels());
}
private String prepareLoggingMessage(List<String> messages) {
......@@ -117,7 +116,7 @@ public class JaxRsDpsLog implements AutoCloseable {
return;
}
log.warning(LOG_PREFIX + ".app", prepareLoggingMessage(messages), this.getLabels());
log.warning(properties.getLogPrefix() + ".app", prepareLoggingMessage(messages), this.getLabels());
}
public void warning(final String loggerName, final List<String> messages) {
......@@ -125,31 +124,31 @@ public class JaxRsDpsLog implements AutoCloseable {
return;
}
log.warning(loggerName, LOG_PREFIX + ".app", prepareLoggingMessage(messages), this.getLabels());
log.warning(loggerName, properties.getLogPrefix() + ".app", prepareLoggingMessage(messages), this.getLabels());
}
public void warning(String message, Exception e) {
log.warning(LOG_PREFIX + ".app", message, e, this.getLabels());
log.warning(properties.getLogPrefix() + ".app", message, e, this.getLabels());
}
public void warning(final String loggerName, final String message, final Exception e) {
log.warning(loggerName, LOG_PREFIX + ".app", message, e, this.getLabels());
log.warning(loggerName, properties.getLogPrefix() + ".app", message, e, this.getLabels());
}
public void error(String message) {
log.error(LOG_PREFIX + ".app", message, this.getLabels());
log.error(properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void error(final String loggerName, final String message) {
log.error(loggerName, LOG_PREFIX + ".app", message, this.getLabels());
log.error(loggerName, properties.getLogPrefix() + ".app", message, this.getLabels());
}
public void error(String message, Exception e) {
log.error(LOG_PREFIX + ".app", message, e, this.getLabels());
log.error(properties.getLogPrefix() + ".app", message, e, this.getLabels());
}
public void error(final String loggerName, final String message, final Exception e) {
log.error(loggerName, LOG_PREFIX + ".app", message, e, this.getLabels());
log.error(loggerName, properties.getLogPrefix() + ".app", message, e, this.getLabels());
}
@Override
......
Supports Markdown
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