From bf55012dc0c5d36b4952fc71e9c791fccc4b0617 Mon Sep 17 00:00:00 2001 From: Nathan Petrangelo Date: Wed, 4 Apr 2018 20:51:10 -0400 Subject: [PATCH 1/2] Log the match details at the start of the log file --- src/org/usfirst/frc/team467/robot/Logging.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/org/usfirst/frc/team467/robot/Logging.java b/src/org/usfirst/frc/team467/robot/Logging.java index 8b75db5..3678a5f 100644 --- a/src/org/usfirst/frc/team467/robot/Logging.java +++ b/src/org/usfirst/frc/team467/robot/Logging.java @@ -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; @@ -56,8 +59,13 @@ private static void setupDefaultLogging() { System.out.println("Failed to create log file appender: " + e.getMessage()); } + DriverStation station = DriverStation.getInstance(); + String event = station.getEventName(); + String type = station.getMatchType().name(); + String match = Integer.toString(station.getMatchNumber()); + Logger.getRootLogger().info(String.join(" ", event, type, match)); - // Set the default log level to INFO. + // Set the default log level to ERROR. Logger.getRootLogger().setLevel(Level.ERROR); // changing log level } } \ No newline at end of file From 05cae40c19ffb3a79803e05830a576f9a7591743 Mon Sep 17 00:00:00 2001 From: Nathan Petrangelo Date: Wed, 4 Apr 2018 20:54:40 -0400 Subject: [PATCH 2/2] Added try-catch block --- src/org/usfirst/frc/team467/robot/Logging.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/org/usfirst/frc/team467/robot/Logging.java b/src/org/usfirst/frc/team467/robot/Logging.java index 3678a5f..f8cb04d 100644 --- a/src/org/usfirst/frc/team467/robot/Logging.java +++ b/src/org/usfirst/frc/team467/robot/Logging.java @@ -59,11 +59,15 @@ private static void setupDefaultLogging() { System.out.println("Failed to create log file appender: " + e.getMessage()); } - DriverStation station = DriverStation.getInstance(); - String event = station.getEventName(); - String type = station.getMatchType().name(); - String match = Integer.toString(station.getMatchNumber()); - Logger.getRootLogger().info(String.join(" ", event, type, match)); + try { + DriverStation station = DriverStation.getInstance(); + String event = station.getEventName(); + String type = station.getMatchType().name(); + String match = Integer.toString(station.getMatchNumber()); + Logger.getRootLogger().info(String.join(" ", event, type, match)); + } catch (NullPointerException e) { + Logger.getRootLogger().info("No match data"); + } // Set the default log level to ERROR. Logger.getRootLogger().setLevel(Level.ERROR); // changing log level