Skip to content

Commit

Permalink
Merge pull request orhanobut#78 from orhanobut/feature
Browse files Browse the repository at this point in the history
Use Logger without init and rename tool to adapter
  • Loading branch information
orhanobut authored Jun 19, 2016
2 parents 7ba7383 + 26228b1 commit 796c825
Show file tree
Hide file tree
Showing 19 changed files with 535 additions and 326 deletions.
16 changes: 6 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ language: android

android:
components:
- build-tools-21.1.1
- android-18
licenses:
- 'android-sdk-license-.+'

notifications:
email: true

sudo: false
- tools
- platform-tools
- build-tools-24.0.0
- android-23
- android-24

script:
- ./gradlew build
- ./gradlew check
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CHANGELOG

### 1.13

- LogTool is renamed to LogAdapter
- Logger.init() is optional now. It used to be mandatory to call this method once.
- Log.e(Throwable) will print out all stacktrace
- Deprecated methods are removed
- Dependencies are updated
22 changes: 5 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ Logger provides :
- Jump to source

### Dependency
https://jitpack.io/#orhanobut/logger/1.12

```groovy
repositories {
// ...
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.orhanobut:logger:1.12'
}
compile 'com.orhanobut:logger:1.13'
```

### Current Log system
Expand All @@ -44,9 +35,6 @@ Logger.d("hello %s %d", "world", 5); // String.format
```
<img src='https://github.com/orhanobut/logger/blob/master/images/description.png'/>

### Usage
Note: Because of the latest changes, Logger.init() must be called once to initiate. This will be fixed in the next version

```java
Logger.d("hello");
Logger.e("hello");
Expand All @@ -71,25 +59,25 @@ Logger.t("mytag").d("hello");

### Settings (optional)
Change the settings with init. This should be called only once. Best place would be in application class. All of them
are optional.
are optional. You can just use the default settings if you don't init Logger.
```java
Logger
.init(YOUR_TAG) // default PRETTYLOGGER or use just init()
.methodCount(3) // default 2
.hideThreadInfo() // default shown
.logLevel(LogLevel.NONE) // default LogLevel.FULL
.methodOffset(2) // default 0
.logTool(new AndroidLogTool()); // custom log tool, optional
.logAdapter(new AndroidLogAdapter()); //default AndroidLogAdapter
}

```
Note: Use LogLevel.NONE for the release versions.

### Use another log util instead of android.util.log
- Implement LogTool
- Implement LogAdapter
- set it with init
```java
.logTool(new MyCustomLogTool())
.logAdapter(new CustomLogAdapter())
```

### More log samples
Expand Down
53 changes: 43 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
subprojects { project ->
group = GROUP
version = VERSION_NAME

buildscript {
repositories {
jcenter()
apply plugin: 'checkstyle'

task checkstyle(type: Checkstyle) {
configFile rootProject.file('checkstyle.xml')
source 'src/main/java'
ignoreFailures false
showViolations true
include '**/*.java'

classpath = files()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
afterEvaluate {
if (project.tasks.findByName('check')) {
check.dependsOn('checkstyle')
}
}

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
}

allprojects {
repositories {
jcenter()
}
}

ext {
minSdkVersion = 8
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = '24.0.0'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
}

ext.deps = [
// Test dependencies
junit : 'junit:junit:4.12',
truth : 'com.google.truth:truth:0.28',
robolectric: 'org.robolectric:robolectric:3.1',
mockito : "org.mockito:mockito-core:1.10.19"
]
31 changes: 13 additions & 18 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=1.13
GROUP=com.orhanobut

POM_DESCRIPTION=Simple, Pretty and Advanced Logger
POM_URL=https://github.com/orhanobut/logger
POM_SCM_URL=https://github.com/orhanobut/logger
POM_SCM_CONNECTION=scm:git@https://github.com/orhanobut/logger.git
POM_SCM_DEV_CONNECTION=scm:git@https://github.com/orhanobut/logger.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=nr4bt
POM_DEVELOPER_NAME=Orhan Obut
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
50 changes: 11 additions & 39 deletions logger/build.gradle
Original file line number Diff line number Diff line change
@@ -1,52 +1,24 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'checkstyle'

check.dependsOn('checkstyle')

task checkstyle(type: Checkstyle) {
configFile = rootProject.file('checkstyle.xml')
source 'src'
include '**/*.java'
exclude '**/gen/**'

classpath = files()
}

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion 8
targetSdkVersion 22
minSdkVersion rootProject.ext.minSdkVersion
}

lintOptions {
abortOnError false
textReport true
textOutput 'stdout'
}
}

// build a jar with source files
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
dependencies {
testCompile deps.junit
testCompile deps.truth
testCompile deps.robolectric
testCompile deps.mockito
}

dependencies {
testCompile 'junit:junit:4.12'
testCompile "org.robolectric:robolectric:3.0"
testCompile 'org.assertj:assertj-core:1.7.0'
}
apply from: rootProject.file('maven_push.gradle')
3 changes: 3 additions & 0 deletions logger/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=Logger
POM_ARTIFACT_ID=logger
POM_PACKAGING=aar
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.util.Log;

class AndroidLogTool implements LogTool {
class AndroidLogAdapter implements LogAdapter {
@Override public void d(String tag, String message) {
Log.d(tag, message);
}
Expand Down
Loading

0 comments on commit 796c825

Please sign in to comment.