-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes the mass of Dev Services logging to a single status line per starting container. This allows the user to see that progress is happening, without flooding the console. If the operation fails all captured output is dumped. Fixes #16203
- Loading branch information
1 parent
5c63f10
commit 34ef1f9
Showing
14 changed files
with
357 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleInstalledBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.quarkus.deployment.console; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
/** | ||
* Build item that signifies that the interactive console is ready. | ||
* | ||
* This will not always be present, as the console may not be installed | ||
*/ | ||
public final class ConsoleInstalledBuildItem extends SimpleBuildItem { | ||
|
||
public static final ConsoleInstalledBuildItem INSTANCE = new ConsoleInstalledBuildItem(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
core/deployment/src/main/java/io/quarkus/deployment/console/StartupLogCompressor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.quarkus.deployment.console; | ||
|
||
import java.io.Closeable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.function.BiPredicate; | ||
|
||
import io.quarkus.deployment.dev.testing.MessageFormat; | ||
import io.quarkus.deployment.logging.LoggingSetupBuildItem; | ||
import io.quarkus.dev.console.QuarkusConsole; | ||
import io.quarkus.dev.console.StatusLine; | ||
|
||
/** | ||
* special filter that can be used to compress log messages to a status line | ||
* <p> | ||
* This is useful for Dev Services to show progress without cluttering up the logs | ||
*/ | ||
public class StartupLogCompressor implements Closeable, BiPredicate<String, Boolean> { | ||
|
||
final Thread thread; | ||
final String name; | ||
volatile StatusLine sl; | ||
final List<String> toDump = new ArrayList<>(); | ||
final AtomicInteger COUNTER = new AtomicInteger(); | ||
|
||
public StartupLogCompressor(String name, Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem, | ||
LoggingSetupBuildItem loggingSetupBuildItem) { | ||
ConsoleHelper.installRedirects(); | ||
this.name = name; | ||
this.thread = Thread.currentThread(); | ||
QuarkusConsole.addOutputFilter(this); | ||
sl = QuarkusConsole.INSTANCE.registerStatusLine(1000 + COUNTER.incrementAndGet()); | ||
sl.setMessage(MessageFormat.BLUE + name + MessageFormat.RESET); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
QuarkusConsole.removeOutputFilter(this); | ||
sl.close(); | ||
} | ||
|
||
public void closeAndDumpCaptured() { | ||
QuarkusConsole.removeOutputFilter(this); | ||
sl.close(); | ||
for (var i : toDump) { | ||
QuarkusConsole.INSTANCE.write(true, i); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean test(String s, Boolean errorStream) { | ||
if (Thread.currentThread() == thread) { | ||
if (!QuarkusConsole.INSTANCE.isAnsiSupported()) { | ||
return true; | ||
} | ||
toDump.add(s); | ||
sl.setMessage(MessageFormat.BLUE + name + MessageFormat.RESET + " " + s.replace("\n", "")); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.