diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 67ed4fc0..dd24a2a2 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -73,7 +73,7 @@ The user program is responsible for configuring and initializing the logging fra Logger.recordMetadata("ProjectName", "MyProject"); // Set a metadata value if (isReal()) { - Logger.addDataReceiver(new WPILOGWriter("/U")); // Log to a USB stick + Logger.addDataReceiver(new WPILOGWriter()); // Log to a USB stick ("/U/logs") Logger.addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables new PowerDistribution(1, ModuleType.kRev); // Enables power distribution logging } else { diff --git a/example_projects/advanced_swerve_drive/src/main/java/frc/robot/Robot.java b/example_projects/advanced_swerve_drive/src/main/java/frc/robot/Robot.java index 93e1c995..4d87d201 100644 --- a/example_projects/advanced_swerve_drive/src/main/java/frc/robot/Robot.java +++ b/example_projects/advanced_swerve_drive/src/main/java/frc/robot/Robot.java @@ -59,8 +59,8 @@ public void robotInit() { // Set up data receivers & replay source switch (Constants.currentMode) { case REAL: - // Running on a real robot, log to a USB stick - Logger.addDataReceiver(new WPILOGWriter("/U")); + // Running on a real robot, log to a USB stick ("/U/logs") + Logger.addDataReceiver(new WPILOGWriter()); Logger.addDataReceiver(new NT4Publisher()); break; diff --git a/example_projects/diff_drive/src/main/java/frc/robot/Robot.java b/example_projects/diff_drive/src/main/java/frc/robot/Robot.java index 93e1c995..4d87d201 100644 --- a/example_projects/diff_drive/src/main/java/frc/robot/Robot.java +++ b/example_projects/diff_drive/src/main/java/frc/robot/Robot.java @@ -59,8 +59,8 @@ public void robotInit() { // Set up data receivers & replay source switch (Constants.currentMode) { case REAL: - // Running on a real robot, log to a USB stick - Logger.addDataReceiver(new WPILOGWriter("/U")); + // Running on a real robot, log to a USB stick ("/U/logs") + Logger.addDataReceiver(new WPILOGWriter()); Logger.addDataReceiver(new NT4Publisher()); break; diff --git a/example_projects/skeleton/src/main/java/frc/robot/Robot.java b/example_projects/skeleton/src/main/java/frc/robot/Robot.java index 3328eb90..a5b6f83a 100644 --- a/example_projects/skeleton/src/main/java/frc/robot/Robot.java +++ b/example_projects/skeleton/src/main/java/frc/robot/Robot.java @@ -61,8 +61,8 @@ public void robotInit() { // Set up data receivers & replay source switch (Constants.currentMode) { case REAL: - // Running on a real robot, log to a USB stick - Logger.addDataReceiver(new WPILOGWriter("/U")); + // Running on a real robot, log to a USB stick ("/U/logs") + Logger.addDataReceiver(new WPILOGWriter()); Logger.addDataReceiver(new NT4Publisher()); break; diff --git a/example_projects/swerve_drive/src/main/java/frc/robot/Robot.java b/example_projects/swerve_drive/src/main/java/frc/robot/Robot.java index 93e1c995..4d87d201 100644 --- a/example_projects/swerve_drive/src/main/java/frc/robot/Robot.java +++ b/example_projects/swerve_drive/src/main/java/frc/robot/Robot.java @@ -59,8 +59,8 @@ public void robotInit() { // Set up data receivers & replay source switch (Constants.currentMode) { case REAL: - // Running on a real robot, log to a USB stick - Logger.addDataReceiver(new WPILOGWriter("/U")); + // Running on a real robot, log to a USB stick ("/U/logs") + Logger.addDataReceiver(new WPILOGWriter()); Logger.addDataReceiver(new NT4Publisher()); break; diff --git a/junction/core/src/org/littletonrobotics/junction/wpilog/WPILOGWriter.java b/junction/core/src/org/littletonrobotics/junction/wpilog/WPILOGWriter.java index 4497ae81..d1f66593 100644 --- a/junction/core/src/org/littletonrobotics/junction/wpilog/WPILOGWriter.java +++ b/junction/core/src/org/littletonrobotics/junction/wpilog/WPILOGWriter.java @@ -38,6 +38,8 @@ public class WPILOGWriter implements LogDataReceiver { private static final double timestampUpdateDelay = 5.0; // Wait several seconds after DS attached to ensure // timestamp/timezone is updated + private static final String defaultPathRio = "/U/logs"; + private static final String defaultPathSim = "logs"; private static final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yy-MM-dd_HH-mm-ss"); private String folder; @@ -99,6 +101,18 @@ public WPILOGWriter(String path) { this(path, 0.1); } + /** + * Create a new WPILOGWriter for writing to a ".wpilog" file. + * + *
+ * The logs will be saved to "/U/logs" on the RIO and "logs" in sim. The + * filename will be generated based on the current time and match number (if + * applicable). + */ + public WPILOGWriter() { + this(RobotBase.isSimulation() ? defaultPathSim : defaultPathRio); + } + public void start() { // Create folder if necessary File logFolder = new File(folder);