Skip to content

Commit b8304b0

Browse files
committed
Rename StderrLogService to DefaultLogService
This is a backwards incompatible change.
1 parent 2f5e8c8 commit b8304b0

File tree

7 files changed

+76
-9
lines changed

7 files changed

+76
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>scijava-common</artifactId>
13-
<version>2.39.1-SNAPSHOT</version>
13+
<version>3.0.0-SNAPSHOT</version>
1414

1515
<name>SciJava Common</name>
1616
<description>SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, backed by its own annotation processor, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO.</description>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* #%L
3+
* SciJava Common shared library for SciJava software.
4+
* %%
5+
* Copyright (C) 2009 - 2015 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava.log;
33+
34+
import org.scijava.Priority;
35+
import org.scijava.plugin.Plugin;
36+
import org.scijava.service.Service;
37+
38+
/**
39+
* Implementation of {@link LogService} using the standard error stream.
40+
*
41+
* @author Johannes Schindelin
42+
* @author Curtis Rueden
43+
*/
44+
@Plugin(type = Service.class, priority = Priority.LOW_PRIORITY)
45+
public class DefaultLogService extends AbstractLogService {
46+
47+
/**
48+
* Prints a message to stderr.
49+
*
50+
* @param message the message
51+
*/
52+
@Override
53+
protected void log(final String message) {
54+
System.err.println(message);
55+
}
56+
57+
/**
58+
* Prints an exception to stderr.
59+
*
60+
* @param t the exception
61+
*/
62+
@Override
63+
protected void log(final Throwable t) {
64+
t.printStackTrace();
65+
}
66+
67+
}

src/main/java/org/scijava/script/AbstractScriptEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import javax.script.ScriptEngineFactory;
4040
import javax.script.ScriptException;
4141

42+
import org.scijava.log.DefaultLogService;
4243
import org.scijava.log.LogService;
43-
import org.scijava.log.StderrLogService;
4444

4545
/**
4646
* This class implements dummy versions for ScriptEngine's methods that are not
@@ -70,7 +70,7 @@ public abstract class AbstractScriptEngine implements ScriptEngine {
7070

7171
public synchronized LogService log() {
7272
if (log == null) {
73-
log = new StderrLogService();
73+
log = new DefaultLogService();
7474
}
7575
return log;
7676
}

src/main/java/org/scijava/service/ServiceHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
import org.scijava.Optional;
4444
import org.scijava.event.EventHandler;
4545
import org.scijava.event.EventService;
46+
import org.scijava.log.DefaultLogService;
4647
import org.scijava.log.LogService;
47-
import org.scijava.log.StderrLogService;
4848
import org.scijava.plugin.Parameter;
4949
import org.scijava.plugin.PluginInfo;
5050
import org.scijava.service.event.ServicesLoadedEvent;
@@ -114,7 +114,7 @@ public ServiceHelper(final Context context,
114114
{
115115
setContext(context);
116116
log = context.getService(LogService.class);
117-
if (log == null) log = new StderrLogService();
117+
if (log == null) log = new DefaultLogService();
118118
classPoolMap = new HashMap<Class<? extends Service>, Double>();
119119
classPoolList = new ArrayList<Class<? extends Service>>();
120120
findServiceClasses(classPoolMap, classPoolList);

src/test/java/org/scijava/ContextCreationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testFull() {
9898
org.scijava.ui.dnd.DefaultDragAndDropService.class,
9999
org.scijava.welcome.DefaultWelcomeService.class,
100100
org.scijava.widget.DefaultWidgetService.class,
101-
org.scijava.log.StderrLogService.class,
101+
org.scijava.log.DefaultLogService.class,
102102
org.scijava.platform.DefaultAppEventService.class };
103103

104104
final Context context = new Context();

src/test/java/org/scijava/log/LogServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public class LogServiceTest {
4545
@Test
4646
public void testDefaultLevel() {
47-
final LogService log = new StderrLogService();
47+
final LogService log = new DefaultLogService();
4848
int level = log.getLevel();
4949
assertTrue("default level (" + level + ") is at least INFO(" + WARN + ")", level >= WARN);
5050
}

src/test/java/org/scijava/service/ServiceIndexTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.junit.Test;
4141
import org.scijava.Context;
4242
import org.scijava.event.DefaultEventService;
43-
import org.scijava.log.StderrLogService;
43+
import org.scijava.log.DefaultLogService;
4444
import org.scijava.options.DefaultOptionsService;
4545
import org.scijava.options.OptionsService;
4646
import org.scijava.plugin.DefaultPluginService;
@@ -63,7 +63,7 @@ public void testGetAll() {
6363
assertSame(DefaultEventService.class, all.get(0).getClass());
6464
assertSame(DefaultPluginService.class, all.get(1).getClass());
6565
assertSame(DefaultThreadService.class, all.get(2).getClass());
66-
assertSame(StderrLogService.class, all.get(3).getClass());
66+
assertSame(DefaultLogService.class, all.get(3).getClass());
6767
}
6868

6969
/**

0 commit comments

Comments
 (0)