You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use SciJava Log2 Logger within SciJava Discoverer implementations #106
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.
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.
Activity
ctrueden commentedon Jan 6, 2023
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.Merge pull request #106 from scijava/scijava/scijava-ops-engine/hide-…