mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-13 13:03:11 +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
|
* @throws FileNotFoundException If file of command line variable -r reporter is not found
|
||||||
*/
|
*/
|
||||||
private Curator initCurator() throws FileNotFoundException {
|
private Curator initCurator() throws FileNotFoundException {
|
||||||
Curator curator = new Curator();
|
Curator curator = new Curator(handler);
|
||||||
curator.setLogHandler(handler);
|
|
||||||
OutputStream reporterStream;
|
OutputStream reporterStream;
|
||||||
if (null == this.reporter) {
|
if (null == this.reporter) {
|
||||||
reporterStream = new NullOutputStream();
|
reporterStream = new NullOutputStream();
|
||||||
|
@@ -9,6 +9,7 @@ package org.dspace.curate;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -93,6 +94,16 @@ public class Curator {
|
|||||||
protected HandleService handleService;
|
protected HandleService handleService;
|
||||||
protected DSpaceRunnableHandler handler;
|
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
|
* No-arg constructor
|
||||||
*/
|
*/
|
||||||
@@ -607,11 +618,11 @@ public class Curator {
|
|||||||
return mb.toString();
|
return mb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void logInfo(String id) {
|
protected void logInfo(String message) {
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
log.info(logMessage(id));
|
log.info(message);
|
||||||
} else {
|
} else {
|
||||||
handler.logInfo(logMessage(id));
|
handler.logInfo(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,11 +640,11 @@ public class Curator {
|
|||||||
log.warn(message);
|
log.warn(message);
|
||||||
}
|
}
|
||||||
} else {
|
} 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