The Badlog post has prompted me to ask about logging frameworks generally. We want to implement a proper logging framework this season - we certainly suffered from not having one last season.
Badlog looks very good, and we will definitely have a play with it. However, our team is fairly new, and I wonder if there are other frameworks around that we can compare to.
So the question is: are there other frameworks that are recommended as well?
Shuffleboard saves all the values it sees to disk and lets you play back the recorded data in the dashboard or export it to a CSV file. Pretty much every physical thing on the robot (sensors, motor controllers, subsystems, etc) are already logged in WPILib via the LiveWindow. Custom information can be sent over NetworkTables through the SmartDashboard class, the Shuffleboard class (new in 2019), or manually with the NetworkTables API.
Not for teams, no. The JDK used for FRC programming is comes bundled with the WPILib installer. VS Code will use that JDK for FRC projects, but it will not be on the PATH, so your system environment variables will be unchanged. The tool launchers in VS Code will use that JDK for running Shuffleboard and the other Java desktop tools.
Is there a preview for this 2019 shuffleboard available yet? we had a poor experience with shuffleboard last year, but are extremely excited for the potential that we saw. I would love to start evaluating it.
By the way, the vs code and Gradle set up that was published in the alpha is absolutely fantastic.
Everything is on GitHub and the Maven repo is public, so you can grab the beta Shuffleboard now. You will need Java 11 to run the 2019 beta version though.
Let me speak up in favor of simple debug logging. All robot programmers should be putting some well chosen print statements into their code. The results will show up on your driverâs console and will also be viewable for all previous matches on the driver station Log Viewer. This can provide critical information such as which commands really executed, what your vision system was seeing, or how much air pressure you had available.
Simple print statements will do the job. If you want a slightly more sophisticated logging framework, I suggest the java.util.logging framework. It is built into your JVM, so you wonât need to add any dependencies to your build.gradle file.
Thanks very much Keith. I am very familiar with logging - use log4net and Serilog extensively, and various others in professional life.
I agree that a lot can be done with simple print statements, but that gets very hard to manage very quickly.
The advantage of Badlog and Shuffleboard is they incorporate stuff for the physical environment we find ourselves. I am slightly concerned that Badlog might be a bit sophisticated for our team at the moment, but I have not spent enough time with it yet.
Your blog post on java.util.logging is very good, and we may well start with that.
What did you end up doing with your logging? Iâm desperately trying to find some way of improving our logging. Iâve read many threads here about it, have looked into Shuffleboardâs NetworkTables view, etc. Seems like many revolve around printing out diagnostics to a file, then downloading it. Iâm not even interested in that yet; Iâve learned all that telemetry is already available somewhere in the background; WPILIB can dump it, or Shufffleboard can record it and output it, etc.
All Iâm interested in right now is just seeing OUR simple string messages, uncluttered by all the stuff wpilib and roborio prints out itself. I was hoping Shuffleboard could do that with the NetworkTables, but after looking into that, it looks like thatâs not a great use case for a history of messages.
Sorry for delay in response. We are actually using java.util.logging (JUL) with some wrapper classes to make it a little more hospitable. Currently just logging to the console, and not getting too much output from the WPI stuff to interfere.
Actually getting it going was slightly tricky. You can see our code on GitHub:
We are using a logging.properties file for setup, and put it into the project deploy directory so that it gets sent to the RoboRio. Note how it is set up in robotInit().
The format for the log line is set in the properties file. The one we are using gives timing to the millisecond, the log level and the message.
The wrapper class is there to make generating a log message a little easier. Basic JUL logging has a slightly odd setup, and does not support using java String.format() style messages, so the wrapper classes allow that, and make it easier to log exceptions. They also make the log messages conform to SLF4J format, so if we switch to a more advanced logging framework at some point, should not have any impact.
The PeriodicLogger class is there to make it a bit easier to have log messages in the periodic loops (e.g teleopInit()) and not get overwhelmed. It only logs every Nth call - so if you construct with say 50 as the N value, it only logs every 50th call - which equates to one per second in teleopPeriodic.
Hope that helps. let me know if you have any questions.
Looks like Discus format interprets a â#â as a command to bold everything. The bold lines start with a â#â which indicates a comment in the file.
Alos, our wrapper class avoids the necessity to use the MessgeFormat - we use String.format instead