From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/log/PushLogHelper.java | 226 ++++++++++++++++++++++++++++++++------------------------ 1 files changed, 128 insertions(+), 98 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/log/PushLogHelper.java b/fanli/src/main/java/com/yeshi/fanli/log/PushLogHelper.java index 91c7da7..c1af69e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/log/PushLogHelper.java +++ b/fanli/src/main/java/com/yeshi/fanli/log/PushLogHelper.java @@ -1,98 +1,128 @@ -package com.yeshi.fanli.log; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; - -import org.apache.log4j.Logger; - -import com.yeshi.fanli.util.TimeUtil; - -/** - * 鎺ㄩ�佹棩蹇� - * - * @author Administrator - * - */ -public class PushLogHelper { - // log - private static Logger xmLogger = Logger.getLogger("pushXMLog"); - - private static Logger iosLogger = Logger.getLogger("pushIOSLog"); - - private static Logger hwLogger = Logger.getLogger("pushHWLog"); - - public static void xmInfo(Object obj) { - xmLogger.info(obj); - } - - public static void iosInfo(Object obj) { - iosLogger.info(obj); - } - - public static void hwInfo(Object obj) { - hwLogger.info(obj); - } - - public static void xmError(Throwable e) { - String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); - String os = System.getProperty("os.name"); - String filePath = String.format("/usr/local/tomcat8/logs/push/xm_error_detail_%s.txt", date); - if (os.toLowerCase().startsWith("win")) { - filePath = String.format("C:/logs/push/xm_error_detail_%s.txt", date); - } - - try { - saveErrorLog(e, filePath); - } catch (IOException e1) { - } - } - - public static void iosError(Throwable e) { - String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); - String os = System.getProperty("os.name"); - String filePath = String.format("/usr/local/tomcat8/logs/push/ios_error_detail_%s.txt", date); - if (os.toLowerCase().startsWith("win")) { - filePath = String.format("C:/logs/push/ios_error_detail_%s.txt", date); - } - - try { - saveErrorLog(e, filePath); - } catch (IOException e1) { - } - } - - public static void hwError(Throwable e) { - String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); - String os = System.getProperty("os.name"); - String filePath = String.format("/usr/local/tomcat8/logs/push/hw_error_detail_%s.txt", date); - if (os.toLowerCase().startsWith("win")) { - filePath = String.format("C:/logs/push/hw_error_detail_%s.txt", date); - } - - try { - saveErrorLog(e, filePath); - } catch (IOException e1) { - } - } - - public static void saveErrorLog(Throwable e, String filePath) throws IOException { - // 鍒涘缓鏂囦欢澶� - if (!new File(new File(filePath).getParent()).exists()) - new File(new File(filePath).getParent()).mkdirs(); - OutputStream out = new FileOutputStream(new File(filePath), true); - try { - 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(); - } finally { - out.close(); - } - } - -} +package com.yeshi.fanli.log; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; + +import org.apache.log4j.Logger; + +import org.yeshi.utils.TimeUtil; + +/** + * 鎺ㄩ�佹棩蹇� + * + * @author Administrator + * + */ +public class PushLogHelper { + // log + private static Logger xmLogger = Logger.getLogger("pushXMLog"); + + private static Logger iosLogger = Logger.getLogger("pushIOSLog"); + + private static Logger hwLogger = Logger.getLogger("pushHWLog"); + + public static void xmInfo(Object obj) { + xmLogger.info(obj); + } + + public static void iosInfo(Object obj) { + iosLogger.info(obj); + } + + public static void hwInfo(Object obj) { + hwLogger.info(obj); + } + + public static void xmError(Throwable e) { + String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); + String os = System.getProperty("os.name"); + String filePath = String.format("/usr/local/tomcat8/logs/push/xm_error_detail_%s.txt", date); + if (os.toLowerCase().startsWith("win")) { + filePath = String.format("C:/logs/push/xm_error_detail_%s.txt", date); + } + + try { + saveErrorLog(e, filePath); + } catch (IOException e1) { + } + } + + public static void iosError(Throwable e) { + String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); + String os = System.getProperty("os.name"); + String filePath = String.format("/usr/local/tomcat8/logs/push/ios_error_detail_%s.txt", date); + if (os.toLowerCase().startsWith("win")) { + filePath = String.format("C:/logs/push/ios_error_detail_%s.txt", date); + } + + try { + saveErrorLog(e, filePath); + } catch (IOException e1) { + } + } + + public static void hwError(Throwable e) { + String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); + String os = System.getProperty("os.name"); + String filePath = String.format("/usr/local/tomcat8/logs/push/hw_error_detail_%s.txt", date); + if (os.toLowerCase().startsWith("win")) { + filePath = String.format("C:/logs/push/hw_error_detail_%s.txt", date); + } + + try { + saveErrorLog(e, filePath); + } catch (IOException e1) { + } + } + + + public static void oppoError(Throwable e) { + String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); + String os = System.getProperty("os.name"); + String filePath = String.format("/usr/local/tomcat8/logs/push/oppo_error_detail_%s.txt", date); + if (os.toLowerCase().startsWith("win")) { + filePath = String.format("C:/logs/push/oppo_error_detail_%s.txt", date); + } + + try { + saveErrorLog(e, filePath); + } catch (IOException e1) { + } + } + + + public static void vivoError(Throwable e) { + String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); + String os = System.getProperty("os.name"); + String filePath = String.format("/usr/local/tomcat8/logs/push/vivo_error_detail_%s.txt", date); + if (os.toLowerCase().startsWith("win")) { + filePath = String.format("C:/logs/push/vivo_error_detail_%s.txt", date); + } + + try { + saveErrorLog(e, filePath); + } catch (IOException e1) { + } + } + + public static void saveErrorLog(Throwable e, String filePath) throws IOException { + // 鍒涘缓鏂囦欢澶� + if (!new File(new File(filePath).getParent()).exists()) + new File(new File(filePath).getParent()).mkdirs(); + OutputStream out = new FileOutputStream(new File(filePath), true); + try { + 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(); + } finally { + out.close(); + } + } + +} -- Gitblit v1.8.0