Skip to content

Commit

Permalink
bug fixes to logger and config saving
Browse files Browse the repository at this point in the history
  • Loading branch information
AIP21 committed May 14, 2022
1 parent cb14396 commit a042cdc
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Player Tracker Decoder - CONFIG
Delete this config file to reset values to their default settings
size: 1.0 // Change th position marker or line size
convertChunkPositions: true // Convert logged chunk positions into block positions, this is done by multiplying the chunk position by 16
maxEntries: 0 // The limit to the amount of data entries to compile into the final image or gif, useful when wanting a less-detailed, but quick output or when with low memory. Set to 0 to disable
drawType: 0 // The way to represent the positions. 0 = Pixel, 1 = Dot, 2 = Lines, 3 = Heatmap
lineThreshold: 200 // The maximum distance a player can move until its position change doesn't draw a line. This is to fix issues where massive lines are drawn across the map when players nether travel or die.
upscale: 1 // The scale multiplier. The higher the up-scaling, the higher the final resolution. HIGHER VALUES DRASTICALLY INCREASE FILE SIZE AND PROCESSING TIME!
fancyLines: false // Show arrows at data points when drawing using lines
antialiasing: true // Use antialiasing when rendering. Used to smooth out the hard, pixelated edges
hiddenLines: false // Show lines that were hidden for being above the threshold
terminusPoints: true // Show dots at the start and end of lines
ageFade: false // Fade out older log markers, showing the age of the marker
ageFadeThreshold: 0 // How much to fade out older log markers. If 0, then it uses the max amount of log markers
heatDrawType: 0 // The way to represent the heatmap. 0 = Change size, 1 = Change color
heatMapThreshold: 0 // How much to change colors on the heatmap
37 changes: 37 additions & 0 deletions logs/2022-05-14 31.log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[INFO] <2022-05-14; 16:40:09.314> Player Tracker Decoder App v1.7.3 - LOG FILE
[INFO] <2022-05-14; 16:40:09.316> Initializing logger
[INFO] <2022-05-14; 16:40:09.317> Logger successfully initialized
[INFO] <2022-05-14; 16:40:09.317> Initializing primary systems
[INFO] <2022-05-14; 16:40:09.319> Initializing settings subsystem
[WARNING] <2022-05-14; 16:40:09.320> Config file does not exist, creating it
[INFO] <2022-05-14; 16:40:09.321> Successfully created config file
[INFO] <2022-05-14; 16:40:09.322> Saving and writing settings to config file
[INFO] <2022-05-14; 16:40:09.326> Successfully saved and wrote settings to config file
[INFO] <2022-05-14; 16:40:09.327> Successfully saved and wrote default settings to config file
[INFO] <2022-05-14; 16:40:09.327> Fetching and parsing settings from config file
[INFO] <2022-05-14; 16:40:09.331> 1.0
[INFO] <2022-05-14; 16:40:09.332> true
[INFO] <2022-05-14; 16:40:09.333> 0
[INFO] <2022-05-14; 16:40:09.333> Pixel
[INFO] <2022-05-14; 16:40:09.333> 200
[INFO] <2022-05-14; 16:40:09.334> false
[INFO] <2022-05-14; 16:40:09.334> true
[INFO] <2022-05-14; 16:40:09.334> false
[INFO] <2022-05-14; 16:40:09.335> true
[INFO] <2022-05-14; 16:40:09.335> false
[INFO] <2022-05-14; 16:40:09.336> ageFadeThreshold: 0
[INFO] <2022-05-14; 16:40:09.336> ChangeSize
[INFO] <2022-05-14; 16:40:09.336> 0
[INFO] <2022-05-14; 16:40:09.337> Settings: 12
[INFO] <2022-05-14; 16:40:09.337> Successfully fetched and parsed settings from config file
[INFO] <2022-05-14; 16:40:09.337> Successfully initialized settings subsystem
[INFO] <2022-05-14; 16:40:09.339> Initializing decoder subsystem
[INFO] <2022-05-14; 16:40:09.339> Successfully initialized decoder subsystem
[INFO] <2022-05-14; 16:40:09.339> Initializing primary frame subsystem
[INFO] <2022-05-14; 16:40:09.394> Initializing main display subsystem
[INFO] <2022-05-14; 16:40:09.395> Antialiasing enabled on main display panel
[INFO] <2022-05-14; 16:40:09.395> Successfully initialized main display subsystem
[INFO] <2022-05-14; 16:40:09.433> Successfully initialized primary frame subsystem
[INFO] <2022-05-14; 16:40:09.433> Loading resources
[INFO] <2022-05-14; 16:40:10.301> Successfully initialized all subsystems

Binary file modified out/artifacts/TrackerDecoderApp_jar/TrackerDecoderApp.jar
Binary file not shown.
38 changes: 3 additions & 35 deletions out/production/TrackerDecoderApp/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions out/production/TrackerDecoderApp/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Player Tracker Decoder - CONFIG
Delete this config file to reset values to their default settings
size: 1.0 // Change th position marker or line size
convertChunkPositions: true // Convert logged chunk positions into block positions, this is done by multiplying the chunk position by 16
maxEntries: 0 // The limit to the amount of data entries to compile into the final image or gif, useful when wanting a less-detailed, but quick output or when with low memory. Set to 0 to disable
drawType: 0 // The way to represent the positions. 0 = Pixel, 1 = Dot, 2 = Lines, 3 = Heatmap
lineThreshold: 200 // The maximum distance a player can move until its position change doesn't draw a line. This is to fix issues where massive lines are drawn across the map when players nether travel or die.
upscale: 1 // The scale multiplier. The higher the up-scaling, the higher the final resolution. HIGHER VALUES DRASTICALLY INCREASE FILE SIZE AND PROCESSING TIME!
fancyLines: false // Show arrows at data points when drawing using lines
antialiasing: true // Use antialiasing when rendering. Used to smooth out the hard, pixelated edges
hiddenLines: false // Show lines that were hidden for being above the threshold
terminusPoints: true // Show dots at the start and end of lines
ageFade: false // Fade out older log markers, showing the age of the marker
ageFadeThreshold: 0 // How much to fade out older log markers. If 0, then it uses the max amount of log markers
heatDrawType: 0 // The way to represent the heatmap. 0 = Change size, 1 = Change color
heatMapThreshold: 0 // How much to change colors on the heatmap
Binary file modified out/production/TrackerDecoderApp/src/Logger$MessageType.class
Binary file not shown.
Binary file modified out/production/TrackerDecoderApp/src/Logger.class
Binary file not shown.
Binary file modified out/production/TrackerDecoderApp/src/PlayerTrackerDecoder.class
Binary file not shown.
Binary file modified out/production/TrackerDecoderApp/src/Settings.class
Binary file not shown.
22 changes: 21 additions & 1 deletion src/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,34 @@ public Logger(String version) {
name += (count != 0 ? " " + count : "") + ".log.txt";

logFile = new File("logs/" + name);
Log(" Player Tracker Decoder App v" + version + " - LOG FILE", MessageType.INFO);
LogFirst("Player Tracker Decoder App v" + version + " - LOG FILE", MessageType.INFO);
Log("Initializing logger", MessageType.INFO);

if (created) Log("Log file directory didn't exist, so it was created", MessageType.WARNING);

Log("Logger successfully initialized", MessageType.INFO);
}

public void LogFirst(Object message, MessageType type) {
String toLog = (" [" + type.toString() + "] <" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd; HH:mm:ss.SSS")) + "> " + message + "\n ");

if (type == MessageType.ERROR) {
System.err.print("\u001B[0m" + toLog.replace(", ", "\n "));
} else if (type == MessageType.WARNING) {
System.out.print("\u001B[33m" + toLog);
} else {
System.out.print("\u001B[0m" + toLog);
}

try {
FileWriter writer = new FileWriter(logFile, true);
writer.append(toLog);
writer.close();
} catch (Exception e) {
Log("Error logging message:\n " + Arrays.toString(e.getStackTrace()), MessageType.ERROR);
}
}

public void Log(Object message, MessageType type) {
String toLog = ("[" + type.toString() + "] <" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd; HH:mm:ss.SSS")) + "> " + message + "\n ");

Expand Down
2 changes: 1 addition & 1 deletion src/PlayerTrackerDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class PlayerTrackerDecoder extends JFrame {
private ImageIcon checkBoxIconON;
private ImageIcon checkBoxIconOFF;

private final String version = "1.7.3";
private final String version = "1.7.4";

public PlayerTrackerDecoder() {
logger = new Logger(version);
Expand Down
4 changes: 4 additions & 0 deletions src/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public Settings(Logger log) {
_heatDrawType = PlayerTrackerDecoder.HeatDrawType.ChangeSize;
heatMapThreshold = 0;

new File("config.txt").createNewFile();

logger.Log("Successfully created config file", Logger.MessageType.INFO);

SaveSettings();
Expand Down Expand Up @@ -107,6 +109,8 @@ public void SaveSettings() {
writer.println("heatDrawType: " + heatDrawTypeToInt(_heatDrawType) + " // The way to represent the heatmap. 0 = Change size, 1 = Change color");
writer.println("heatMapThreshold: " + heatMapThreshold + " // How much to change colors on the heatmap");

writer.close();

logger.Log("Successfully saved and wrote settings to config file", Logger.MessageType.INFO);
} catch (Exception e) {
logger.Log("Error saving and writing settings to config file:\n " + Arrays.toString(e.getStackTrace()), Logger.MessageType.ERROR);
Expand Down

0 comments on commit a042cdc

Please sign in to comment.