根据后端需求修改上报日志接口参数
This commit is contained in:
@@ -16,9 +16,8 @@ import com.yunbao.common.CommonAppConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2019/6/20.
|
||||
@@ -46,20 +45,30 @@ public class LogUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void pushError(Context context){
|
||||
if(!CommonAppConfig.IS_UPLOAD_ERROR_LOG){
|
||||
|
||||
/**
|
||||
* 上报闪退日志
|
||||
*/
|
||||
public static void uploadErrorLog(Context context) {
|
||||
if (!CommonAppConfig.IS_UPLOAD_ERROR_LOG) {
|
||||
return;
|
||||
}
|
||||
File file = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()+File.separator+"error.log");
|
||||
if(file.exists()){
|
||||
File file = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + "error.log");
|
||||
if (file.exists()) {
|
||||
Log.i("异常上传", "pushError: 准备上传文件");
|
||||
String err = FileUtil.loadStringToFile(file);
|
||||
String time = matcher(".(?<=time\\=).*(?=\\nUserData\\=)", err);
|
||||
if(time!=null){
|
||||
time=time.replace("=","");
|
||||
}else{
|
||||
time=System.currentTimeMillis()+"";
|
||||
}
|
||||
PostRequest<String> request = OkGo.<String>post("https://newht.yaoulive.com/index.php/api/error_log/report")
|
||||
.params("log", err)
|
||||
.params("uid", CommonAppConfig.getInstance().getUid())
|
||||
.params("time", new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss", Locale.CHINA).format(new Date()))
|
||||
.params("isGoogle",CommonAppConfig.IS_GOOGLE_PLAY)
|
||||
.params("appVersion",CommonAppConfig.getInstance().getVersion())
|
||||
.params("time",time)
|
||||
.params("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY)
|
||||
.params("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||
.tag("errorLog")
|
||||
.converter(new StringCallback() {
|
||||
String TAG = "异常上传";
|
||||
@@ -101,4 +110,13 @@ public class LogUtil {
|
||||
task.start();
|
||||
}
|
||||
}
|
||||
|
||||
private static String matcher(String regex, String input) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
if (matcher.find()) {
|
||||
return matcher.group();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user