Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/org/usfirst/frc/team467/robot/Logging.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import org.usfirst.frc.team467.robot.Autonomous.Action;
import org.usfirst.frc.team467.robot.Autonomous.ActionGroup;
import org.usfirst.frc.team467.robot.vision.VisionIntegration;

import edu.wpi.first.wpilibj.DriverStation;

import org.usfirst.frc.team467.robot.Autonomous.MatchConfiguration;
import org.usfirst.frc.team467.robot.simulator.DriveSimulator;
import org.usfirst.frc.team467.robot.simulator.draw.RobotShape;
Expand Down Expand Up @@ -56,8 +59,17 @@ private static void setupDefaultLogging() {
System.out.println("Failed to create log file appender: " + e.getMessage());
}

try {
DriverStation station = DriverStation.getInstance();
String event = station.getEventName();
String type = station.getMatchType().name();
String match = Integer.toString(station.getMatchNumber());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the log match data is for but if it's for what I think it is, I think that there should be an if statement to check if any of the strings are null, if they are they should be reassigned as "No event data found" or "No match data found" instead of catching the null pointer by the string.join. I think this will be able to eliminate the need for a try-catch and it will be able to tell what specifically went wrong, further it will tell us other match data instead of just giving a blanket "no match data".

Logger.getRootLogger().info(String.join(" ", event, type, match));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the delimiter should probably be something other than just a space to prevent confusion when looking through quickly, but it probably won't matter too much in this case.

} catch (NullPointerException e) {
Logger.getRootLogger().info("No match data");
}

// Set the default log level to INFO.
// Set the default log level to ERROR.
Logger.getRootLogger().setLevel(Level.ERROR); // changing log level
}
}