From 274fb9afc3dafcb094245f253f39b04955784db6 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 25 Aug 2020 19:28:26 +0200 Subject: [PATCH] platform specific log file location support --- .../sparrowwallet/drongo/PropertyDefiner.java | 21 +++++++++++++++++++ src/main/java/module-info.java | 1 + 2 files changed, 22 insertions(+) create mode 100644 src/main/java/com/sparrowwallet/drongo/PropertyDefiner.java diff --git a/src/main/java/com/sparrowwallet/drongo/PropertyDefiner.java b/src/main/java/com/sparrowwallet/drongo/PropertyDefiner.java new file mode 100644 index 0000000..b074922 --- /dev/null +++ b/src/main/java/com/sparrowwallet/drongo/PropertyDefiner.java @@ -0,0 +1,21 @@ +package com.sparrowwallet.drongo; + +import ch.qos.logback.core.PropertyDefinerBase; + +public class PropertyDefiner extends PropertyDefinerBase { + private String application; + + public void setApplication(String application) { + this.application = application; + } + + @Override + public String getPropertyValue() { + return isWindows() ? System.getenv("APPDATA") + "/" + application.substring(0, 1).toUpperCase() + application.substring(1) : System.getProperty("user.home") + "/." + application; + } + + private boolean isWindows() { + String osName = System.getProperty("os.name"); + return (osName != null && osName.toLowerCase().startsWith("windows")); + } +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 41f8136..fbd2c9f 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -2,6 +2,7 @@ open module com.sparrowwallet.drongo { requires org.bouncycastle.provider; requires de.mkammerer.argon2; requires slf4j.api; + requires logback.core; requires json.simple; requires jeromq; exports com.sparrowwallet.drongo;