New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an annotation-based logging framework for Java programs #6584
base: main
Are you sure you want to change the base?
Conversation
/format |
This looks really good! Two thoughts:
|
} | ||
out.println(); | ||
|
||
// public class FooLogger implements ClassSpecificLogger<Foo> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah. I originally had this printing out elements individually, so comments were helpful for showing examples of what the code was generating. I later refactored it to use string concats and this got left over
The idea is to make the lowest-friction way of using the library to also be what provides the most information. Therefore, tagging a class with
There was a lot of back and forth on that. But getting back to simplicity, this means only a single annotation needs to get used (and a separate |
I worry that "most information" might not be the default behavior that's most-useful in practice beyond initial prototyping phases. I might be biased towards complex codebases with a high base-level of internal complexity, though. I agree that |
For sake of tracking history, that should be a separate PR. |
Higher complexity codebases can surely add a bit more complexity and use explicit logging configurations. My concern is that forcing users to tag everything they want (and have to decide what they want) is too much overhead; people generally want something that does what they want with the least time and effort possible.
Yep, having the annotation name a verb makes sense. I considered changing it to
I agree; the squash merge would hide the upgrade. Looks like @spacey-sooty is top of things and already opened a PR 🙂 |
I think |
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/AnnotationProcessor.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/AnnotationProcessor.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/AnnotationProcessor.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/EpiloguerGenerator.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/LoggerGenerator.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/LoggerGenerator.java
Outdated
Show resolved
Hide resolved
An annotation processor will generate loggers at compile time Logging is opt-out by default; placing an `@Epilogue` annotation on a class will attempt to log *everything* in that class. This can be configured by setting the strategy on the class and by configuring the importance levels on the logged elements Explicitly tagging a non-loggable element will result in a compile-time error Data is logged to NetworkTables by default
fdea407
to
2877db2
Compare
714c3b8
to
9bcde16
Compare
epilogue-processor/src/test/java/edu/wpi/first/epilogue/processor/AnnotationProcessorTest.java
Outdated
Show resolved
Hide resolved
9bcde16
to
9615e05
Compare
9615e05
to
f404877
Compare
An annotation processor will generate data loggers at compile time based on the contents of the annotated classes.
Logging is opt-out by default; placing an
@Logged
annotation on a class will attempt to log everything in that class. This can be configured by setting the strategy on the class and by configuring the importance levels on the logged elements, or by placing a@NotLogged
annotation on fields and methods that should always be excludedExplicitly tagging a non-loggable element will result in a compile-time error
Data is logged to NetworkTables by default, but can be configured to use any backend (just implement the
DataLogger
interface)This relies on features added between Java 11 and 17, including text blocks and pattern matching, and I've included a small commit that bumps our source compatibility. We already build with and ship JDK 17 to teams, so this is just giving us access to those language features.Added separately in #6585