Skip to content

Commit 22a7bc2

Browse files
committed
Add debug flag for system output
Signed-off-by: Aaron Lew <[email protected]>
1 parent 1df301d commit 22a7bc2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tuf-cli/src/main/java/dev/sigstore/tuf/cli/TufConformanceServer.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@
3838
public class TufConformanceServer {
3939

4040
private static final Gson GSON = new Gson();
41+
private static boolean debug = false;
4142

4243
private static class ExecuteRequest {
4344
String[] args;
4445
String faketime;
4546
}
4647

4748
public static void main(String[] args) throws Exception {
49+
if (args.length > 0 && "--debug".equals(args[0])) {
50+
debug = true;
51+
}
4852
int port = 8080;
4953
Server server = new Server(port);
5054
server.setHandler(new TufConformanceHandler());
@@ -86,8 +90,10 @@ private static void handleExecute(HttpServletRequest request, HttpServletRespons
8690

8791
try (PrintStream outPs = new PrintStream(outContent, true, StandardCharsets.UTF_8);
8892
PrintStream errPs = new PrintStream(errContent, true, StandardCharsets.UTF_8)) {
89-
System.setOut(outPs);
90-
System.setErr(errPs);
93+
if (!debug) {
94+
System.setOut(outPs);
95+
System.setErr(errPs);
96+
}
9197

9298
Instant fakeNow = Instant.ofEpochSecond(Long.parseLong(executeRequest.faketime));
9399
TestClock.set(Clock.fixed(fakeNow, ZoneOffset.UTC));
@@ -114,8 +120,10 @@ private static void handleExecute(HttpServletRequest request, HttpServletRespons
114120
os.write(responseBytes);
115121
}
116122
} finally {
117-
System.setOut(originalOut);
118-
System.setErr(originalErr);
123+
if (!debug) {
124+
System.setOut(originalOut);
125+
System.setErr(originalErr);
126+
}
119127
TestClock.reset();
120128
}
121129
}

0 commit comments

Comments
 (0)