Skip to content

Commit

Permalink
delete useless commit
Browse files Browse the repository at this point in the history
  • Loading branch information
郭文明 committed Jul 22, 2016
1 parent 6313400 commit 15e4a6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 42 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ public class MyApplication extends Application {
}

```

## 上传
在任意地方,调用以下方法即可,崩溃发生后,会在下一次App启动的时候使用Service异步打包日志,然后上传日志,发送成功与否,Service都会自动退出释放内存
``` java
LogReport.getInstance().upload(context);
```

## 发往服务器

如果您有自己的服务器,想往服务器发送本地保存的日志文件,而不是通过邮箱发送。请使用以下方法替换initEmailReporter方法
``` java

Expand All @@ -96,11 +105,6 @@ public class MyApplication extends Application {
LogWriter.writeLog("wenming", "打Log测试!!!!");
```

## 上传
在任意地方,调用以下方法即可,崩溃发生后,会在下一次App启动的时候使用Service异步打包日志,然后上传日志,发送成功与否,Service都会自动退出释放内存
``` java
LogReport.getInstance().upload(context);
```

## 关于使用邮件上传的注意事项
- 强烈建议使用163邮箱作为发送崩溃的邮箱,并且此邮箱务必要开启SMTP服务,如下图所示,才能发送邮件成功!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import java.util.concurrent.Future;

/**
* 抽象的日志报告类
*/
public abstract class BaseUpload implements ILogUpload {
public Context mContext;
public Future mFuture;

public final static SimpleDateFormat yyyy_MM_dd_HH_mm_ss_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS", Locale.getDefault());

Expand All @@ -52,15 +50,7 @@ public BaseUpload(Context context) {

@Override
public void sendFile(final File file, final String content, final OnUploadFinishedListener onUploadFinishedListener) {
if (mFuture != null && !mFuture.isDone()) {
mFuture.cancel(false);
}
new Thread(new Runnable() {
@Override
public void run() {
sendReport(buildTitle(mContext), buildBody(mContext, content), file, onUploadFinishedListener);
}
}).start();
sendReport(buildTitle(mContext), buildBody(mContext, content), file, onUploadFinishedListener);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,17 @@ protected void sendReport(String title, String body, File file, OnUploadFinished
}
}

private void deleteLog(File file) {
private boolean deleteLog(File file) {
Log.d("HttpReporter", "delete: " + file.getName());
file.delete();
return file.delete();
}

public String getUrl() {
return url;
}

/**
* 发送请求的地址。
*
* @param url
* @param url 发送请求的地址。
*/
public HttpReporter setUrl(String url) {
this.url = url;
Expand All @@ -101,9 +99,7 @@ public String getTitleParam() {
}

/**
* 标题的参数名
*
* @param titleParam
* @param titleParam 标题的参数名
*/
public HttpReporter setTitleParam(String titleParam) {
this.titleParam = titleParam;
Expand All @@ -115,9 +111,7 @@ public String getBodyParam() {
}

/**
* 内容的参数名
*
* @param bodyParam
* @param bodyParam 内容的参数名
*/
public HttpReporter setBodyParam(String bodyParam) {
this.bodyParam = bodyParam;
Expand All @@ -129,9 +123,7 @@ public String getFileParam() {
}

/**
* 文件的参数名
*
* @param fileParam
* @param fileParam 文件的参数名
*/
public HttpReporter setFileParam(String fileParam) {
this.fileParam = fileParam;
Expand All @@ -143,9 +135,9 @@ public Map<String, String> getOtherParams() {
}

/**
* 其他自定义的参数对(可不设置)
* 。
*
* @param otherParams
* @param otherParams 其他自定义的参数对(可不设置)
*/
public void setOtherParams(Map<String, String> otherParams) {
this.otherParams = otherParams;
Expand All @@ -156,9 +148,7 @@ public String getTo() {
}

/**
* 收件人
*
* @param to
* @param to 收件人
*/
public HttpReporter setTo(String to) {
this.to = to;
Expand All @@ -170,9 +160,7 @@ public HttpReportCallback getCallback() {
}

/**
* 设置发送请求之后的回调接口。
*
* @param callback
* @param callback 设置发送请求之后的回调接口。
*/
public HttpReporter setCallback(HttpReportCallback callback) {
this.callback = callback;
Expand All @@ -184,9 +172,7 @@ public String getToParam() {
}

/**
* 收件人参数名。
*
* @param toParam
* @param toParam 收件人参数名。
*/
public HttpReporter setToParam(String toParam) {
this.toParam = toParam;
Expand All @@ -200,7 +186,7 @@ public interface HttpReportCallback {
*
* @param status 状态码
* @param content 返回的内容。
* @return
* @return 如果成功,则日志文件会被删除,返回true
*/
public boolean isSuccess(int status, String content);
}
Expand Down

0 comments on commit 15e4a6b

Please sign in to comment.