GeezerVison is showing github.com — Fix Logger Parameter with Ops by maarzt · Pull Request #319 · scijava/scijava-common
Conversation
maarzt
commented
Apr 27, 2018
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
LoggerPreprecessor is no longer needed, because Context does the
Logger injection. But it's still important to test, if the Logger
gets confortable injected when using CommandService.
|
I think this will wreak havoc with the ops matcher, unfortunately. Even though the Logger is optional, it is still a parameter, unlike LogService which is ignored by the ops matching framework. The Logger should be completely invisible to ops, and never appear in any op signature.
|
wiedenm reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Also, we do still need the LoggerPreprocessor, for scripts, since a script could have a Logger parameter, and the context injection will not handle it. This is the same reason we have the ServicePreprocessor still.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
maarzt
commented
Apr 27, 2018
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Even though the Logger is optional, it is still a parameter, unlike LogService which is ignored by the ops matching framework. The Logger should be completely invisible to ops, and never appear in any op signature.
I have a different opinion, I want the Logger to be an optional parameter. Let's assume: The caller of an op has a sophisticated UI with an integrated logging panel. The logging panel should show the log messages of the op. This can be achieved by providing a prepared Logger as parameter to the op.
Also, we do still need the LoggerPreprocessor, for scripts, since a script could have a Logger parameter, and the context injection will not handle it. This is the same reason we have the ServicePreprocessor still.
Merge state
Ok, I will restore the LoggerPreprocessor
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I want the Logger to be an optional parameter.
OK. There will be consequences though, is all I am saying. I assume you want existing ops that use LogService parameter to instead use Logger:
- src/main/java/net/imagej/ops/commands/filter/FrangiVesselness.java
- src/main/java/net/imagej/ops/help/HelpCandidates.java
- src/main/java/net/imagej/ops/image/equation/DefaultEquation.java
- src/main/java/net/imagej/ops/thread/chunker/ChunkerInterleaved.java
- src/main/java/net/imagej/ops/thread/chunker/DefaultChunker.java
- src/main/java/net/imagej/ops/threshold/rosin/ComputeRosinThreshold.java
These ops will all need their namespace methods updated to include the Logger. All existing code that relied on a certain number and order of parameters for them will break, because there is now a new Logger parameter, which must either be passed, or set to null. (Only if there are no other optional parameters "to the right" will existing code still work as expected, with null logger.) Furthermore, all of these ops assume the LogService (now Logger) is non-null, which it may not necessarily be now, so they all need to wrap all log statements with if (log != null).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ok, the consequences your are describing clearly call for a better solution, than what I suggested.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
CC @gselzer: next year when we take stock of the current Ops progress, let's discuss this Logger issue. Now that the Ops framework is fundamentally not built on Command/Module anymore, this PR may be easier to integrate into the SciJava framework in a backwards-compatible way. Ideally, op implementations should be able to declare a @Parameter Logger for logging, without it affecting the function signature, in the same way they can declare service parameters.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|