[JAVA-6005] Reduce logging (#11247)

This commit is contained in:
Haroon Khan
2021-09-26 04:28:09 +01:00
committed by GitHub
parent 79e287a900
commit 375803d6a3
13 changed files with 102 additions and 26 deletions

View File

@@ -8,7 +8,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SuffixTree {
private static final Logger LOGGER = LoggerFactory.getLogger(SuffixTree.class);
private static final String WORD_TERMINATION = "$";
private static final int POSITION_UNDEFINED = -1;
private Node root;
@@ -23,7 +25,7 @@ public class SuffixTree {
}
public List<String> searchText(String pattern) {
LOGGER.info("Searching for pattern \"{}\"", pattern);
LOGGER.debug("Searching for pattern \"{}\"", pattern);
List<String> result = new ArrayList<>();
List<Node> nodes = getAllNodesInTraversePath(pattern, root, false);
@@ -41,11 +43,11 @@ public class SuffixTree {
}
private void addSuffix(String suffix, int position) {
LOGGER.info(">>>>>>>>>>>> Adding new suffix {}", suffix);
LOGGER.debug(">>>>>>>>>>>> Adding new suffix {}", suffix);
List<Node> nodes = getAllNodesInTraversePath(suffix, root, true);
if (nodes.size() == 0) {
addChildNode(root, suffix, position);
LOGGER.info("{}", printTree());
LOGGER.debug("{}", printTree());
} else {
Node lastNode = nodes.remove(nodes.size() - 1);
String newText = suffix;
@@ -58,7 +60,7 @@ public class SuffixTree {
newText = newText.substring(existingSuffixUptoLastNode.length());
}
extendNode(lastNode, newText, position);
LOGGER.info("{}", printTree());
LOGGER.debug("{}", printTree());
}
}

View File

@@ -2,7 +2,6 @@ package com.baeldung.algorithms.dfs;
import java.util.List;
import com.baeldung.algorithms.dfs.Graph;
import org.junit.Test;
public class GraphUnitTest {

View File

@@ -10,7 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class QuadTreeSearchUnitTest {
private static final Logger LOGGER = LoggerFactory.getLogger(QuadTreeSearchUnitTest.class);
private static QuadTree quadTree;
@@ -20,41 +20,41 @@ public class QuadTreeSearchUnitTest {
Region area = new Region(0, 0, 400, 400);
quadTree = new QuadTree(area);
float[][] points = new float[][] { { 21, 25 }, { 55, 53 }, { 70, 318 }, { 98, 302 },
float[][] points = new float[][] { { 21, 25 }, { 55, 53 }, { 70, 318 }, { 98, 302 },
{ 49, 229 }, { 135, 229 }, { 224, 292 }, { 206, 321 }, { 197, 258 }, { 245, 238 } };
for (int i = 0; i < points.length; i++) {
Point point = new Point(points[i][0], points[i][1]);
quadTree.addPoint(point);
}
LOGGER.info("\n" + quadTree.printTree(""));
LOGGER.info("==============================================");
LOGGER.debug("\n" + quadTree.printTree(""));
LOGGER.debug("==============================================");
}
@Test
public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() {
Region searchArea = new Region(200, 200, 250, 250);
List<Point> result = quadTree.search(searchArea, null, "");
LOGGER.info(result.toString());
LOGGER.info(quadTree.printSearchTraversePath());
LOGGER.debug(result.toString());
LOGGER.debug(quadTree.printSearchTraversePath());
Assert.assertEquals(1, result.size());
Assert.assertArrayEquals(new float[] { 245, 238 },
Assert.assertArrayEquals(new float[] { 245, 238 },
new float[]{result.get(0).getX(), result.get(0).getY() }, 0);
}
@Test
public void givenQuadTree_whenSearchingForRange_thenReturn2MatchingItems() {
Region searchArea = new Region(0, 0, 100, 100);
List<Point> result = quadTree.search(searchArea, null, "");
LOGGER.info(result.toString());
LOGGER.info(quadTree.printSearchTraversePath());
LOGGER.debug(result.toString());
LOGGER.debug(quadTree.printSearchTraversePath());
Assert.assertEquals(2, result.size());
Assert.assertArrayEquals(new float[] { 21, 25 },
Assert.assertArrayEquals(new float[] { 21, 25 },
new float[]{result.get(0).getX(), result.get(0).getY() }, 0);
Assert.assertArrayEquals(new float[] { 55, 53 },
Assert.assertArrayEquals(new float[] { 55, 53 },
new float[]{result.get(1).getX(), result.get(1).getY() }, 0);
}
}