Skip to content

Commit

Permalink
Merge pull request #170 from orhanobut/version-2.2
Browse files Browse the repository at this point in the history
Version 2.2
  • Loading branch information
orhanobut authored Mar 24, 2018
2 parents 0e80af4 + 3b0e6be commit 1e9ea42
Show file tree
Hide file tree
Showing 14 changed files with 396 additions and 15 deletions.
229 changes: 229 additions & 0 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Simple, pretty and powerful logger for android
### Setup
Download
```groovy
compile 'com.orhanobut:logger:2.1.1'
implementation 'com.orhanobut:logger:2.2.0'
```

Initialize
Expand All @@ -32,15 +32,15 @@ Logger.e("error");
Logger.w("warning");
Logger.v("verbose");
Logger.i("information");
Logger.wtf("wtf!!!!");
Logger.wtf("What a Terrible Failure");
```

String format arguments are supported
```java
Logger.d("hello %s", "world");
```

Collections support (only available for debug logs)
Collections are supported (only available for debug logs)
```java
Logger.d(MAP);
Logger.d(SET);
Expand Down Expand Up @@ -68,8 +68,9 @@ Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));
```

### Loggable
Log adapters checks whether the log should be printed out or not by checking this function.
If you want to disable/hide logs for output, override `isLoggable` method and put the condition.
Log adapter checks whether the log should be printed or not by checking this function.
If you want to disable/hide logs for output, override `isLoggable` method.
`true` will print the log message, `false` will ignore it.
```java
Logger.addLogAdapter(new AndroidLogAdapter() {
@Override public boolean isLoggable(int priority, String tag) {
Expand Down Expand Up @@ -98,7 +99,7 @@ Logger.addLogAdapter(new DiskLogAdapter(formatStrategy));


### More
- Use the filter for a better result. PRETTY_LOGGER or your custom tag
- Use filter for a better result. PRETTY_LOGGER or your custom tag
- Make sure that wrap option is disabled
- You can also simplify output by changing settings.

Expand All @@ -114,13 +115,9 @@ Timber.plant(new Timber.DebugTree() {
});
```

### Breaking changes
- Initialization is changed. No backward compatibility support. Use `Logger.addLogAdapter`
- LogLevel is removed. Use the new `isLoggable` approach

### License
<pre>
Copyright 2017 Orhan Obut
Copyright 2018 Orhan Obut

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.1.1
VERSION_NAME=2.2.0
GROUP=com.orhanobut

POM_DESCRIPTION=Simple, Pretty and Advanced Logger
Expand Down
2 changes: 1 addition & 1 deletion gradle/maven_push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ afterEvaluate { project ->
pom.artifactId = POM_ARTIFACT_ID
repository(url: sonatypeRepositoryUrl) {
try {
authentication(userName: mavenUser, password: mavenPassword)
authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD)
} catch (Exception ignored) {
println "mavenUser or mavenPassword is missing"
}
Expand Down
13 changes: 13 additions & 0 deletions logger/src/main/java/com/orhanobut/logger/AndroidLogAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@

import static com.orhanobut.logger.Utils.checkNotNull;

/**
* Android terminal log output implementation for {@link LogAdapter}.
*
* Prints output to LogCat with pretty borders.
*
* <pre>
* ┌──────────────────────────
* │ Method stack history
* ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
* │ Log message
* └──────────────────────────
* </pre>
*/
public class AndroidLogAdapter implements LogAdapter {

@NonNull private final FormatStrategy formatStrategy;
Expand Down
4 changes: 4 additions & 0 deletions logger/src/main/java/com/orhanobut/logger/DiskLogAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

import static com.orhanobut.logger.Utils.checkNotNull;

/**
* This is used to saves log messages to the disk.
* By default it uses {@link CsvFormatStrategy} to translates text message into CSV format.
*/
public class DiskLogAdapter implements LogAdapter {

@NonNull private final FormatStrategy formatStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
/**
* Abstract class that takes care of background threading the file log operation on Android.
* implementing classes are free to directly perform I/O operations there.
*
* Writes all logs to the disk with CSV format.
*/
public class DiskLogStrategy implements LogStrategy {

Expand Down
6 changes: 6 additions & 0 deletions logger/src/main/java/com/orhanobut/logger/FormatStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

/**
* Used to determine how messages should be printed or saved.
*
* @see PrettyFormatStrategy
* @see CsvFormatStrategy
*/
public interface FormatStrategy {

void log(int priority, @Nullable String tag, @NonNull String message);
Expand Down
24 changes: 23 additions & 1 deletion logger/src/main/java/com/orhanobut/logger/LogAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,31 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

/**
* Provides a common interface to emits logs through. This is a required contract for Logger.
*
* @see AndroidLogAdapter
* @see DiskLogAdapter
*/
public interface LogAdapter {

/**
* Used to determine whether log should be printed out or not.
*
* @param priority is the log level e.g. DEBUG, WARNING
* @param tag is the given tag for the log message
*
* @return is used to determine if log should printed.
* If it is true, it will be printed, otherwise it'll be ignored.
*/
boolean isLoggable(int priority, @Nullable String tag);

/**
* Each log will use this pipeline
*
* @param priority is the log level e.g. DEBUG, WARNING
* @param tag is the given tag for the log message.
* @param message is the given message for the log message.
*/
void log(int priority, @Nullable String tag, @NonNull String message);
}
}
Loading

0 comments on commit 1e9ea42

Please sign in to comment.