根据后端需求修改上报日志接口参数
This commit is contained in:
parent
38a269ae1c
commit
90e249e2d7
@ -1,10 +1,12 @@
|
|||||||
package com.shayu.phonelive;
|
package com.shayu.phonelive;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.yunbao.common.utils.FileUtil;
|
import com.yunbao.common.utils.FileUtil;
|
||||||
import com.yunbao.common.utils.SpUtil;
|
import com.yunbao.common.utils.SpUtil;
|
||||||
|
|
||||||
@ -126,10 +128,11 @@ public class NeverCrashUtils {
|
|||||||
}
|
}
|
||||||
private static String throwableToString(Throwable e) {
|
private static String throwableToString(Throwable e) {
|
||||||
StringWriter writer=new StringWriter();
|
StringWriter writer=new StringWriter();
|
||||||
writer.write(SpUtil.getInstance().getStringValue(SpUtil.USER_INFO));
|
|
||||||
writer.write("\n");
|
|
||||||
writer.write("time="+System.currentTimeMillis());
|
writer.write("time="+System.currentTimeMillis());
|
||||||
writer.write("\n");
|
writer.write("\n");
|
||||||
|
writer.write("UserData=");
|
||||||
|
writer.write(SpUtil.getInstance().getStringValue(SpUtil.USER_INFO));
|
||||||
|
writer.write("\n");
|
||||||
writer.write("[ERROR]");
|
writer.write("[ERROR]");
|
||||||
PrintWriter printWriter=new PrintWriter(writer);
|
PrintWriter printWriter=new PrintWriter(writer);
|
||||||
e.printStackTrace(printWriter);
|
e.printStackTrace(printWriter);
|
||||||
|
@ -139,7 +139,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
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.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.regex.Matcher;
|
||||||
import java.util.Date;
|
import java.util.regex.Pattern;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cxf on 2019/6/20.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
File file = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()+File.separator+"error.log");
|
File file = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + "error.log");
|
||||||
if(file.exists()){
|
if (file.exists()) {
|
||||||
Log.i("异常上传", "pushError: 准备上传文件");
|
Log.i("异常上传", "pushError: 准备上传文件");
|
||||||
String err = FileUtil.loadStringToFile(file);
|
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")
|
PostRequest<String> request = OkGo.<String>post("https://newht.yaoulive.com/index.php/api/error_log/report")
|
||||||
.params("log", err)
|
.params("log", err)
|
||||||
.params("uid", CommonAppConfig.getInstance().getUid())
|
.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("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY)
|
||||||
.params("appVersion",CommonAppConfig.getInstance().getVersion())
|
.params("appVersion", CommonAppConfig.getInstance().getVersion())
|
||||||
.tag("errorLog")
|
.tag("errorLog")
|
||||||
.converter(new StringCallback() {
|
.converter(new StringCallback() {
|
||||||
String TAG = "异常上传";
|
String TAG = "异常上传";
|
||||||
@ -101,4 +110,13 @@ public class LogUtil {
|
|||||||
task.start();
|
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);
|
ConversationIMListManager.get(this).getUserInstructor(this);
|
||||||
checkVersion();
|
checkVersion();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user