From 0a8917b5a842f0343e5a1d322209fee95fa1b23d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 28 八月 2019 15:30:17 +0800
Subject: [PATCH] 增加返利得金币任务
---
fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java b/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
index 3399e40..78492e1 100644
--- a/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
+++ b/fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
@@ -40,6 +41,8 @@
private static Logger smsLogger = Logger.getLogger("smsLog");
private static Logger requestLogger = Logger.getLogger("requestLog");
+
+ private static Logger requestTimeLogger = Logger.getLogger("requestTimeLog");
public static void userInfo(Object obj) {
userLogger.info(obj);
@@ -90,7 +93,7 @@
loginLogger.info(obj);
}
- public static void errorDetailInfo(Throwable e) throws Exception {
+ public static void errorDetailInfo(Throwable e) {
e.printStackTrace();
String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd");
String os = System.getProperty("os.name");
@@ -100,20 +103,28 @@
} else
filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date);
- OutputStream out = new FileOutputStream(new File(filePath), true);
+ OutputStream out = null;
+
try {
+ out = new FileOutputStream(new File(filePath), true);
PrintStream ps = new PrintStream(out);
ps.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
ps.print("\n");
e.printStackTrace(ps);
ps.flush();
ps.close();
+ } catch (Exception ee) {
+
} finally {
- out.close();
+ try {
+ out.close();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
}
}
- public static void errorDetailInfo(Throwable e, String params, String url) throws Exception {
+ public static void errorDetailInfo(Throwable e, String params, String url) {
e.printStackTrace();
String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd");
String os = System.getProperty("os.name");
@@ -122,9 +133,9 @@
filePath = String.format("C:/logs/error_detail_%s.txt", date);
} else
filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.txt", date);
-
- OutputStream out = new FileOutputStream(new File(filePath), true);
+ OutputStream out = null;
try {
+ out = new FileOutputStream(new File(filePath), true);
PrintStream ps = new PrintStream(out);
ps.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
ps.print("\n");
@@ -135,8 +146,14 @@
e.printStackTrace(ps);
ps.flush();
ps.close();
+ } catch (Exception e1) {
+
} finally {
- out.close();
+ try {
+ out.close();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
}
}
@@ -175,4 +192,26 @@
if (info != null)
smsLogger.info(info);
}
+
+ public static void requestTime(String url, Map<String, Object> params, long time) {
+ String paramsStr = "";
+ try {
+ Iterator<String> its = params.keySet().iterator();
+ List<String> list = new ArrayList<>();
+ while (its.hasNext()) {
+ String key = its.next();
+ Object value = params.get(key);
+ Object[] values = (Object[]) value;
+ list.add(key + "=" + values[0].toString());
+ }
+ for (String param : list)
+ paramsStr += param + "&";
+ if (paramsStr.endsWith("&"))
+ paramsStr = paramsStr.substring(0, paramsStr.length() - 1);
+ } catch (Exception e) {
+
+ }
+ String content = String.format("閾炬帴:%s 鍙傛暟:%s 鍝嶅簲鏃堕棿:%s", url, paramsStr, time + "");
+ requestTimeLogger.info(content);
+ }
}
--
Gitblit v1.8.0