|
| 1 | +package org.mastodon.revised.mamut; |
| 2 | + |
| 3 | +import org.scijava.Priority; |
| 4 | +import org.scijava.log.LogSource; |
| 5 | +import org.scijava.plugin.Plugin; |
| 6 | +import org.scijava.service.AbstractService; |
| 7 | + |
| 8 | +/** |
| 9 | + * A low priority {@link MastodonLogger} that appends messages to |
| 10 | + * {@link System#out} and {@link System#err}. Progress messages are discarded. |
| 11 | + * |
| 12 | + * @author Jean-Yves Tinevez |
| 13 | + */ |
| 14 | +@Plugin( type = MastodonLogger.class, priority = Priority.LOW ) |
| 15 | +public class SysOutMastodonLogger extends AbstractService implements MastodonLogger |
| 16 | +{ |
| 17 | + |
| 18 | + private final LogSource root = LogSource.newRoot(); |
| 19 | + |
| 20 | + private final LogSource unknownSource = root.subSource( "Unkown source" ); |
| 21 | + |
| 22 | + @Override |
| 23 | + public LogSource getLogSourceRoot() |
| 24 | + { |
| 25 | + return root; |
| 26 | + } |
| 27 | + |
| 28 | + @Override |
| 29 | + public void info( final String message, final LogSource source ) |
| 30 | + { |
| 31 | + System.out.println( '[' + source.name() + "] " + message ); |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public void info( final String message ) |
| 36 | + { |
| 37 | + info( message, unknownSource ); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public void error( final String message, final LogSource source ) |
| 42 | + { |
| 43 | + System.err.println( '[' + source.name() + "] " + message ); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public void error( final String message ) |
| 48 | + { |
| 49 | + error( message, unknownSource ); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public void setStatus( final String status, final LogSource source ) |
| 54 | + { |
| 55 | + info( status, source ); |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public void setStatus( final String status ) |
| 60 | + { |
| 61 | + setStatus( status, unknownSource ); |
| 62 | + } |
| 63 | + |
| 64 | + @Override |
| 65 | + public void setProgress( final double progress, final LogSource source ) |
| 66 | + {} |
| 67 | + |
| 68 | + @Override |
| 69 | + public void setProgress( final double progress ) |
| 70 | + {} |
| 71 | +} |
0 commit comments