Skip to content

Commit

Permalink
2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CPPAlien committed Jul 21, 2016
1 parent bf56c33 commit 8f7201c
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# PtLog
[![](https://jitpack.io/v/CPPAlien/VinciLog.svg)](https://jitpack.io/#CPPAlien/VinciLog)
# VinciLog

Friendly android log lib, includes crash info collection, log saving, and more friendly log printing format

## Features
1, When unexpected crash happened, it can save crash info and device info to local file.
2, Friendly log format: log info includes class name, method name and line num of logging place, make you easy find where the log happened.

2, Friendly log format: log info includes thread id, class name, method name and line num of logging place, make you easy find where the log happened.
3, Divide the log into different level, you can chose to display different level log.
## How to use

### Import lib
Expand All @@ -14,41 +15,36 @@ repositories{
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.CPPAlien:PtLog:1.0.7'
compile 'com.github.CPPAlien:PtLog:2.0.0'
}
```

### Initiation
```
PtLog.init(boolean isEnable, String tag, Context context)
VinciLog.init(LogLevel, TAG, Context context);
```
You should init PtLog before using it, if else the log will not be displayed
You should init VinciLog before using it, if else the log will not be displayed
So you are suggested putting the init code in the Application onCreate method

***Tips: You may use BuildConfig.DEBUG as first parameter, like PtLog.init(BuildConfig.DEBUG, "peng", this); This will make the log printing opened in Debug version and closed in Release version.***

### Save log to local file

```
PtLog.startLogSave()
```
After the code called, the log printed next will be saved.
```
String path = PtLog.getLogPath()
```
Get the log absolute path, you can handle it by yourself. For example, you can show it in a TextView, or upload to your server.
```
PtLog.deleteLog()
```
Delete the log, return true or false

#### Usage
PtLog.d("test");

PtLog.e("test");
...


###log level instruction
LogLevel.NONE : Do not show any log info
LogLevel.DEBUG : Show debug and above log
LogLevel.INFO : show info and below level log
LogLevel.WARN : show warn and below level log
LogLevel.ERROR : only show error log

### Example
VinciLog.init(LogLevel.DEBUG, "PENG", this);
VinciLog.e("This is a test");

If the code run, you can see the log displayed in Logcat:
`07-21 14:18:01.738 8529-8529/? E/PENG: [1] MainActivity.onCreate(MainActivity.java:17):This is a test`

`PENG` is the tag
`[1]` is the id of thread the log printed in, 1 means in main thread.
`MainActivity.onCreate` means the log printed in onCreate Method of MainActivity class
`(MainActivity.java:17)` means the log is at 17 lines of the file
`This is a test` is the content of the log

## TODO
More friendly log format, like logger(https://github.com/orhanobut/logger)
Expand Down

0 comments on commit 8f7201c

Please sign in to comment.