Skip to content

Commit 40f05c0

Browse files
committed
Code refactoring - removed logging
1 parent ebba2cd commit 40f05c0

File tree

6 files changed

+3
-32
lines changed

6 files changed

+3
-32
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ repositories {
2727

2828
dependencies {
2929

30-
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
3130
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
3231
compile group: 'org.apache.commons', name: 'commons-text', version: '1.9'
3332
compile group: 'commons-codec', name: 'commons-codec', version: '1.15'

src/main/java/net/andreinc/mockneat/unit/text/Markovs.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import net.andreinc.mockneat.abstraction.MockUnitString;
77
import net.andreinc.mockneat.types.enums.MarkovChainType;
88
import net.andreinc.mockneat.utils.file.FileManager;
9-
import org.slf4j.Logger;
10-
import org.slf4j.LoggerFactory;
119

1210
import java.io.IOException;
1311
import java.io.UncheckedIOException;
@@ -25,8 +23,6 @@ public class Markovs extends MockUnitBase implements MockUnitString {
2523

2624
private static final FileManager fm = FileManager.getInstance();
2725

28-
private static final Logger logger = LoggerFactory.getLogger(Markovs.class);
29-
3026
private final Map<MarkovChainType, MChainText> markovUnits = new EnumMap<>(MarkovChainType.class);
3127

3228
private int size = 512;
@@ -50,7 +46,6 @@ protected Markovs() {}
5046

5147
private MChainText get(MarkovChainType markovChainType) throws IOException {
5248
if (!markovUnits.containsKey(markovChainType)) {
53-
logger.info("Loading MarkovUnit in memory '{}'." , markovChainType.getFile());
5449
MChainText mChainText = new MChainText(2, mockNeat.getRandom());
5550
List<String> lines = fm.read(markovChainType);
5651
mChainText.train(lines);
@@ -86,7 +81,6 @@ public MockUnitString type(MarkovChainType type) {
8681
unit = get(type);
8782
return unit.generateText(size);
8883
} catch (IOException e) {
89-
logger.error("Cannot load MarkovUnit chain of type '{}'.", type.name());
9084
throw new UncheckedIOException(e);
9185
}
9286
};

src/main/java/net/andreinc/mockneat/utils/LoopsUtils.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
import net.andreinc.mockneat.MockNeat;
44
import net.andreinc.mockneat.types.CallBack;
5-
import org.slf4j.Logger;
6-
import org.slf4j.LoggerFactory;
75

86
import java.util.Arrays;
97
import java.util.function.Consumer;
108
import java.util.function.Function;
119

1210
public final class LoopsUtils {
1311

14-
private static final Logger logger = LoggerFactory.getLogger(LoopsUtils.class);
15-
1612
private LoopsUtils() {}
1713

1814
public static void loop(int cycles, CallBack callBack) {
@@ -26,17 +22,16 @@ public static void loop(int cycles, MockNeat[] array, Consumer<MockNeat> consume
2622
}
2723

2824
public static <T> void loop(int cycles, MockNeat[] array, Function<MockNeat, T> map, Consumer<T> consume) {
29-
loop(cycles, () -> Arrays.stream(array).map(map).forEach(consume));
25+
loop(cycles, () -> Arrays.stream(array)
26+
.map(map)
27+
.forEach(consume));
3028
}
3129

3230
public static <T> void loop(boolean dbg, int cycles, MockNeat[] array, Function<MockNeat, T> map, Consumer<T> consume) {
3331
loop(cycles,
3432
() -> Arrays.stream(array)
3533
.map(r -> {
3634
T o = map.apply(r);
37-
if (dbg) {
38-
logger.info(null == o ? "" : o.toString());
39-
}
4035
return o;
4136
})
4237
.forEach(consume));

src/main/java/net/andreinc/mockneat/utils/file/FileManager.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import net.andreinc.mockneat.types.enums.DictType;
44
import net.andreinc.mockneat.types.enums.MarkovChainType;
5-
import org.slf4j.Logger;
6-
import org.slf4j.LoggerFactory;
75

86
import java.io.BufferedReader;
97
import java.io.IOException;
@@ -21,8 +19,6 @@
2119

2220
public class FileManager {
2321

24-
private static final Logger logger = LoggerFactory.getLogger(FileManager.class);
25-
2622
private static final String DICT_FOLDER = "dicts/";
2723

2824
private static final String MARKOV_FOLDER = "markov/";
@@ -52,10 +48,8 @@ public List<String> getLines(String path) {
5248
if (!JAR_EXTERNAL.containsKey(path)) {
5349
try {
5450
List<String> lines = read(path);
55-
logger.info("Loaded file '{}' in memory. The file contains {} lines.", path, lines.size());
5651
JAR_EXTERNAL.put(path, lines);
5752
} catch (IOException e) {
58-
logger.error("Cannot read file '{}' in memory.", path);
5953
throw new IllegalArgumentException(e);
6054
}
6155
}
@@ -67,13 +61,8 @@ public List<String> getLines(DictType dictType) {
6761
if (!JAR_INTERNAL.containsKey(internal)) {
6862
try {
6963
List<String> lines = read(dictType);
70-
logger.info("Loading internal dictionary '{}' in memory. The dictionary contains {} lines.",
71-
dictType.getFile(),
72-
lines.size());
7364
JAR_INTERNAL.put(internal, lines);
7465
} catch (IOException e) {
75-
logger.error("Cannot read internal dictionary '{}' in memory. Something is terribly wrong.",
76-
dictType.getFile());
7766
throw new UncheckedIOException(e);
7867
}
7968
}

src/main/resources/log4j.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/test/java/net/andreinc/mockneat/unit/objects/ProbabilitiesTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public void testValuesWithMockUnits2() {
7474
.add(0.1, mockNeat.ints().range(5, 6))
7575
.val(),
7676
val -> {
77-
System.out.println(val);
7877
Assert.assertTrue(val >= 0 && val <= 5);
7978
}
8079
);

0 commit comments

Comments
 (0)