Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.GKerison:KLog:2.1.0'
}
dependencies {
implementation("com.github.GKerison:KLog:2.1.0")
}
<dependency>
<groupId>com.github.GKerison</groupId>
<artifactId>KLog</artifactId>
<version>2.1.0</version>
</dependency>
libraryDependencies += "com.github.GKerison" % "KLog" % "2.1.0"
:dependencies [[com.github.GKerison/KLog "2.1.0"]]
Android上一个简单易用的Log日志库
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.GKerison:KLog:2.1.0'
}
KL.config(BuildConfig.DEBUG).setTag("DEBUG").setTextLevel(Log.WARN).setMethodCount(1);
KL.i();
String name = "kerison";
String json = " {\"citys\": [\n" +
" {\n" +
" \"id\": \"110000\",\n" +
" \"full_name\": \"北京市\"\n" +
" },\n" +
" {\n" +
" \"id\": \"120000\",\n" +
" \"full_name\": \"天津市\"\n" +
" }\n" +
" ]}";
String xml = "<manifest package=\"cn.kerison.kit.log\"\n" +
" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n" +
" <application />\n" +
"</manifest>\n";
KL.v("hello %s ", name);
KL.d("hello %s ", name);
KL.i("hello %s ", name);
KL.w("hello %s ", name);
KL.e("hello %s ", name);
KL.wtf("hello %s ", name);
KL.json(json);
KL.xml(xml);
个人使用的时候,建议配合自定义自己喜欢的Console的Log颜色和字体,打印出来的效果更明显。