Skip to content

Commit

Permalink
Merge HenrikPoulsen/master in
Browse files Browse the repository at this point in the history
  • Loading branch information
hymerman committed Oct 26, 2015
2 parents 98ae8a4 + c23990f commit 819abe6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
lib/
out/
*.iws
77 changes: 12 additions & 65 deletions agent/src/unityRunner/agent/UnityRunner.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package unityRunner.agent;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;
import org.apache.commons.io.input.Tailer;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -84,17 +83,16 @@ List<String> getArgs() {
* start the unity runner
*/
public void start() {
//
// logMessage("[Starting UnityRunner]");
//
// Thread runnerThread = new Thread(new Runnable() {
// @Override
// public void run() {
// tailLogFile();
// }
// });
// runnerThread.start();
logMessage("[Unity runner is started, but waiting until end to cat log file]");

logMessage("[Starting UnityRunner]");

Thread runnerThread = new Thread(new Runnable() {
@Override
public void run() {
tailLogFile();
}
});
runnerThread.start();

if (configuration.clearBefore) {
clearBefore();
Expand Down Expand Up @@ -126,56 +124,6 @@ private void tailLogFile() {

}

/**
* cat the log file instead of tailing it
*/
private void catLogFile() {
logMessage("[Catting log file]");
if ( configuration.ignoreLogBefore) {
logMessage("[Ignoring lines before text "+configuration.ignoreLogBeforeText +"]");
}

File file = new File(configuration.getInterestedLogPath());

// for each line
try {
LineIterator iterator = FileUtils.lineIterator(file);
List<String> ignoredLines = new ArrayList<String>();
boolean stillIgnoringLines = configuration.ignoreLogBefore;
try {
while (iterator.hasNext()) {
String line = iterator.nextLine();
if (stillIgnoringLines && line.contentEquals(configuration.ignoreLogBeforeText)){
stillIgnoringLines = false;
}

if (line.length() > 0) {
if ( stillIgnoringLines ) {
// add the message to the ignored group
ignoredLines.add(line);
} else {
// log the message
logMessage(line);
}
}
}
if (stillIgnoringLines) {
// we have finished processing the log and we've ignored everything
logMessage("[The configured text has not been found: "+configuration.ignoreLogBeforeText +"]");
// we better output all these lines
logMessages(ignoredLines);
}
} finally {
iterator.close();
}

} catch (IOException e) {
e.printStackTrace();
}


}

private void logMessages(List<String> lines) {
for (String line : lines){
logMessage(line);
Expand All @@ -186,9 +134,8 @@ private void logMessages(List<String> lines) {
* stop the runner
*/
public void stop() {
catLogFile();
// stop = true;
// logMessage("[Stop UnityRunner]");
stop = true;
logMessage("[Stop UnityRunner]");

}

Expand Down

0 comments on commit 819abe6

Please sign in to comment.