-
Notifications
You must be signed in to change notification settings - Fork 614
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
[epilogue] allow arrays with @Logged types to be logged #7499
base: main
Are you sure you want to change the base?
Conversation
if (arrayElement.getModifiers().contains(Modifier.FINAL)) { | ||
return m_loggableHandler.isLoggableType(componentType); | ||
} else { | ||
m_processingEnv |
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.
Note that this will cause two messages to be emitted: one for the general "not a loggable type", and this message
"[EPILOGUE] Excluded from logs because array " | ||
+ arrayElement | ||
+ " isn't marked as final(or is returned from a method).", |
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.
You could check the type of the element to be VariableElement
or ExecutableElement
to provide a more specific message
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/LoggableHandler.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/LoggableHandler.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/test/java/edu/wpi/first/epilogue/processor/AnnotationProcessorTest.java
Outdated
Show resolved
Hide resolved
Is there anything left for this pr? |
idts, @SamCarlberg just hasn't approved it yet |
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/ArrayHandler.java
Outdated
Show resolved
Hide resolved
|
||
@Logged | ||
class Example { | ||
final SubLoggable[] x = new SubLoggable[] {}; // logged |
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.
Adding a test case for private final
would be useful, too
logInvocation.replaceAll( | ||
"backend\\.getNested\\(\".*\"\\)", | ||
"backend.getNested(\"%s/\" + i)".formatted(loggedName(element))); |
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.
This regex replace still seems hacky, but it appears to work well enough
Co-authored-by: Sam Carlberg <[email protected]>
This feature is only be restricted to final arrays; as variable-size containers would cause data to become stale and misrepresent what is being logged.