根据后端需求修改上报日志接口参数
This commit is contained in:
parent
38a269ae1c
commit
90e249e2d7
@ -1,10 +1,12 @@
|
||||
package com.shayu.phonelive;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.yunbao.common.utils.FileUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
|
||||
@ -126,10 +128,11 @@ public class NeverCrashUtils {
|
||||
}
|
||||
private static String throwableToString(Throwable e) {
|
||||
StringWriter writer=new StringWriter();
|
||||
writer.write(SpUtil.getInstance().getStringValue(SpUtil.USER_INFO));
|
||||
writer.write("\n");
|
||||
writer.write("time="+System.currentTimeMillis());
|
||||
writer.write("\n");
|
||||
writer.write("UserData=");
|
||||
writer.write(SpUtil.getInstance().getStringValue(SpUtil.USER_INFO));
|
||||
writer.write("\n");
|
||||
writer.write("[ERROR]");
|
||||
PrintWriter printWriter=new PrintWriter(writer);
|
||||
e.printStackTrace(printWriter);
|
||||
|
@ -139,7 +139,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
||||
}
|
||||
};
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
LogUtil.pushError(AppContext.sInstance);
|
||||
LogUtil.uploadErrorLog(AppContext.sInstance);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,7 +45,11 @@ public class LogUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void pushError(Context context){
|
||||
|
||||
/**
|
||||
* 上报闪退日志
|
||||
*/
|
||||
public static void uploadErrorLog(Context context) {
|
||||
if (!CommonAppConfig.IS_UPLOAD_ERROR_LOG) {
|
||||
return;
|
||||
}
|
||||
@ -54,10 +57,16 @@ public class LogUtil {
|
||||
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("time",time)
|
||||
.params("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY)
|
||||
.params("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||
.tag("errorLog")
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -471,7 +471,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
//获取指导员账号
|
||||
ConversationIMListManager.get(this).getUserInstructor(this);
|
||||
checkVersion();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user