88 * %%
99 * Redistribution and use in source and binary forms, with or without
1010 * modification, are permitted provided that the following conditions are met:
11- *
11+ *
1212 * 1. Redistributions of source code must retain the above copyright notice,
1313 * this list of conditions and the following disclaimer.
1414 * 2. Redistributions in binary form must reproduce the above copyright notice,
1515 * this list of conditions and the following disclaimer in the documentation
1616 * and/or other materials provided with the distribution.
17- *
17+ *
1818 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1919 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3838import org .scijava .service .AbstractService ;
3939
4040/**
41- * Base class for {@link LogService} implementations .
42- *
41+ * Base class for {@link LogService} implementationst .
42+ *
4343 * @author Johannes Schindelin
4444 */
45- public abstract class AbstractLogService extends AbstractService implements LogService {
45+ public abstract class AbstractLogService extends AbstractService implements
46+ LogService
47+ {
4648
4749 private int currentLevel = System .getenv ("DEBUG" ) == null ? INFO : DEBUG ;
4850
49- private Map <String , Integer > classAndPackageLevels =
51+ private final Map <String , Integer > classAndPackageLevels =
5052 new HashMap <>();
5153
5254 // -- abstract methods --
5355
5456 /**
5557 * Displays a message.
56- *
58+ *
5759 * @param msg the message to display.
5860 */
5961 protected abstract void log (final String msg );
6062
6163 /**
6264 * Displays an exception.
63- *
65+ *
6466 * @param t the exception to display.
6567 */
6668 protected abstract void log (final Throwable t );
@@ -87,7 +89,8 @@ public AbstractLogService() {
8789 if (!(propKey instanceof String )) continue ;
8890 final String propName = (String ) propKey ;
8991 if (!propName .startsWith (logLevelPrefix )) continue ;
90- final String classOrPackageName = propName .substring (logLevelPrefix .length ());
92+ final String classOrPackageName =
93+ propName .substring (logLevelPrefix .length ());
9194 setLevel (classOrPackageName , level (props .getProperty (propName )));
9295 }
9396
@@ -109,97 +112,97 @@ protected void log(final int level, final Object msg) {
109112 log ((prefix == null ? "" : prefix + " " ) + msg );
110113 }
111114
112- protected String getPrefix (int level ) {
115+ protected String getPrefix (final int level ) {
113116 switch (level ) {
114- case ERROR :
115- return "[ERROR]" ;
116- case WARN :
117- return "[WARNING]" ;
118- case INFO :
119- return "[INFO]" ;
120- case DEBUG :
121- return "[DEBUG]" ;
122- case TRACE :
123- return "[TRACE]" ;
124- default :
125- return null ;
117+ case ERROR :
118+ return "[ERROR]" ;
119+ case WARN :
120+ return "[WARNING]" ;
121+ case INFO :
122+ return "[INFO]" ;
123+ case DEBUG :
124+ return "[DEBUG]" ;
125+ case TRACE :
126+ return "[TRACE]" ;
127+ default :
128+ return null ;
126129 }
127130 }
128131
129132 // -- LogService methods --
130133
131134 @ Override
132- public void debug (Object msg ) {
135+ public void debug (final Object msg ) {
133136 log (DEBUG , msg , null );
134137 }
135138
136139 @ Override
137- public void debug (Throwable t ) {
140+ public void debug (final Throwable t ) {
138141 log (DEBUG , null , t );
139142 }
140143
141144 @ Override
142- public void debug (Object msg , Throwable t ) {
145+ public void debug (final Object msg , final Throwable t ) {
143146 log (DEBUG , msg , t );
144147 }
145148
146149 @ Override
147- public void error (Object msg ) {
150+ public void error (final Object msg ) {
148151 log (ERROR , msg , null );
149152 }
150153
151154 @ Override
152- public void error (Throwable t ) {
155+ public void error (final Throwable t ) {
153156 log (ERROR , null , t );
154157 }
155158
156159 @ Override
157- public void error (Object msg , Throwable t ) {
160+ public void error (final Object msg , final Throwable t ) {
158161 log (ERROR , msg , t );
159162 }
160163
161164 @ Override
162- public void info (Object msg ) {
165+ public void info (final Object msg ) {
163166 log (INFO , msg , null );
164167 }
165168
166169 @ Override
167- public void info (Throwable t ) {
170+ public void info (final Throwable t ) {
168171 log (INFO , null , t );
169172 }
170173
171174 @ Override
172- public void info (Object msg , Throwable t ) {
175+ public void info (final Object msg , final Throwable t ) {
173176 log (INFO , msg , t );
174177 }
175178
176179 @ Override
177- public void trace (Object msg ) {
180+ public void trace (final Object msg ) {
178181 log (TRACE , msg , null );
179182 }
180183
181184 @ Override
182- public void trace (Throwable t ) {
185+ public void trace (final Throwable t ) {
183186 log (TRACE , null , t );
184187 }
185188
186189 @ Override
187- public void trace (Object msg , Throwable t ) {
190+ public void trace (final Object msg , final Throwable t ) {
188191 log (TRACE , msg , t );
189192 }
190193
191194 @ Override
192- public void warn (Object msg ) {
195+ public void warn (final Object msg ) {
193196 log (WARN , msg , null );
194197 }
195198
196199 @ Override
197- public void warn (Throwable t ) {
200+ public void warn (final Throwable t ) {
198201 log (WARN , null , t );
199202 }
200203
201204 @ Override
202- public void warn (Object msg , Throwable t ) {
205+ public void warn (final Object msg , final Throwable t ) {
203206 log (WARN , msg , t );
204207 }
205208
@@ -248,7 +251,7 @@ public void setLevel(final int level) {
248251 currentLevel = level ;
249252 }
250253
251- // @Override
254+ // @Override
252255 public void setLevel (final String classOrPackageName , final int level ) {
253256 classAndPackageLevels .put (classOrPackageName , level );
254257 }
@@ -289,7 +292,7 @@ private String callingClass() {
289292 }
290293
291294 private String parentPackage (final String classOrPackageName ) {
292- int dot = classOrPackageName .lastIndexOf ("." );
295+ final int dot = classOrPackageName .lastIndexOf ("." );
293296 if (dot < 0 ) return null ;
294297 return classOrPackageName .substring (0 , dot );
295298 }
0 commit comments