fix bug https://github.com/AriaLyy/Aria/issues/702 优化异常提示
This commit is contained in:
@@ -19,13 +19,14 @@ package com.arialyy.aria.core.group;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.TaskRecord;
|
||||
import com.arialyy.aria.core.config.Configuration;
|
||||
import com.arialyy.aria.core.inf.IThreadStateManager;
|
||||
import com.arialyy.aria.core.loader.IRecordHandler;
|
||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||
import com.arialyy.aria.exception.AriaException;
|
||||
import com.arialyy.aria.exception.ExceptionFactory;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.NetUtils;
|
||||
@@ -72,7 +73,7 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
mGState.listener.onSubRunning(loaderUtil.getEntity(), range);
|
||||
break;
|
||||
case IThreadStateManager.STATE_PRE:
|
||||
mGState.listener.onSubPre(loaderUtil.getEntity( ));
|
||||
mGState.listener.onSubPre(loaderUtil.getEntity());
|
||||
mGState.updateCount(loaderUtil.getKey());
|
||||
break;
|
||||
case IThreadStateManager.STATE_START:
|
||||
@@ -104,8 +105,11 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
* @param needRetry true 需要重试,false 不需要重试
|
||||
*/
|
||||
private synchronized void handleFail(final AbsSubDLoadUtil loaderUtil, boolean needRetry) {
|
||||
Configuration config = Configuration.getInstance();
|
||||
Log.d(TAG, String.format("handleFail, size = %s, completeNum = %s, failNum = %s, stopNum = %s",
|
||||
mGState.getSubSize(), mGState.getCompleteNum(), mGState.getFailNum(),
|
||||
mGState.getSubSize()));
|
||||
|
||||
Configuration config = Configuration.getInstance();
|
||||
int num = config.dGroupCfg.getSubReTryNum();
|
||||
boolean isNotNetRetry = config.appCfg.isNotNetRetry();
|
||||
|
||||
@@ -114,25 +118,27 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
|| loaderUtil.getLoader() == null // 如果获取不到文件信息,loader为空
|
||||
|| loaderUtil.getEntity().getFailNum() > num) {
|
||||
mQueue.removeTaskFromExecQ(loaderUtil);
|
||||
mGState.listener.onSubFail(loaderUtil.getEntity(), new AriaException(TAG,
|
||||
String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(),
|
||||
loaderUtil.getEntity().getUrl())));
|
||||
mGState.listener.onSubFail(loaderUtil.getEntity(),
|
||||
ExceptionFactory.getException(ExceptionFactory.TYPE_GROUP,
|
||||
String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(),
|
||||
loaderUtil.getEntity().getUrl()), null));
|
||||
mGState.countFailNum(loaderUtil.getKey());
|
||||
if (mGState.getFailNum() == mGState.getSubSize()
|
||||
|| mGState.getStopNum() + mGState.getFailNum() + mGState.getCompleteNum()
|
||||
== mGState.getSubSize()) {
|
||||
mQueue.clear();
|
||||
mGState.isRunning.set(false);
|
||||
if (mGState.getCompleteNum() > 0&&Configuration.getInstance().dGroupCfg.isSubFailAsStop()) {
|
||||
if (mGState.getCompleteNum() > 0
|
||||
&& Configuration.getInstance().dGroupCfg.isSubFailAsStop()) {
|
||||
ALog.e(TAG, String.format("任务组【%s】停止", mGState.getGroupHash()));
|
||||
mGState.listener.onStop(mGState.getProgress());
|
||||
} else {
|
||||
mGState.listener.onFail(false, new AriaException(TAG,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
startNext();
|
||||
mGState.listener.onFail(false,
|
||||
ExceptionFactory.getException(ExceptionFactory.TYPE_GROUP,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash()), null));
|
||||
return;
|
||||
}
|
||||
startNext();
|
||||
return;
|
||||
}
|
||||
SimpleSubRetryQueue.getInstance().offer(loaderUtil);
|
||||
@@ -144,6 +150,10 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
* 2、completeNum + failNum + stopNum = subSize,则认为组合任务停止
|
||||
*/
|
||||
private synchronized void handleStop(AbsSubDLoadUtil loadUtil, long curLocation) {
|
||||
Log.d(TAG, String.format("handleStop, size = %s, completeNum = %s, failNum = %s, stopNum = %s",
|
||||
mGState.getSubSize(), mGState.getCompleteNum(), mGState.getFailNum(),
|
||||
mGState.getSubSize()));
|
||||
|
||||
mGState.listener.onSubStop(loadUtil.getEntity(), curLocation);
|
||||
mGState.countStopNum(loadUtil.getKey());
|
||||
if (mGState.getStopNum() == mGState.getSubSize()
|
||||
@@ -152,12 +162,11 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
+ mGState.getFailNum()
|
||||
+ mQueue.getCacheSize()
|
||||
== mGState.getSubSize()) {
|
||||
mQueue.clear();
|
||||
mGState.isRunning.set(false);
|
||||
mGState.listener.onStop(mGState.getProgress());
|
||||
} else {
|
||||
startNext();
|
||||
return;
|
||||
}
|
||||
startNext();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,6 +179,11 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
*/
|
||||
private synchronized void handleComplete(AbsSubDLoadUtil loader) {
|
||||
ALog.d(TAG, String.format("子任务【%s】完成", loader.getEntity().getFileName()));
|
||||
Log.d(TAG,
|
||||
String.format("handleComplete, size = %s, completeNum = %s, failNum = %s, stopNum = %s",
|
||||
mGState.getSubSize(), mGState.getCompleteNum(), mGState.getFailNum(),
|
||||
mGState.getSubSize()));
|
||||
|
||||
TaskRecord record = loader.getRecord();
|
||||
if (record != null && record.isBlock) {
|
||||
File partFile =
|
||||
@@ -180,23 +194,22 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
mGState.listener.onSubComplete(loader.getEntity());
|
||||
mQueue.removeTaskFromExecQ(loader);
|
||||
mGState.updateCompleteNum();
|
||||
ALog.d(TAG, String.format("总任务数:%s,完成的任务数:%s,失败的任务数:%s,停止的任务数:%s", mGState.getSubSize(),
|
||||
mGState.getCompleteNum(), mGState.getFailNum(), mGState.getStopNum()));
|
||||
if (mGState.getCompleteNum() + mGState.getFailNum() + mGState.getStopNum()
|
||||
== mGState.getSubSize()) {
|
||||
if (mGState.getStopNum() == 0 && mGState.getFailNum() == 0) {
|
||||
mGState.listener.onComplete();
|
||||
} else if(mGState.getStopNum() == 0&&!Configuration.getInstance().dGroupCfg.isSubFailAsStop() ){
|
||||
mGState.listener.onFail(false, new AriaException(TAG,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
|
||||
} else if (mGState.getStopNum() == 0
|
||||
&& !Configuration.getInstance().dGroupCfg.isSubFailAsStop()) {
|
||||
mGState.listener.onFail(false,
|
||||
ExceptionFactory.getException(ExceptionFactory.TYPE_GROUP,
|
||||
String.format("任务组【%s】下载失败", mGState.getGroupHash()), null));
|
||||
} else {
|
||||
mGState.listener.onStop(mGState.getProgress());
|
||||
}
|
||||
mQueue.clear();
|
||||
mGState.isRunning.set(false);
|
||||
} else {
|
||||
startNext();
|
||||
return;
|
||||
}
|
||||
startNext();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,8 +223,8 @@ final class SimpleSchedulers implements Handler.Callback {
|
||||
if (next != null) {
|
||||
ALog.d(TAG, String.format("启动任务:%s", next.getEntity().getFileName()));
|
||||
mQueue.startTask(next);
|
||||
} else {
|
||||
ALog.i(TAG, "没有下一子任务");
|
||||
return;
|
||||
}
|
||||
ALog.i(TAG, "没有下一子任务");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import com.arialyy.aria.util.CommonUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 组合任务队列,该队列生命周期和{@link AbsGroupLoaderUtil}生命周期一致
|
||||
@@ -34,11 +34,11 @@ final class SimpleSubQueue implements ISubQueue<AbsSubDLoadUtil> {
|
||||
/**
|
||||
* 缓存下载器
|
||||
*/
|
||||
private Map<String, AbsSubDLoadUtil> mCache = new LinkedHashMap<>();
|
||||
private Map<String, AbsSubDLoadUtil> mCache = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 执行中的下载器
|
||||
*/
|
||||
private Map<String, AbsSubDLoadUtil> mExec = new LinkedHashMap<>();
|
||||
private Map<String, AbsSubDLoadUtil> mExec = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 最大执行任务数
|
||||
@@ -85,12 +85,13 @@ final class SimpleSubQueue implements ISubQueue<AbsSubDLoadUtil> {
|
||||
if (mExec.size() < mExecSize) {
|
||||
mCache.remove(fileer.getKey());
|
||||
mExec.put(fileer.getKey(), fileer);
|
||||
ALog.d(TAG, String.format("开始执行子任务:%s", fileer.getEntity().getFileName()));
|
||||
ALog.d(TAG,
|
||||
String.format("开始执行子任务:%s,key: %s", fileer.getEntity().getFileName(), fileer.getKey()));
|
||||
fileer.run();
|
||||
} else {
|
||||
ALog.d(TAG, String.format("执行队列已满,任务进入缓存器中,key: %s", fileer.getKey()));
|
||||
addTask(fileer);
|
||||
return;
|
||||
}
|
||||
ALog.d(TAG, String.format("执行队列已满,任务进入缓存器中,key: %s", fileer.getKey()));
|
||||
addTask(fileer);
|
||||
}
|
||||
|
||||
@Override public void stopTask(AbsSubDLoadUtil fileer) {
|
||||
@@ -144,15 +145,16 @@ final class SimpleSubQueue implements ISubQueue<AbsSubDLoadUtil> {
|
||||
addTask(t);
|
||||
}
|
||||
}
|
||||
} else { // 处理队列变大的情况,该情况下将增加任务
|
||||
if (mExec.size() < num) {
|
||||
for (int i = 0; i < diff; i++) {
|
||||
AbsSubDLoadUtil next = getNextTask();
|
||||
if (next != null) {
|
||||
startTask(next);
|
||||
} else {
|
||||
ALog.d(TAG, "子任务中没有缓存任务");
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 处理队列变大的情况,该情况下将增加任务
|
||||
if (mExec.size() < num) {
|
||||
for (int i = 0; i < diff; i++) {
|
||||
AbsSubDLoadUtil next = getNextTask();
|
||||
if (next != null) {
|
||||
startTask(next);
|
||||
} else {
|
||||
ALog.d(TAG, "子任务中没有缓存任务");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.arialyy.aria.core.listener;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
||||
@@ -125,7 +124,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
|
||||
if (e != null) {
|
||||
String error = ALog.getExceptionString(e);
|
||||
ALog.e(TAG, error);
|
||||
ErrorHelp.saveError(e.getTag(), e.getMessage(), error);
|
||||
ErrorHelp.saveError(e.getMessage(), error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class DownloadGroupListener
|
||||
sendInState2Target(ISchedulers.SUB_FAIL, subEntity);
|
||||
if (e != null) {
|
||||
e.printStackTrace();
|
||||
ErrorHelp.saveError(e.getTag(), "", ALog.getExceptionString(e));
|
||||
ErrorHelp.saveError("", ALog.getExceptionString(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.ThreadRecord;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
@@ -259,16 +258,15 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
if (mTaskWrapper.getRequestType() == ITaskWrapper.M3U8_VOD) {
|
||||
writeConfig(false, getConfig().tempFile.length());
|
||||
ALog.i(TAG, String.format("任务【%s】已停止", getFileName()));
|
||||
} else {
|
||||
if (mTaskWrapper.isSupportBP()) {
|
||||
ALog.d(TAG,
|
||||
String.format("任务【%s】thread__%s__停止【当前线程停止位置:%s】", getFileName(),
|
||||
mRecord.threadId, stopLocation));
|
||||
writeConfig(false, stopLocation);
|
||||
} else {
|
||||
ALog.i(TAG, String.format("任务【%s】已停止", getFileName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mTaskWrapper.isSupportBP()) {
|
||||
ALog.d(TAG, String.format("任务【%s】thread__%s__停止【当前线程停止位置:%s】", getFileName(),
|
||||
mRecord.threadId, stopLocation));
|
||||
writeConfig(false, stopLocation);
|
||||
return;
|
||||
}
|
||||
ALog.i(TAG, String.format("任务【%s】已停止", getFileName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,7 +408,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
retryBlockTask(needRetry && mConfig.startThreadNum != 1);
|
||||
} else {
|
||||
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName()));
|
||||
ErrorHelp.saveError(TAG, "", ALog.getExceptionString(ex));
|
||||
ErrorHelp.saveError("", ALog.getExceptionString(ex));
|
||||
sendFailMsg(null, needRetry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,20 +17,12 @@ package com.arialyy.aria.exception;
|
||||
|
||||
public class AriaException extends Exception {
|
||||
|
||||
private String tag;
|
||||
|
||||
public AriaException(String tag, String message) {
|
||||
public AriaException(String message) {
|
||||
super(message);
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public AriaException(String tag, String message, Exception e) {
|
||||
super(String.format("%s, %s\n%s", tag, message == null ? "" : message,
|
||||
public AriaException(String message, Exception e) {
|
||||
super(String.format("%s\n%s", message == null ? "" : message,
|
||||
e == null ? "" : e.getMessage()));
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaFTPException extends AriaException {
|
||||
private static final String FTP_EXCEPTION = "Aria FTP Exception:";
|
||||
|
||||
public AriaFTPException(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||
public AriaFTPException(String message) {
|
||||
super(String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaFTPException(String tag, String message, Exception e) {
|
||||
super(tag, message, e);
|
||||
public AriaFTPException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.exception;
|
||||
|
||||
public class AriaGroupException extends AriaException {
|
||||
private static final String FTP_EXCEPTION = "Aria Group Exception:";
|
||||
|
||||
public AriaGroupException(String message) {
|
||||
super(String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaGroupException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaHTTPException extends AriaException {
|
||||
private static final String HTTP_EXCEPTION = "Aria HTTP Exception:";
|
||||
|
||||
public AriaHTTPException(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", HTTP_EXCEPTION, message));
|
||||
public AriaHTTPException( String message) {
|
||||
super(String.format("%s\n%s", HTTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaHTTPException(String tag, String message, Exception e) {
|
||||
super(tag, message, e);
|
||||
public AriaHTTPException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaM3U8Exception extends AriaException {
|
||||
private static final String M3U8_EXCEPTION = "Aria M3U8 Exception:";
|
||||
|
||||
public AriaM3U8Exception(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", M3U8_EXCEPTION, message));
|
||||
public AriaM3U8Exception(String message) {
|
||||
super(String.format("%s\n%s", M3U8_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaM3U8Exception(String tag, String message, Exception e){
|
||||
super(tag, message, e);
|
||||
public AriaM3U8Exception(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ package com.arialyy.aria.exception;
|
||||
public class AriaSFTPException extends AriaException {
|
||||
private static final String SFTP_EXCEPTION = "Aria SFTP Exception:";
|
||||
|
||||
public AriaSFTPException(String tag, String message) {
|
||||
super(tag, String.format("%s\n%s", SFTP_EXCEPTION, message));
|
||||
public AriaSFTPException(String message) {
|
||||
super(String.format("%s\n%s", SFTP_EXCEPTION, message));
|
||||
}
|
||||
|
||||
public AriaSFTPException(String tag, String message, Exception e) {
|
||||
super(tag, message, e);
|
||||
public AriaSFTPException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.aria.exception;
|
||||
|
||||
public class ExceptionFactory {
|
||||
public static final int TYPE_FTP = 1;
|
||||
public static final int TYPE_HTTP = 2;
|
||||
public static final int TYPE_M3U8 = 3;
|
||||
public static final int TYPE_SFTP = 4;
|
||||
public static final int TYPE_GROUP = 5;
|
||||
|
||||
public static AriaException getException(int type, String msg, Exception e) {
|
||||
switch (type) {
|
||||
case TYPE_FTP: {
|
||||
return e == null ? new AriaFTPException(msg) : new AriaFTPException(msg, e);
|
||||
}
|
||||
case TYPE_HTTP: {
|
||||
return e == null ? new AriaHTTPException(msg) : new AriaHTTPException(msg, e);
|
||||
}
|
||||
case TYPE_M3U8: {
|
||||
return e == null ? new AriaM3U8Exception(msg) : new AriaM3U8Exception(msg, e);
|
||||
}
|
||||
case TYPE_SFTP: {
|
||||
return e == null ? new AriaSFTPException(msg) : new AriaSFTPException(msg, e);
|
||||
}
|
||||
case TYPE_GROUP: {
|
||||
return e == null ? new AriaGroupException(msg) : new AriaGroupException(msg, e);
|
||||
}
|
||||
}
|
||||
return e == null ? new AriaException(msg) : new AriaException(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class AriaCrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
mExecutorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ErrorHelp.saveError(name, "", ALog.getExceptionString(ex));
|
||||
ErrorHelp.saveError("", ALog.getExceptionString(ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.annotation.SuppressLint;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -36,8 +35,8 @@ public class ErrorHelp {
|
||||
* @param msg 错误提示
|
||||
* @param ex 异常
|
||||
*/
|
||||
public static void saveError(String tag, String msg, String ex) {
|
||||
writeLogToFile(tag, String.format("\nmsg【%s】\nException:%s", msg, ex));
|
||||
public static void saveError(String msg, String ex) {
|
||||
writeLogToFile(String.format("\nmsg【%s】\nException:%s", msg, ex));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,12 +56,10 @@ public class ErrorHelp {
|
||||
/**
|
||||
* 把日志记录到文件
|
||||
*/
|
||||
private static int writeLogToFile(String tag, String message) {
|
||||
private static int writeLogToFile(String message) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(getData("yyyy-MM-dd HH:mm:ss"));
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(tag);
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(message);
|
||||
stringBuffer.append("\n\n");
|
||||
PrintWriter writer = null;
|
||||
|
||||
Reference in New Issue
Block a user