Skip to content

Use SciJava Log2 Logger within SciJava Discoverer implementations #106

Closed
scijava/incubator
#82

Description

@gselzer

Each Discoverer is responsible for reporting an arbitrary number of implementations for each call to Discoverer.discover().

Sometimes, these Discoverers might find that one of the implementations is incorrect in some way. Instead of throwing an error, I think the principle of least surprise suggests that they should notify the user and move on, returning the correct discoveries instead of none at all. SciJava Log2's Logger class would be perfect for this.

Unfortunately, though, we don't provide the API for Discoverers to access a Logger, so as @ctrueden noticed Discoverers either use Throwable.printStackTrace or just use System.out.println or the equivalent.

I don't have a great idea of how to solve this. Off the top of my head we could:

  • Add a Logger to the discover function. I dislike this, I don't like metaparameters leaking into signatures.
  • Make a LoggingDiscoverer interface with getters/setters for a Logger.
  • Make a static method somewhere that each Discoverer could call to log errors. Would different Discoverers ever want to log to different outputs? If so, this probably is a bad idea.

Activity

  1. added this to the 1.0.0 milestone on Jan 6, 2023
  2. ctrueden commented on Jan 6, 2023

    @ctrueden
    Member

    A fourth option could be to use a similar "static + ThreadLocal" pattern like how some other subsystems work, e.g. parallelization and op progress reporting, for associating loggers with the active thread before invoking discovery.

  3. added a commit that references this issue on May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions