From 3cd4f03002044a3353d5b2a742c62e685963dcb6 Mon Sep 17 00:00:00 2001 From: Orhan Obut Date: Sat, 27 May 2017 15:19:50 +0200 Subject: [PATCH] Refactor in general for some small changes - Move LogItem into LogAssert - Add csv format strategy sample to README - Fix some inspected code --- .gitignore | 1 - README.md | 9 +++++++++ gradle/maven_push.gradle | 2 +- .../java/com/orhanobut/logger/DiskLogStrategy.java | 1 + .../test/java/com.orhanobut.logger/LogAssert.java | 12 ++++++++++++ .../src/test/java/com.orhanobut.logger/LogItem.java | 13 ------------- .../com.orhanobut.logger/LoggerPrinterTest.java | 8 -------- .../PrettyFormatStrategyTest.java | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 logger/src/test/java/com.orhanobut.logger/LogItem.java diff --git a/.gitignore b/.gitignore index 0f3be5a1..aae8b8a5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ build/ # Gradle files .gradle/ -credential.properties /captures # Log Files diff --git a/README.md b/README.md index 6af67e02..a2ff3d5f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,15 @@ Logger.addLogAdapter(new AndroidLogAdapter(){ Logger.addLogAdapter(new DiskLogAdapter()); ``` +Add custom tag to Csv format strategy +```java +FormatStrategy formatStrategy = CsvFormatStrategy.newBuilder() + .tag("custom") + .build(); + +Logger.addLogAdapter(new DiskLogAdapter(formatStrategy)); +``` + ### How it works diff --git a/gradle/maven_push.gradle b/gradle/maven_push.gradle index 50e961d3..584ecfb7 100644 --- a/gradle/maven_push.gradle +++ b/gradle/maven_push.gradle @@ -28,7 +28,7 @@ afterEvaluate { project -> repository(url: sonatypeRepositoryUrl) { try { authentication(userName: mavenUser, password: mavenPassword) - } catch (Exception e) { + } catch (Exception ignored) { println "mavenUser or mavenPassword is missing" } } diff --git a/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java b/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java index 78d2530b..38fada4a 100644 --- a/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java +++ b/logger/src/main/java/com/orhanobut/logger/DiskLogStrategy.java @@ -75,6 +75,7 @@ private File getLogFile(String folderName, String fileName) { File folder = new File(folderName); if (!folder.exists()) { + // TODO: What if folder is not created, what happens then? folder.mkdirs(); } diff --git a/logger/src/test/java/com.orhanobut.logger/LogAssert.java b/logger/src/test/java/com.orhanobut.logger/LogAssert.java index b441e09a..2028ecc4 100644 --- a/logger/src/test/java/com.orhanobut.logger/LogAssert.java +++ b/logger/src/test/java/com.orhanobut.logger/LogAssert.java @@ -71,4 +71,16 @@ void hasNoMoreMessages() { assertThat(items).hasSize(index); items.clear(); } + + static class LogItem { + final int priority; + final String tag; + final String message; + + LogItem(int priority, String tag, String message) { + this.priority = priority; + this.tag = tag; + this.message = message; + } + } } diff --git a/logger/src/test/java/com.orhanobut.logger/LogItem.java b/logger/src/test/java/com.orhanobut.logger/LogItem.java deleted file mode 100644 index d0b83152..00000000 --- a/logger/src/test/java/com.orhanobut.logger/LogItem.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.orhanobut.logger; - -public class LogItem { - public final int priority; - public final String tag; - public final String message; - - public LogItem(int priority, String tag, String message) { - this.priority = priority; - this.tag = tag; - this.message = message; - } -} diff --git a/logger/src/test/java/com.orhanobut.logger/LoggerPrinterTest.java b/logger/src/test/java/com.orhanobut.logger/LoggerPrinterTest.java index 04e0b97e..e4dcbf15 100644 --- a/logger/src/test/java/com.orhanobut.logger/LoggerPrinterTest.java +++ b/logger/src/test/java/com.orhanobut.logger/LoggerPrinterTest.java @@ -138,14 +138,6 @@ public class LoggerPrinterTest { } @Test public void logJsonArray() { - String[] messages = new String[]{ - "[", - " {", - " \"key\": 3", - " }", - "]" - }; - printer.json("[{\"key\":3}]"); verify(adapter).log(DEBUG, null, "[{\"key\": 3}]"); diff --git a/logger/src/test/java/com.orhanobut.logger/PrettyFormatStrategyTest.java b/logger/src/test/java/com.orhanobut.logger/PrettyFormatStrategyTest.java index af5af1a2..b92548c4 100644 --- a/logger/src/test/java/com.orhanobut.logger/PrettyFormatStrategyTest.java +++ b/logger/src/test/java/com.orhanobut.logger/PrettyFormatStrategyTest.java @@ -170,10 +170,10 @@ public class PrettyFormatStrategyTest { } private static class MockLogStrategy implements LogStrategy { - List logItems = new ArrayList<>(); + List logItems = new ArrayList<>(); @Override public void log(int priority, String tag, String message) { - logItems.add(new LogItem(priority, tag, message)); + logItems.add(new LogAssert.LogItem(priority, tag, message)); } }