GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix Logger Parameter with Ops by maarzt · Pull Request #319 · scijava/scijava-common

Conversation

@maarzt

@maarzt maarzt commented Apr 27, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Previously the LoggerPreprocessor automatically injected Logger Paramters for CommandService.
But LoggerPreprocessor didn't work for Ops.
This PR fixes this issue:

  1. Context injects Logger Parameter
  2. Logger extend Optional interface, this make Logger optional during ops matching.

The issue is described in http://forum.imagej.net/t/using-the-new-scijava-logging-and-status-service-system-in-an-application/9964/10

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
maarzt added 3 commits April 27, 2018 16:00
@maarzt
Context: add Logger injection
cad0cfe
@maarzt
Remove LoggerPreprocessor
85af399
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.
@maarzt
Logger: make Logger an optional parameter for Ops and Commands
6e15e99
@ctrueden

ctrueden commented Apr 27, 2018

Copy link
Copy Markdown
Member

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ctrueden

ctrueden commented Apr 27, 2018

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maarzt

maarzt commented Apr 27, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ctrueden

ctrueden commented Apr 28, 2018

Copy link
Copy Markdown
Member

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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maarzt

maarzt commented Apr 28, 2018

Copy link
Copy Markdown
Contributor Author

Ok, the consequences your are describing clearly call for a better solution, than what I suggested.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ctrueden

ctrueden commented Dec 20, 2018

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ctrueden ctrueden mentioned this pull request May 16, 2019
Decide how to support logging errors and warnings scijava/scijava#13
Closed
@ctrueden
ctrueden force-pushed the master branch 3 times, most recently from 53b6733 to 3dc99c9 Compare November 7, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@maarzt @ctrueden
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.