From 29faafbbdb068192bfe83b585436b46482aa8e14 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 3 Jan 2025 14:45:40 +0100 Subject: [PATCH] added minimal logging Signed-off-by: Stephan Richter --- de.srsoftware.configuration.json/build.gradle.kts | 2 +- .../java/de/srsoftware/configuration/JsonConfig.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/de.srsoftware.configuration.json/build.gradle.kts b/de.srsoftware.configuration.json/build.gradle.kts index 4b55843..ab0dcbb 100644 --- a/de.srsoftware.configuration.json/build.gradle.kts +++ b/de.srsoftware.configuration.json/build.gradle.kts @@ -14,7 +14,7 @@ object Meta { val COMPONENT_TYPE = "java" // "java" or "versionCatalog" val GROUP = "de.srsoftware" val ARTIFACT_ID = "configuration.json" - val VERSION = "1.0.0" + val VERSION = "1.0.1" val PUBLISHING_TYPE = "AUTOMATIC" // USER_MANAGED or AUTOMATIC val SHA_ALGORITHMS = listOf("SHA-256", "SHA-512") // sha256 and sha512 are supported but not mandatory. Only sha1 is mandatory but it is supported by default. val DESC = "SRSoftware Configuration: Json-based Implementation" diff --git a/de.srsoftware.configuration.json/src/main/java/de/srsoftware/configuration/JsonConfig.java b/de.srsoftware.configuration.json/src/main/java/de/srsoftware/configuration/JsonConfig.java index 6d906cf..507aace 100644 --- a/de.srsoftware.configuration.json/src/main/java/de/srsoftware/configuration/JsonConfig.java +++ b/de.srsoftware.configuration.json/src/main/java/de/srsoftware/configuration/JsonConfig.java @@ -2,6 +2,9 @@ package de.srsoftware.configuration; +import static java.lang.System.Logger; +import static java.lang.System.getLogger; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -9,14 +12,14 @@ import java.nio.file.Files; import java.util.*; import org.json.JSONObject; - /** * A Configuration implementation, that stores its data in a json file. * Altered json <em>is not automatically saved>/em< after editing! */ public class JsonConfig implements Configuration { - private final File file; - private final JSONObject json; + private static final Logger LOG = getLogger(JsonConfig.class.getSimpleName()); + private final File file; + private final JSONObject json; /** * Create a new JsonConfig instance using the passed file for storage @@ -29,6 +32,7 @@ public class JsonConfig implements Configuration { if (!file.exists()) try (var out = new FileWriter(file)) { out.write("{}\n"); } + LOG.log(Logger.Level.INFO, "Loading json config file from {0}…", file); json = new JSONObject(Files.readString(file.toPath())); }