Logging
Intro
Obviously, it's easiest to just System.out.println("Your message here")
when debugging something.
But when you have multiple modules, as we do on the robot, it helps to use a framework like SLF4J (Simple Logging Facade for Java).
For a tutorial on SLF4J that I didn't write, check out this one.
Logging on the robot
Usually, there is a line at the beginning of most of our classes like this one:
private static final Logger log = LoggerFactory.getLogger(DriveBackAndShoot.class);
Where DriveBackAndShoot
is replaced with the class that it's in.
For example, if that line was in the Arm
subsystem class, it would become:
private static final Logger log = LoggerFactory.getLogger(Arm.class);
Then, elsewhere in the class, you'll be able to print to the console (the driver station) using any of these lines:
log.debug("ABC method was called with rotation={} degrees", theta.getDegrees())
log.info("Action took {}s to create", timer.get());
log.error("This action isn't supported yet")