README.md 2.5 KB
Newer Older
Z
ZhaoKaiQiang 已提交
1
# KLog
Z
ZhaoKaiQiang 已提交
2

Z
ZhaoKaiQiang 已提交
3 4
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ZhaoKaiQiang-green.svg?style=true)](https://android-arsenal.com/details/1/2782)

Z
ZhaoKaiQiang 已提交
5 6
This is a useful log tool for Android 

Z
ZhaoKaiQiang 已提交
7
Android LogCat 工具类,支持行号、所在函数、点击自动跳转、Json格式自定解析打印、存储Log到文件等功能。
Z
ZhaoKaiQiang 已提交
8

Z
ZhaoKaiQiang 已提交
9
中文文档请戳[这里](http://blog.csdn.net/zhaokaiqiang1992/article/details/49837627)
Z
ZhaoKaiQiang 已提交
10 11 12 13 14 15 16 17 18

---

##Features

- Can use KLog.d() with no tag
- Print log info with line number and method name
- Jump to the position where the log is invoked, by click in the Android Studio Logcat

Z
ZhaoKaiQiang 已提交
19 20 21 22 23
##Update

- Add support for Long JSON String
- KLog.file() could save the log to file

Z
ZhaoKaiQiang 已提交
24 25
##Sample Usage

Z
ZhaoKaiQiang 已提交
26
![](https://github.com/ZhaoKaiQiang/KLog/blob/master/image/demo.gif)
Z
ZhaoKaiQiang 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

###KLog.d()

Use this method , you can get a log like follwing,default tag is current class name

![](http://i13.tietuku.com/6eac96ebfbea82cb.png)

###KLog.d(String)

you can print a String with this method ,default tag is current class name
![](http://i13.tietuku.com/95871d0388a27777.png)

###KLog.d(Tag,String)

you can set tag by youself , the result is as bollow 
![](http://i13.tietuku.com/f0286fa45f975346.png)

###KLog.json(String)

you can print a String with json format ,and it will be formated as following
![](http://i13.tietuku.com/767fa81ad27c8f9f.png)

###KLog.json(Tag,String)

as same as above , but with a tag whitch are set by yourself
![](http://i13.tietuku.com/bc9714547a4f50fe.png)

Z
ZhaoKaiQiang 已提交
54 55
###KLog.file()

Z
update  
ZhaoKaiQiang 已提交
56
you can save the log string in to file !
Z
ZhaoKaiQiang 已提交
57 58 59 60 61

```
 KLog.file(TAG, Environment.getExternalStorageDirectory(), "test.txt", JSON_LONG);
```

Z
ZhaoKaiQiang 已提交
62
![](https://github.com/ZhaoKaiQiang/KLog/blob/master/image/file.png)
Z
ZhaoKaiQiang 已提交
63

Z
ZhaoKaiQiang 已提交
64 65 66 67
##JCenter

```
dependencies {
Z
ZhaoKaiQiang 已提交
68
    compile 'com.github.zhaokaiqiang.klog:library:0.2.0'
Z
ZhaoKaiQiang 已提交
69 70 71
}
```

Z
ZhaoKaiQiang 已提交
72 73 74
##License

```
Z
ZhaoKaiQiang 已提交
75
Copyright 2015, 2016 ZhaoKaiQiang
Z
ZhaoKaiQiang 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

##About me
- [Android Developer](http://weibo.com/zhaokaiqiang1992)
- [CSDN Blog](http://blog.csdn.net/zhaokaiqiang1992)