Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 97e1c17

Browse files
committed
Fixes thaliproject#129: Add Option to Write Tor Process InputStream to Console
1 parent 06b419b commit 97e1c17

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

universal/src/main/java/com/msopentech/thali/toronionproxy/OnionProxyManager.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,10 @@ private Process spawnTorProcess() throws IOException {
461461
LOG.warn(e.toString(), e);
462462
throw new IOException(e);
463463
}
464-
eatStream(torProcess.getErrorStream());
464+
eatStream(torProcess.getErrorStream(), true);
465+
if (getContext().getSettings().hasDebugLogs()) {
466+
eatStream(torProcess.getInputStream(), false);
467+
}
465468
return torProcess;
466469
}
467470

@@ -504,16 +507,20 @@ private void waitForCookieAuthFileCreation(File cookieAuthFile) throws IOExcepti
504507
LOG.info("Created cookie auth file: time = " + (System.currentTimeMillis() - cookieAuthStartTime) + "ms");
505508
}
506509

507-
private void eatStream(final InputStream inputStream) {
510+
private void eatStream(final InputStream inputStream, boolean isError) {
508511
new Thread() {
509512
@Override
510513
public void run() {
511514
Scanner scanner = new Scanner(inputStream);
512515
try {
513516
while (scanner.hasNextLine()) {
514-
String error = scanner.nextLine();
515-
LOG.error(error);
516-
eventBroadcaster.broadcastException(error, new Exception());
517+
String line = scanner.nextLine();
518+
if(isError) {
519+
LOG.error(line);
520+
eventBroadcaster.broadcastException(line, new Exception());
521+
} else {
522+
LOG.info(line);
523+
}
517524
}
518525
} finally {
519526
try {

0 commit comments

Comments
 (0)