Skip to content

Commit ba7bfaa

Browse files
authored
Merge pull request eugenp#11234 from Maiklins/JAVA-7244-Review_log_statements_for_projects
JAVA-7244 Review log statements for projects
2 parents 7d437b6 + c974daf commit ba7bfaa

File tree

32 files changed

+370
-24
lines changed

32 files changed

+370
-24
lines changed

algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package com.baeldung.algorithms.caesarcipher;
22

33
import org.apache.commons.math3.stat.inference.ChiSquareTest;
4+
import org.slf4j.Logger;
5+
import org.slf4j.LoggerFactory;
46

57
import java.util.Arrays;
68
import java.util.stream.IntStream;
79

810
public class CaesarCipher {
11+
12+
private final Logger log = LoggerFactory.getLogger(CaesarCipher.class);
13+
914
private static final char LETTER_A = 'a';
1015
private static final char LETTER_Z = 'z';
1116
private static final int ALPHABET_SIZE = LETTER_Z - LETTER_A + 1;
@@ -72,7 +77,7 @@ private double[] expectedLettersFrequencies(int messageLength) {
7277
private int probableOffset(double[] chiSquares) {
7378
int probableOffset = 0;
7479
for (int offset = 0; offset < chiSquares.length; offset++) {
75-
System.out.println(String.format("Chi-Square for offset %d: %.2f", offset, chiSquares[offset]));
80+
log.debug(String.format("Chi-Square for offset %d: %.2f", offset, chiSquares[offset]));
7681
if (chiSquares[offset] < chiSquares[probableOffset]) {
7782
probableOffset = offset;
7883
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="INFO">
11+
<appender-ref ref="STDOUT" />
12+
</root>
13+
</configuration>

algorithms-searching/src/main/java/com/baeldung/algorithms/breadthfirstsearch/BreadthFirstSearchAlgorithm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static <T> Optional<Tree<T>> search(T value, Tree<T> root) {
1616
Tree<T> currentNode;
1717
while (!queue.isEmpty()) {
1818
currentNode = queue.remove();
19-
LOGGER.info("Visited node with value: {}", currentNode.getValue());
19+
LOGGER.debug("Visited node with value: {}", currentNode.getValue());
2020

2121
if (currentNode.getValue().equals(value)) {
2222
return Optional.of(currentNode);
@@ -37,7 +37,7 @@ public static <T> Optional<Node<T>> search(T value, Node<T> start) {
3737

3838
while (!queue.isEmpty()) {
3939
currentNode = queue.remove();
40-
LOGGER.info("Visited node with value: {}", currentNode.getValue());
40+
LOGGER.debug("Visited node with value: {}", currentNode.getValue());
4141

4242
if (currentNode.getValue().equals(value)) {
4343
return Optional.of(currentNode);

algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static void setUp() {
3535
public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() {
3636
Region searchArea = new Region(200, 200, 250, 250);
3737
List<Point> result = quadTree.search(searchArea, null, "");
38+
3839
LOGGER.debug(result.toString());
3940
LOGGER.debug(quadTree.printSearchTraversePath());
4041

@@ -47,6 +48,7 @@ public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() {
4748
public void givenQuadTree_whenSearchingForRange_thenReturn2MatchingItems() {
4849
Region searchArea = new Region(0, 0, 100, 100);
4950
List<Point> result = quadTree.search(searchArea, null, "");
51+
5052
LOGGER.debug(result.toString());
5153
LOGGER.debug(quadTree.printSearchTraversePath());
5254

algorithms-searching/src/test/java/com/baeldung/algorithms/suffixtree/SuffixTreeUnitTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,54 +24,54 @@ public static void setUp() {
2424
public void givenSuffixTree_whenSearchingForA_thenReturn6Matches() {
2525
List<String> matches = suffixTree.searchText("a");
2626
matches.stream()
27-
.forEach(m -> LOGGER.info(m));
27+
.forEach(m -> LOGGER.debug(m));
2828
Assert.assertArrayEquals(new String[] { "h[a]vanabanana", "hav[a]nabanana", "havan[a]banana", "havanab[a]nana", "havanaban[a]na", "havanabanan[a]" }, matches.toArray());
2929
}
3030

3131
@Test
3232
public void givenSuffixTree_whenSearchingForNab_thenReturn1Match() {
3333
List<String> matches = suffixTree.searchText("nab");
3434
matches.stream()
35-
.forEach(m -> LOGGER.info(m));
35+
.forEach(m -> LOGGER.debug(m));
3636
Assert.assertArrayEquals(new String[] { "hava[nab]anana" }, matches.toArray());
3737
}
3838

3939
@Test
4040
public void givenSuffixTree_whenSearchingForNag_thenReturnNoMatches() {
4141
List<String> matches = suffixTree.searchText("nag");
4242
matches.stream()
43-
.forEach(m -> LOGGER.info(m));
43+
.forEach(m -> LOGGER.debug(m));
4444
Assert.assertArrayEquals(new String[] {}, matches.toArray());
4545
}
4646

4747
@Test
4848
public void givenSuffixTree_whenSearchingForBanana_thenReturn2Matches() {
4949
List<String> matches = suffixTree.searchText("ana");
5050
matches.stream()
51-
.forEach(m -> LOGGER.info(m));
51+
.forEach(m -> LOGGER.debug(m));
5252
Assert.assertArrayEquals(new String[] { "hav[ana]banana", "havanab[ana]na", "havanaban[ana]" }, matches.toArray());
5353
}
5454

5555
@Test
5656
public void givenSuffixTree_whenSearchingForNa_thenReturn4Matches() {
5757
List<String> matches = suffixTree.searchText("na");
5858
matches.stream()
59-
.forEach(m -> LOGGER.info(m));
59+
.forEach(m -> LOGGER.debug(m));
6060
Assert.assertArrayEquals(new String[] { "hava[na]banana", "havanaba[na]na", "havanabana[na]" }, matches.toArray());
6161
}
6262

6363
@Test
6464
public void givenSuffixTree_whenSearchingForX_thenReturnNoMatches() {
6565
List<String> matches = suffixTree.searchText("x");
6666
matches.stream()
67-
.forEach(m -> LOGGER.info(m));
67+
.forEach(m -> LOGGER.debug(m));
6868
Assert.assertArrayEquals(new String[] {}, matches.toArray());
6969
}
7070

7171
private static void printTree() {
7272
suffixTree.printTree();
7373

74-
LOGGER.info("\n" + suffixTree.printTree());
75-
LOGGER.info("==============================================");
74+
LOGGER.debug("\n" + suffixTree.printTree());
75+
LOGGER.debug("==============================================");
7676
}
7777
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="INFO">
11+
<appender-ref ref="STDOUT" />
12+
</root>
13+
</configuration>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="INFO">
11+
<appender-ref ref="STDOUT" />
12+
</root>
13+
</configuration>
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<configuration>
3-
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4-
<encoder>
5-
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6-
</pattern>
7-
</encoder>
8-
</appender>
9-
10-
<root level="WARN">
11-
<appender-ref ref="STDOUT" />
12-
</root>
13-
</configuration>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="WARN">
11+
<appender-ref ref="STDOUT" />
12+
</root>
13+
</configuration>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="INFO">
11+
<appender-ref ref="STDOUT" />
12+
</root>
13+
</configuration>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="INFO">
11+
<appender-ref ref="STDOUT" />
12+
</root>
13+
</configuration>

0 commit comments

Comments
 (0)