mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
Support Logger#log(Level,String,Object)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
874bf4ef4c
commit
6159f5cd3c
@ -80,6 +80,30 @@ public class Logger {
|
||||
log(level, Method.getCaller(), message, exception);
|
||||
}
|
||||
|
||||
public void log(Level level, String message, Object param) {
|
||||
log(level, Method.getCaller(), replaceParameters(message, param), null);
|
||||
}
|
||||
|
||||
private static String replaceParameters(String message, Object... params) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int offset = 0;
|
||||
for (int i = 0; i < params.length; ++i) {
|
||||
int curly = message.indexOf("{}", offset);
|
||||
if (curly < 0) {
|
||||
break;
|
||||
}
|
||||
if (curly > offset) {
|
||||
builder.append(message, offset, curly);
|
||||
}
|
||||
offset = curly + 2;
|
||||
builder.append(params[i]);
|
||||
}
|
||||
if (message.length() > offset) {
|
||||
builder.append(message, offset, message.length());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public void logp(Level level, String sourceClass, String sourceMethod, String msg) {
|
||||
if (!isLoggable(level)) {
|
||||
return;
|
||||
|
@ -66,7 +66,7 @@ public class Logging {
|
||||
public void run() {
|
||||
log.info("Started run");
|
||||
a();
|
||||
log.info("Ended run");
|
||||
log.log(Level.INFO, "Ended {}!", "run");
|
||||
}
|
||||
|
||||
private void a() {
|
||||
|
Loading…
Reference in New Issue
Block a user