1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-21 15:28:52 -05:00

Improved logging for large scripts passed in as argument messing up the log lines

This commit is contained in:
Reinhard Pointner 2019-06-10 22:47:38 +07:00
parent 4a19490f01
commit aa7234982d
2 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package net.filebot;
import static java.nio.channels.Channels.*;
import static java.util.Arrays.*;
import static java.util.stream.Collectors.*;
import static net.filebot.util.RegularExpressions.*;
import java.io.File;
import java.io.FileOutputStream;
@ -96,6 +97,10 @@ public final class Logging {
return () -> String.format(format, args);
}
public static Supplier<String> formatSingleLine(String format, Object... args) {
return () -> NEWLINE.splitAsStream(String.format(format, args)).map(String::trim).filter(s -> !s.isEmpty()).collect(joining(""));
}
public static Supplier<String> trace(Throwable t) {
return () -> {
StringBuilder s = new StringBuilder();

View File

@ -891,7 +891,7 @@ public class CmdlineOperations implements CmdlineInterface {
return input;
}
log.fine(format("Apply filter [%s] on [%d] items", filter.getExpression(), input.size()));
log.fine(formatSingleLine("Apply filter [%s] on [%d] items", filter.getExpression(), input.size()));
// support context bindings
Map<File, ?> context = new EntryList<File, T>(null, input);
@ -910,7 +910,7 @@ public class CmdlineOperations implements CmdlineInterface {
return episodes;
}
log.fine(format("Apply mapper [%s] on [%d] items", mapper.getExpression(), episodes.size()));
log.fine(formatSingleLine("Apply mapper [%s] on [%d] items", mapper.getExpression(), episodes.size()));
// support episode list context
Map<File, Episode> context = new EntryList<File, Episode>(null, episodes);