mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Avoid redirecting System.out
GitOrigin-RevId: 451a89190f2089b3053763f41a96d84fa5c3093e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b90e7ecd88
commit
339e3a45d4
@@ -124,6 +124,10 @@ public final class TestLoggerFactory implements Logger.Factory {
|
||||
}
|
||||
|
||||
public static void dumpLogToStdout(@NotNull String testStartMarker) {
|
||||
dumpLogTo(testStartMarker, System.out);
|
||||
}
|
||||
|
||||
public static void dumpLogTo(@NotNull String testStartMarker, PrintStream out) {
|
||||
Path logFile = getTestLogDir().resolve(LOG_FILE_NAME);
|
||||
if (Files.exists(logFile)) {
|
||||
try {
|
||||
@@ -142,12 +146,12 @@ public final class TestLoggerFactory implements Logger.Factory {
|
||||
logText = Files.readString(logFile);
|
||||
}
|
||||
|
||||
System.out.println("\n\nIdea Log:");
|
||||
out.println("\n\nIdea Log:");
|
||||
Pattern logStart = Pattern.compile("[\\d\\-, :\\[\\]]+(DEBUG|INFO|ERROR) - ");
|
||||
for (String line : StringUtil.splitByLines(logText.substring(Math.max(0, logText.lastIndexOf(testStartMarker))))) {
|
||||
Matcher matcher = logStart.matcher(line);
|
||||
int lineStart = matcher.lookingAt() ? matcher.end() : 0;
|
||||
System.out.println(line.substring(lineStart));
|
||||
out.println(line.substring(lineStart));
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
+3
-10
@@ -825,16 +825,9 @@ class ModuleBridgesTest {
|
||||
}
|
||||
|
||||
fun catchLog(): String {
|
||||
val prev = System.out
|
||||
return try {
|
||||
val outCatcher = OutCatcher(System.out)
|
||||
System.setOut(outCatcher)
|
||||
TestLoggerFactory.dumpLogToStdout(logLine)
|
||||
outCatcher.catcher
|
||||
}
|
||||
finally {
|
||||
System.setOut(prev)
|
||||
}
|
||||
val outCatcher = OutCatcher(System.out)
|
||||
TestLoggerFactory.dumpLogTo(logLine, outCatcher)
|
||||
return outCatcher.catcher
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user