From 4902d0062a5ac97cefb3742a7c800103be60573f Mon Sep 17 00:00:00 2001 From: Thilo Schwarz Date: Fri, 18 Apr 2025 13:19:40 +0200 Subject: [PATCH] Improve logging and update dependencies Enabled detailed logging for DNS record operations and adjusted log levels. Updated Maven dependencies, including httpclient5, logback, and added explicit SLF4J configurations. Minor changes to the logging configuration file and project structure for better test isolation. --- pom.xml | 37 +++++++++++++------ .../java/codes/thischwa/cf/CfDnsClient.java | 7 +++- .../{logback.xml => logback-test.xml} | 4 +- 3 files changed, 34 insertions(+), 14 deletions(-) rename src/test/resources/{logback.xml => logback-test.xml} (78%) diff --git a/pom.xml b/pom.xml index 24813a0..5e12889 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 codes.thischwa @@ -33,16 +34,17 @@ 2.18.2 - 5.4.2 + 5.4.3 1.18.36 - 1.5.12 + 2.0.17 + 1.5.18 5.11.4 - scm:git:git@gitlab.com:thischwa/CloudflareDNS-java.git - scm:git:git@gitlab.com:thischwa/CloudflareDNS-java.git - https://gitlab.com/thischwa/CloudflareDNS-java + scm:git:git@gitlab.com:ths6435116/CloudflareDNS-java.git + scm:git:git@gitlab.com:ths6435116/CloudflareDNS-java.git + https://gitlab.com/ths6435116/CloudflareDNS-java HEAD @@ -65,6 +67,18 @@ org.apache.httpcomponents.client5 httpclient5 ${httpclient5.version} + + + org.slf4j + * + + + + + org.slf4j + slf4j-api + ${slf4j.version} + provided org.projectlombok @@ -82,11 +96,6 @@ jackson-datatype-jsr310 ${jackson.version} - - ch.qos.logback - logback-classic - ${logback-classic.version} - org.jetbrains annotations @@ -100,6 +109,12 @@ ${junit5.version} test + + ch.qos.logback + logback-classic + ${logback-classic.version} + test + diff --git a/src/main/java/codes/thischwa/cf/CfDnsClient.java b/src/main/java/codes/thischwa/cf/CfDnsClient.java index 282430a..0416ab3 100644 --- a/src/main/java/codes/thischwa/cf/CfDnsClient.java +++ b/src/main/java/codes/thischwa/cf/CfDnsClient.java @@ -217,6 +217,7 @@ public class CfDnsClient extends CfBasicHttpClient { String endpoint = CfRequest.RECORD_CREATE.buildPath(zone.getId()); RecordSingleResponse resp = postRequest(endpoint, rec); checkResponse(resp); + log.info("Record {} of type {} successful created.", rec.getName(), rec.getType()); return resp.getResult(); } @@ -252,6 +253,7 @@ public class CfDnsClient extends CfBasicHttpClient { String endpoint = CfRequest.RECORD_DELETE.buildPath(zone.getId(), id); RecordSingleResponse resp = deleteRequest(endpoint); checkResponse(resp); + log.debug("Record {} successful deleted.", id); return resp.getResult().getId().equals(id); } @@ -272,6 +274,7 @@ public class CfDnsClient extends CfBasicHttpClient { String endpoint = CfRequest.RECORD_UPDATE.buildPath(zone.getId(), rec.getId()); RecordSingleResponse resp = patchRequest(endpoint, rec); checkResponse(resp); + log.info("Record {} of type {} successful updated.", rec.getName(), rec.getType()); return resp.getResult(); } @@ -280,7 +283,7 @@ public class CfDnsClient extends CfBasicHttpClient { * (SLD), if it exists. * * @param zone The zone in which the DNS record resides. It provides information about the domain. - * @param sld The second-level domain (SLD) of the fully qualified domain name (FQDN) for which + * @param sld Th.apache.hc.client5.http.impl.e second-level domain (SLD) of the fully qualified domain name (FQDN) for which * the record is being deleted. * @param recordTypes The type of the DNS record to be deleted (e.g., A, CNAME, TXT). * @throws CloudflareApiException If an error occurs while interacting with the Cloudflare API. @@ -292,7 +295,7 @@ public class CfDnsClient extends CfBasicHttpClient { try { RecordEntity rec = sldInfo(zone, sld, recordType); recordDelete(zone, rec); - log.debug("Record {} of type {} successful deleted.", fqdn, recordTypes); + log.info("Record {} of type {} successful deleted.", fqdn, recordTypes); } catch (CloudflareNotFoundException e) { log.debug("Record {} of type {} does not exist.", fqdn, recordTypes); } diff --git a/src/test/resources/logback.xml b/src/test/resources/logback-test.xml similarity index 78% rename from src/test/resources/logback.xml rename to src/test/resources/logback-test.xml index b251d0f..ba396f7 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback-test.xml @@ -1,5 +1,5 @@ - + @@ -8,6 +8,8 @@ + +