From 2b79c7669f57933f6a9028f8042777272afcf3f1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 8 Jan 2024 12:39:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Key-Value=E3=81=AA=E3=83=AD=E3=82=B0?= =?UTF-8?q?=E3=82=92=E5=87=BA=E5=8A=9B=E3=81=97=E3=82=84=E3=81=99=E3=81=8F?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/utils/LacertaLogger.java | 5 ++++ .../lacerta/utils/impl/LacertaLoggerImpl.java | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java b/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java index f49da584..8de3a97b 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java +++ b/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java @@ -1,5 +1,7 @@ package one.nem.lacerta.utils; +import one.nem.lacerta.utils.model.KeyValueLog; + public interface LacertaLogger { void info(String tag, String message); @@ -9,4 +11,7 @@ public interface LacertaLogger { void trace(String tag, String message); void fatal(String tag, String message); + String buildMessageByObject(KeyValueLog... logs); + // With name + String buildMessageByObject(String name, KeyValueLog... logs); } diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java index aba337d8..aedf1f0f 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java @@ -5,6 +5,8 @@ import android.util.Log; import javax.inject.Inject; import one.nem.lacerta.utils.LacertaLogger; +import one.nem.lacerta.utils.model.KeyValueLog; + public class LacertaLoggerImpl implements LacertaLogger{ @Inject @@ -40,4 +42,30 @@ public class LacertaLoggerImpl implements LacertaLogger{ public void fatal(String tag, String message) { Log.wtf(tag, message); } + + @Override + public String buildMessageByObject(KeyValueLog... logs) { + StringBuilder builder = new StringBuilder(); + for (KeyValueLog log : logs) { + builder.append(log.getKey()); + builder.append(": "); + builder.append(log.getValue()); + builder.append("\n"); + } + return builder.toString(); + } + + @Override + public String buildMessageByObject(String name, KeyValueLog... logs) { + StringBuilder builder = new StringBuilder(); + builder.append(name); + builder.append("\n"); + for (KeyValueLog log : logs) { + builder.append(log.getKey()); + builder.append(": "); + builder.append(log.getValue()); + builder.append("\n"); + } + return builder.toString(); + } } From 48101190a2ec89f208a46ee03fe0b47e9ac09ae2 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 8 Jan 2024 12:41:10 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java | 4 ++-- .../java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java b/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java index 8de3a97b..64076771 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java +++ b/utils/src/main/java/one/nem/lacerta/utils/LacertaLogger.java @@ -11,7 +11,7 @@ public interface LacertaLogger { void trace(String tag, String message); void fatal(String tag, String message); - String buildMessageByObject(KeyValueLog... logs); + String buildKVMessage(KeyValueLog... logs); // With name - String buildMessageByObject(String name, KeyValueLog... logs); + String buildKVMessage(String name, KeyValueLog... logs); } diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java index aedf1f0f..d2b35dd2 100644 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java +++ b/utils/src/main/java/one/nem/lacerta/utils/impl/LacertaLoggerImpl.java @@ -44,7 +44,7 @@ public class LacertaLoggerImpl implements LacertaLogger{ } @Override - public String buildMessageByObject(KeyValueLog... logs) { + public String buildKVMessage(KeyValueLog... logs) { StringBuilder builder = new StringBuilder(); for (KeyValueLog log : logs) { builder.append(log.getKey()); @@ -56,7 +56,7 @@ public class LacertaLoggerImpl implements LacertaLogger{ } @Override - public String buildMessageByObject(String name, KeyValueLog... logs) { + public String buildKVMessage(String name, KeyValueLog... logs) { StringBuilder builder = new StringBuilder(); builder.append(name); builder.append("\n"); From 88dfae7d37738860513e40e4b1f172e55115004d Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 8 Jan 2024 12:35:30 +0900 Subject: [PATCH 3/4] =?UTF-8?q?KeyValue=E3=83=AD=E3=82=B0=E3=83=A2?= =?UTF-8?q?=E3=83=87=E3=83=AB=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/model/KeyValueLog.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 model/src/main/java/one/nem/lacerta/model/KeyValueLog.java diff --git a/model/src/main/java/one/nem/lacerta/model/KeyValueLog.java b/model/src/main/java/one/nem/lacerta/model/KeyValueLog.java new file mode 100644 index 00000000..ac5ea426 --- /dev/null +++ b/model/src/main/java/one/nem/lacerta/model/KeyValueLog.java @@ -0,0 +1,31 @@ +package one.nem.lacerta.model; + +public class KeyValueLog { + + String key; + String value; + + public KeyValueLog(String key, String value) { + this.key = key; + this.value = value; + } + + // Getter + public String getKey() { + return key; + } + + public String getValue() { + return value; + } + + // Setter + public void setKey(String key) { + this.key = key; + } + + public void setValue(String value) { + this.value = value; + } + +} From dec4983bfc02951bb4e349bb05cb5c803b759866 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 8 Jan 2024 12:36:39 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/one/nem/lacerta/utils}/model/KeyValueLog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {model/src/main/java/one/nem/lacerta => utils/src/main/java/one/nem/lacerta/utils}/model/KeyValueLog.java (92%) diff --git a/model/src/main/java/one/nem/lacerta/model/KeyValueLog.java b/utils/src/main/java/one/nem/lacerta/utils/model/KeyValueLog.java similarity index 92% rename from model/src/main/java/one/nem/lacerta/model/KeyValueLog.java rename to utils/src/main/java/one/nem/lacerta/utils/model/KeyValueLog.java index ac5ea426..e33d0355 100644 --- a/model/src/main/java/one/nem/lacerta/model/KeyValueLog.java +++ b/utils/src/main/java/one/nem/lacerta/utils/model/KeyValueLog.java @@ -1,4 +1,4 @@ -package one.nem.lacerta.model; +package one.nem.lacerta.utils.model; public class KeyValueLog {