mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 04:53:16 +00:00
[CST-6265] Fixed message formatting
fix: - message formatting for logInfo was done twice feat: - message inside logWarn was not formatted when using handler
This commit is contained in:
@@ -189,8 +189,7 @@ public class Curation extends DSpaceRunnable<CurationScriptConfiguration> {
|
||||
* @throws FileNotFoundException If file of command line variable -r reporter is not found
|
||||
*/
|
||||
private Curator initCurator() throws FileNotFoundException {
|
||||
Curator curator = new Curator();
|
||||
curator.setLogHandler(handler);
|
||||
Curator curator = new Curator(handler);
|
||||
OutputStream reporterStream;
|
||||
if (null == this.reporter) {
|
||||
reporterStream = new NullOutputStream();
|
||||
|
@@ -9,6 +9,7 @@ package org.dspace.curate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -93,6 +94,16 @@ public class Curator {
|
||||
protected HandleService handleService;
|
||||
protected DSpaceRunnableHandler handler;
|
||||
|
||||
/**
|
||||
* constructor that uses an handler for logging
|
||||
*
|
||||
* @param handler {@code DSpaceRunnableHandler} used to logs infos
|
||||
*/
|
||||
public Curator(DSpaceRunnableHandler handler) {
|
||||
this();
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* No-arg constructor
|
||||
*/
|
||||
@@ -607,11 +618,11 @@ public class Curator {
|
||||
return mb.toString();
|
||||
}
|
||||
|
||||
protected void logInfo(String id) {
|
||||
protected void logInfo(String message) {
|
||||
if (handler == null) {
|
||||
log.info(logMessage(id));
|
||||
log.info(message);
|
||||
} else {
|
||||
handler.logInfo(logMessage(id));
|
||||
handler.logInfo(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,11 +640,11 @@ public class Curator {
|
||||
log.warn(message);
|
||||
}
|
||||
} else {
|
||||
handler.logWarning(message);
|
||||
if (object != null) {
|
||||
handler.logWarning(MessageFormat.format(message, object));
|
||||
} else {
|
||||
handler.logWarning(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setLogHandler(DSpaceRunnableHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user