diff --git a/json-path/src/main/java/com/jayway/jsonpath/JsonPath.java b/json-path/src/main/java/com/jayway/jsonpath/JsonPath.java index 1821525b..45af4ee4 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/JsonPath.java +++ b/json-path/src/main/java/com/jayway/jsonpath/JsonPath.java @@ -16,7 +16,6 @@ package com.jayway.jsonpath; import com.jayway.jsonpath.internal.IOUtils; -import com.jayway.jsonpath.internal.Log; import com.jayway.jsonpath.internal.PathToken; import com.jayway.jsonpath.internal.PathTokenizer; import com.jayway.jsonpath.internal.filter.PathTokenFilter; @@ -24,6 +23,8 @@ import com.jayway.jsonpath.spi.HttpProviderFactory; import com.jayway.jsonpath.spi.JsonProvider; import com.jayway.jsonpath.spi.JsonProviderFactory; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.FileInputStream; @@ -99,6 +100,8 @@ import static org.apache.commons.lang3.Validate.*; */ public class JsonPath { + private static final Logger LOG = LoggerFactory.getLogger(JsonPath.class.getName()); + private static Pattern DEFINITE_PATH_PATTERN = Pattern.compile(".*(\\.\\.|\\*|\\[[\\\\/]|\\?|,|:\\s?]|\\[\\s?:|>|\\(|<|=|\\+).*"); private static Pattern INVALID_PATH_PATTERN = Pattern.compile("[^\\?\\+=\\-\\*/!]\\("); @@ -122,8 +125,8 @@ public class JsonPath { this.tokenizer = new PathTokenizer(jsonPath); - if(Log.isDebugEnabled()){ - Log.debug("New JsonPath:\n{}", this.tokenizer.toString()); + if(LOG.isDebugEnabled()){ + LOG.debug("New JsonPath:\n{}", this.tokenizer.toString()); } this.filters = new LinkedList(); diff --git a/json-path/src/main/java/com/jayway/jsonpath/internal/Log.java b/json-path/src/main/java/com/jayway/jsonpath/internal/Log.java deleted file mode 100644 index 7c571d25..00000000 --- a/json-path/src/main/java/com/jayway/jsonpath/internal/Log.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.jayway.jsonpath.internal; - -import org.apache.commons.lang3.StringUtils; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * User: kalle - * Date: 8/28/13 - * Time: 10:23 AM - */ -public final class Log { - - private Log() { - } - - private static boolean enabled = false; - - public static void enableDebug(){ - enabled = true; - } - - public static boolean isDebugEnabled(){ - return enabled; - } - - public static void debug(String msg, Object... args){ - if(enabled){ - - int argCount = StringUtils.countMatches(msg, "{}"); - - if(!(argCount == args.length)){ - throw new RuntimeException("Invalid debug statement."); - } - - StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); - - String cls = stackTraceElements[2].getClassName(); - - msg = msg.replaceFirst(Pattern.quote("{}"), "%s"); - - msg = String.format(msg, args); - - System.out.println("DEBUG [" + Thread.currentThread().getName() + "] " + cls + " " + msg); - } - - } - -} diff --git a/json-path/src/test/java/com/jayway/jsonpath/LogTest.java b/json-path/src/test/java/com/jayway/jsonpath/LogTest.java deleted file mode 100644 index cd3b9b9b..00000000 --- a/json-path/src/test/java/com/jayway/jsonpath/LogTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.jayway.jsonpath; - -import com.jayway.jsonpath.internal.Log; -import org.junit.Test; - -/** - * User: kalle - * Date: 8/28/13 - * Time: 10:40 AM - */ -public class LogTest { - - - @Test - public void logger_expands_templates() { - - Log.enableDebug(); - - Log.debug("foo \n{}", "bar"); - - } -} diff --git a/pom.xml b/pom.xml index 20a3680a..01217e11 100644 --- a/pom.xml +++ b/pom.xml @@ -253,7 +253,10 @@ Global dependencies ================================== --> - + + org.slf4j + slf4j-api +