-
Notifications
You must be signed in to change notification settings - Fork 612
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] Backend refactoring and interface fixes #7548
base: main
Are you sure you want to change the base?
[epilogue] Backend refactoring and interface fixes #7548
Conversation
@@ -143,12 +143,19 @@ private Set<TypeElement> getLoggedTypes(RoundEnvironment roundEnv) { | |||
annotatedElements.stream() | |||
.filter(e -> e instanceof TypeElement) | |||
.map(e -> (TypeElement) e), | |||
// 2. All type elements containing a field or method with the @Logged annotation | |||
// 2. All type elements containing a field or method with the @Logged annotation, | |||
// or interfaces which have an implementing class with an @Logged annotation |
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.
It'd be better to change methodsToLog
in LoggerGenerator
to look at superclass and interface methods. This has the side effect of making a plain interface loggable if it happens to have a loggable implementation, which is completely invisible to anyone looking at the interface declaration.
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.
That was the intention. Currently, the "logger file" generated by epilogue for said interface is blank(so there's no side effects). The idea is that if you put @Logged on a IO impl but not the IO, then fields on said impl will still be logged(while not logging any default members of the IO interface)
interface ABC { | ||
default double a() { return 2.0; } | ||
} |
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 should not be loggable
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.
The idea is to still generate a logger for the interface ABC because it has classes that inherit from it(that can be logged)
* @param disabledSupplier the disable condition for NT logging | ||
* @return a new NTBackend | ||
*/ | ||
public NTBackend disableWhen(BooleanSupplier disabledSupplier) { |
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.
How is this better than just changing the backend on the fly?
if (condition()) {
Epilogue.configure(config -> {
config.backend = new NullBackend();
});
}
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.
It's more succint, and prevents you from having to cache different kinds of backends yourself.
For instance, if you only want NT logging enabled when fms is not attached, you would have to cache a file only backend, a file and nt backend, and use an addPeriodic call.
In addition, the configure() method accepts a lambda, and if it is called every loop, it will spawn a new object every loop as well
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.
The NTBackend rename and FileBackend default constructor changes are good, and should be merged. The disabling feature and automagic loggable interfaces changes need more discussion/iterations, and would be better to split into separate PRs to avoid blocking the straightforward backend updates
… misc-epilogue-improvements
/format |
@SamCarlberg I just made 2 changes:
|
This PR fixes a couple of things:
new NTBackend().disableWhen(DriverStation::isFmsAttached)