-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1186c13
Showing
34 changed files
with
974 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Funky Log Client | ||
|
||
App to view logs from robot code. Utilizes custom compression algorithm to reduce log size by 25% on average. Also includes filtering and searches, which driver station console does not currently provide. Logs are sent over UDP from robot code. FunkyLogServer must be running on robot to receive logs. |
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,51 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.funkylogclient</groupId> | ||
<artifactId>funkylogclient</artifactId> | ||
<version>1.0</version> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-controls</artifactId> | ||
<version>13</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-fxml</artifactId> | ||
<version>13</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<release>11</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.openjfx</groupId> | ||
<artifactId>javafx-maven-plugin</artifactId> | ||
<version>0.0.6</version> | ||
<executions> | ||
<execution> | ||
<!-- Default configuration for running --> | ||
<!-- Usage: mvn clean javafx:run --> | ||
<id>default-cli</id> | ||
<configuration> | ||
<mainClass>com.funkylogclient.App</mainClass> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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,160 @@ | ||
package com.funkylogclient; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.LinkedHashSet; | ||
import java.util.LinkedList; | ||
|
||
import javafx.stage.FileChooser; | ||
import javafx.stage.Stage; | ||
|
||
public class FunkyLogSorter { | ||
private static int MAX_LEN = 1200; | ||
|
||
private static boolean allowErrors = true; | ||
private static boolean allowWarnings = true; | ||
private static boolean allowLogs = true; | ||
|
||
private static String searchTerm = ""; | ||
|
||
public static LinkedList<Message> messages = new LinkedList<>(); | ||
public static LinkedList<Message> filtered = new LinkedList<>(); | ||
|
||
public static void clear() { | ||
messages.clear(); | ||
filtered.clear(); | ||
} | ||
|
||
public static void reFilter() { | ||
filtered.clear(); | ||
|
||
for (Message m : messages) { | ||
if (!checkMessageBySearch(m)) { | ||
continue; | ||
} else if (allowLogs && m.isLog()) { | ||
filtered.add(m); | ||
} else if (allowWarnings && m.isWarning()) { | ||
filtered.add(m); | ||
} else if (allowErrors && m.isError()) { | ||
filtered.add(m); | ||
} | ||
} | ||
} | ||
|
||
private static boolean checkMessageBySearch(Message msg) { | ||
if (searchTerm.equals("")) return true; | ||
|
||
return msg.getSender().contains(searchTerm) || msg.getContent().contains(searchTerm); | ||
} | ||
|
||
public static void trimMessages() { | ||
int currentLength = messages.size(); | ||
|
||
if (currentLength <= MAX_LEN) | ||
return; | ||
|
||
for (int i = 0; i <= currentLength - MAX_LEN; i++) { | ||
messages.removeFirst(); | ||
} | ||
|
||
if (filtered.size() > MAX_LEN) { | ||
reFilter(); | ||
} | ||
} | ||
|
||
public static void addMessage(Message m) { | ||
System.out.println(m); | ||
|
||
messages.add(m); | ||
|
||
if (!checkMessageBySearch(m)) { | ||
|
||
} else if (allowLogs && m.isLog()) { | ||
filtered.add(m); | ||
} else if (allowWarnings && m.isWarning()) { | ||
filtered.add(m); | ||
} else if (allowErrors && m.isError()) { | ||
filtered.add(m); | ||
} | ||
|
||
trimMessages(); | ||
} | ||
|
||
public static void setErrorsAllowed(boolean allow) { | ||
allowErrors = allow; | ||
reFilter(); | ||
} | ||
|
||
public static void setWarningsAllowed(boolean allow) { | ||
allowWarnings = allow; | ||
reFilter(); | ||
} | ||
|
||
public static void setLogsAllowed(boolean allow) { | ||
allowLogs = allow; | ||
reFilter(); | ||
} | ||
|
||
public static void changeSearchTerm(String term) { | ||
searchTerm = term; | ||
reFilter(); | ||
} | ||
|
||
// Only for testing | ||
public static void main(String[] args) { | ||
// addMessage(new Message("0;1.0;a;abc")); | ||
// addMessage(new Message("1;2.0;a;cde")); | ||
// addMessage(new Message("2;2.0;a;cdef")); | ||
|
||
// logAllMessages(); | ||
} | ||
|
||
public static void logAllMessages() { | ||
System.out.println("\nSTART"); | ||
for (Message m : filtered) { | ||
System.out.println(m); | ||
} | ||
System.out.println("END\n"); | ||
} | ||
|
||
public static String stringifyAllMessages() { | ||
StringBuilder result = new StringBuilder(); | ||
for (Message m : messages) { | ||
result.append(m); | ||
result.append("\n"); | ||
} | ||
return result.toString(); | ||
} | ||
|
||
public static void saveToFile(Stage pstage) { | ||
FileChooser fileChooser = new FileChooser(); | ||
fileChooser.setTitle("Save Log File"); | ||
|
||
LocalDateTime dateTime = LocalDateTime.now(); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"); | ||
String dateString = dateTime.format(formatter); | ||
|
||
fileChooser.setInitialFileName(dateString + ".log_846"); | ||
|
||
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("FunkyLog (*.log_846)", "*.log_846"); | ||
fileChooser.getExtensionFilters().add(extFilter); | ||
|
||
File file = fileChooser.showSaveDialog(pstage); | ||
|
||
if (file != null) { | ||
try (FileWriter fileWriter = new FileWriter(file)) { | ||
fileWriter.write(stringifyAllMessages()); | ||
System.out.println("File saved to: " + file.getAbsolutePath()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.