public static final String logFileName = "market.txt";//日志名称 public static final String logFilePathFolder = Environment.getExternalStorageDirectory() + File.separator + "tdr_market_log" + File.separator;//日志上传
public class LogFileUtil { private static final String TAG = "LogFileUtil"; private static int count = 0; private static boolean isRequesting; private static int KEY_FILE_SIZE = 3; public static int e(String tag, String msg) { // Log.e("--------size=", getFileSize() + ""); // if (getFileSize() > getUploadFileSize() * 1024 * 1024 && !isRequesting) { if (getFileSize() > 1 * 5 * 1024 && !isRequesting) { createThreadZipFile(); // pushCreateThreadZipFile(); // } else { // } try { if (ObjectUtil.isNull(msg)) { msg = ""; } fileLog(tag, msg); } catch (Exception e) { } return Log.e(tag, msg); } public static int i(String tag, String msg) { // if (getFileSize() > getUploadFileSize() * 1024 * 1024 && !isRequesting) { // createThreadZipFile(); // } else { // fileLog(tag, msg); // } try { if (ObjectUtil.isNull(msg)) { msg = ""; } fileLog(tag, msg); } catch (Exception e) { } return Log.i(tag, msg); } public static void fileLog(String tag, String msg) { try { if ("mounted".equals(Environment.getExternalStorageState())) { File dir = new File(Constant.logFilePathFolder); if (!dir.exists()) { dir.mkdirs(); } File logFile = new File(Constant.logFilePathFolder, Constant.logFileName); if (!logFile.exists()) { logFile.createNewFile(); } BufferedWriter bw = null; if (ObjectUtil.isNull(bw)) { bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(logFile, true), Charset.forName(""UTF-8"))); } bw.append((new Timestamp(System.currentTimeMillis())).toString()).append(" ").append(tag).append(":").append(msg).append("\n"); // bw.flush(); bw.close(); } } catch (Exception var4) { } }
}