Skip to content

Commit 8138f11

Browse files
committed
AbstractLogService: refactor duplicate code
1 parent 294f37c commit 8138f11

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/org/scijava/log/AbstractLogService.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public abstract class AbstractLogService extends AbstractService implements
4646
LogService
4747
{
4848

49-
private int currentLevel = System.getenv("DEBUG") == null ? INFO : DEBUG;
49+
private int currentLevel = levelFromEnvironment();
5050

5151
private final Map<String, Integer> classAndPackageLevels =
5252
new HashMap<>();
@@ -77,10 +77,8 @@ public AbstractLogService() {
7777
final int level = level(logProp);
7878
if (level >= 0) setLevel(level);
7979

80-
if (getLevel() == 0) {
81-
// use the default, which is INFO unless the DEBUG env. variable is set
82-
setLevel(System.getenv("DEBUG") == null ? INFO : DEBUG);
83-
}
80+
if (getLevel() == 0)
81+
setLevel(levelFromEnvironment());
8482

8583
// populate custom class- and package-specific log level properties
8684
final String logLevelPrefix = LOG_LEVEL_PROPERTY + ":";
@@ -297,4 +295,9 @@ private String parentPackage(final String classOrPackageName) {
297295
return classOrPackageName.substring(0, dot);
298296
}
299297

298+
private int levelFromEnvironment() {
299+
// use the default, which is INFO unless the DEBUG env. variable is set
300+
return System.getenv("DEBUG") == null ? INFO : DEBUG;
301+
}
302+
300303
}

0 commit comments

Comments
 (0)