From a46a384f562223e53c339d850f1b4fce188f4fae Mon Sep 17 00:00:00 2001 From: Brian Kennedy Date: Tue, 19 Nov 2024 19:04:17 -0800 Subject: [PATCH] #188590455 1.1.7 (#16) * 1.1.7 Add a debug MoesifApiConnConfig field. If set, it logs the config object upon interceptor initialization Small doc updates Clean up some static member access warnings * debug is false by default --- README.md | 5 +-- pom.xml | 2 +- .../MoesifOkHttp3Interceptor.java | 7 +++-- .../config/MoesifApiConnConfig.java | 31 ++++++++++++++----- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index bdb2d75..6656310 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ For Maven users, add dependency to your `pom.xml`: com.moesif moesif-okhttp-interceptor - 1.1.1 + 1.1.6 ``` For Gradle users, add to your project's build.gradle file: @@ -32,7 +32,7 @@ For Gradle users, add to your project's build.gradle file: ```gradle repositories { dependencies { - implementation 'com.moesif:moesif-okhttp-interceptor:1.1.1' + implementation 'com.moesif:moesif-okhttp-interceptor:1.1.6' } ``` @@ -179,6 +179,7 @@ To use this custom config, update it prior to constructing the interceptor ```java MoesifApiConnConfig cfg = new MoesifApiConnConfig(); cfg.setEventFilterConfig(new MyCustomEventFilterConfig()); +cfg.setDebug(false); MoesifOkHttp3Interceptor interceptor = new MoesifOkHttp3Interceptor(cfg); ``` diff --git a/pom.xml b/pom.xml index b21f088..9c1e641 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.moesif moesif-okhttp-interceptor - 1.1.6 + 1.1.7 jar moesif-okhttp-interceptor https://www.moesif.com diff --git a/src/main/java/com/moesif/sdk/okhttp3client/MoesifOkHttp3Interceptor.java b/src/main/java/com/moesif/sdk/okhttp3client/MoesifOkHttp3Interceptor.java index b94fcc6..dcfc8a8 100644 --- a/src/main/java/com/moesif/sdk/okhttp3client/MoesifOkHttp3Interceptor.java +++ b/src/main/java/com/moesif/sdk/okhttp3client/MoesifOkHttp3Interceptor.java @@ -95,12 +95,15 @@ public MoesifOkHttp3Interceptor(MoesifApiConnConfig connConfig) { } public void init(MoesifApiConnConfig connConfig) { - this.connConfig = (null == connConfig) + MoesifOkHttp3Interceptor.connConfig = (null == connConfig) ? new MoesifApiConnConfig() : connConfig; + if (getConnConfig().isDebug()) { + logger.debug("MoesifOkHttp3Interceptor initialized with config: {}", getConnConfig()); + } } public MoesifApiConnConfig getConnConfig(){ - return this.connConfig; + return connConfig; } /** diff --git a/src/main/java/com/moesif/sdk/okhttp3client/config/MoesifApiConnConfig.java b/src/main/java/com/moesif/sdk/okhttp3client/config/MoesifApiConnConfig.java index 26bbf52..8efa91a 100755 --- a/src/main/java/com/moesif/sdk/okhttp3client/config/MoesifApiConnConfig.java +++ b/src/main/java/com/moesif/sdk/okhttp3client/config/MoesifApiConnConfig.java @@ -11,17 +11,14 @@ public class MoesifApiConnConfig { public static String DEFAULT_BASE_URI = "https://api.moesif.net"; - public String baseUri; + public String baseUri; public Integer eventsBufferSize = 5; - private IInterceptEventFilter eventFilterConfig; - - - public Collection bodyContentTypesBlackList = - DefaultDomainData.bodyContentTypesBlackList; - + public Collection bodyContentTypesBlackList = DefaultDomainData.bodyContentTypesBlackList; private String applicationId; + private IInterceptEventFilter eventFilterConfig; + private boolean debug; public MoesifApiConnConfig() { init(null, null); @@ -30,6 +27,7 @@ public MoesifApiConnConfig() { public MoesifApiConnConfig(String moesifApplicationId) { init(moesifApplicationId, null); } + public MoesifApiConnConfig(String applicationId, String baseUri) { init(applicationId, baseUri); } @@ -142,4 +140,23 @@ public void setEventFilterConfig(IInterceptEventFilter eventFilterConfig) { : eventFilterConfig; } + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + @Override + public String toString() { // produce a log friendly single-line string representation of the config + return "MoesifApiConnConfig{" + + "baseUri='" + baseUri + '\'' + + ", eventsBufferSize=" + eventsBufferSize + + ", eventFilterConfig=" + eventFilterConfig + + ", bodyContentTypesBlackList=" + bodyContentTypesBlackList + + ", applicationId='" + applicationId + '\'' + + ", debug=" + debug + + '}'; + } }