Skip to content

Commit

Permalink
Refactor in general for some small changes
Browse files Browse the repository at this point in the history
- Move LogItem into LogAssert
- Add csv format strategy sample to README
- Fix some inspected code
  • Loading branch information
Orhan Obut committed May 27, 2017
1 parent 61030e1 commit 3cd4f03
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ build/
# Gradle files
.gradle/

credential.properties
/captures

# Log Files
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<img src='https://github.com/orhanobut/logger/blob/master/art/how_it_works.png'/>

Expand Down
2 changes: 1 addition & 1 deletion gradle/maven_push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
12 changes: 12 additions & 0 deletions logger/src/test/java/com.orhanobut.logger/LogAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
13 changes: 0 additions & 13 deletions logger/src/test/java/com.orhanobut.logger/LogItem.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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}]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ public class PrettyFormatStrategyTest {
}

private static class MockLogStrategy implements LogStrategy {
List<LogItem> logItems = new ArrayList<>();
List<LogAssert.LogItem> 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));
}
}

Expand Down

0 comments on commit 3cd4f03

Please sign in to comment.