GKerison/KLog


a kit for android log

Download


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"]]
        
        

Readme


KLog

Android上一个简单易用的Log日志库

  • 支持自定义Tag
  • 支持自定义输出样式
  • 支持输出线程
  • 支持输出调用的方法名 文件名 包名 行数
  • 支持输出调用栈层级
  • 支持屏蔽日志

KLog TODO :ear_of_rice:

  • [x] 更方便的Log配置 [已完成]
  • [x] 无参数的情况支持 [已完成]
  • [x] 自定义纯文本输出等级 [已完成]

KLog Usages

  1. 项目的build.gradle增加JitPack repository
allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}
  1. 模块的build.gradle增加dependency
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);

KLog ScreenShot

个人使用的时候,建议配合自定义自己喜欢的Console的Log颜色和字体,打印出来的效果更明显。

  • Setting > Editor > Colors&Fonts > Android Logcat
  • 另存为自己的Scheme
  • 修改前景色(去掉Use inherited attributes) Log预览