-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mmuzikar/side-by-side
Implemented side by side view, added logging feature
- Loading branch information
Showing
42 changed files
with
1,482 additions
and
218 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
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
85 changes: 85 additions & 0 deletions
85
backendprovider/src/main/java/mmuzikar/handlers/LogHandler.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,85 @@ | ||
package mmuzikar.handlers; | ||
|
||
import com.sun.net.httpserver.HttpExchange; | ||
import gherkin.deps.com.google.gson.Gson; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.java.Log; | ||
import org.apache.commons.io.output.TeeOutputStream; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.PrintStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.logging.LogRecord; | ||
import java.util.logging.Logger; | ||
|
||
@Log | ||
public class LogHandler implements Handler { | ||
|
||
private ByteArrayOutputStream outputCopyStream; | ||
private ByteArrayOutputStream outputErrorStream; | ||
private List<LogRecord> records; | ||
|
||
private void setupStdOutput(){ | ||
outputCopyStream = new ByteArrayOutputStream(1000); | ||
outputErrorStream = new ByteArrayOutputStream(1000); | ||
OutputStream outputTee = new TeeOutputStream(System.out, outputCopyStream); | ||
OutputStream errorTee = new TeeOutputStream(System.err, outputErrorStream); | ||
PrintStream outputPrint = new PrintStream(outputTee); | ||
PrintStream errorPrint = new PrintStream(errorTee); | ||
System.setOut(outputPrint); | ||
System.setErr(errorPrint); | ||
} | ||
|
||
private void setupLoggers(){ | ||
Logger global = Logger.getGlobal(); | ||
while (global.getParent() != null){ | ||
global = global.getParent(); | ||
} | ||
global.addHandler(new java.util.logging.Handler() { | ||
@Override | ||
public void publish(LogRecord record) { | ||
records.add(record); | ||
} | ||
|
||
@Override | ||
public void flush() { | ||
|
||
} | ||
|
||
@Override | ||
public void close() throws SecurityException { | ||
|
||
} | ||
}); | ||
} | ||
|
||
public LogHandler() { | ||
records = new ArrayList<>(20); | ||
setupLoggers(); | ||
setupStdOutput(); | ||
} | ||
|
||
@AllArgsConstructor | ||
private class LogPojo { | ||
public Object json; | ||
public String stdout; | ||
public String stderr; | ||
} | ||
|
||
@Override | ||
public void handle(HttpExchange exchange) throws IOException { | ||
try { | ||
LogPojo log = new LogPojo(records, outputCopyStream.toString(), outputErrorStream.toString()); | ||
Handler.sendResponse(exchange, new Gson().toJson(log)); | ||
records.clear(); | ||
outputCopyStream.reset(); | ||
outputErrorStream.reset(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
Handler.sendResponse(exchange, e.getMessage(), 500); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,24 @@ | ||
// Create your own language definition here | ||
// You can safely look at other samples without losing modifications. | ||
// Modifications are not saved on browser refresh/close though -- copy often! | ||
return { | ||
// Set defaultToken to invalid to see what you do not tokenize yet | ||
// defaultToken: 'invalid', | ||
|
||
keywords: [ | ||
'Feature', 'Scenario', 'Background', 'Then', 'When', 'And', 'Given', 'But' | ||
], | ||
|
||
// The main tokenizer for our languages | ||
tokenizer: { | ||
root: [ | ||
[/#.*$/, 'comment'], | ||
[/@[\w\-]*/, 'annotation'], | ||
[/[A-Z][a-z]*/, {cases: { | ||
'@keywords': 'keyword' | ||
}}], | ||
[/"[^\"]*"/, 'string'], | ||
[/\|/, 'delimiter'] | ||
], | ||
}, | ||
}; |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.