//package com.example.xiaoshiweixinback.business.utils; // //import org.slf4j.Logger; //import org.slf4j.LoggerFactory; //import org.slf4j.MDC; // //import java.io.PrintWriter; //import java.io.StringWriter; // // ///** // * 日志工具类 // * // * @author Peach // */ // //public class LogHelper { // // private static Logger logger = null; // // //------------------------------------------系统日志记录------------------------- // // /** // * @param info // */ // // public static void log(Object... info) { // logger = LoggerFactory.getLogger(""); // logger.info("info={}", info); // } // // public static void log(Throwable e, Object... info) { // logger = LoggerFactory.getLogger(""); // logger.info("exception={} info={}", throwable2String(e), info); // } // // // /** // * @param clazz // * @param info // */ // // public static void log(Class clazz, String info) { // logger = LoggerFactory.getLogger(clazz); // logger.info(info); // } // // // /** // * @param clazz // * @param e // */ // // public static void log(Class clazz, Throwable e) { // log(clazz, throwable2String(e)); // } // // /** // * @param name // * @param info // */ // // @Deprecated // public static void log(String name, String info) { // logger = LoggerFactory.getLogger(name); // logger.info(name + "-" + info); // } // // // /** // * @param name // * @param e // */ // // @Deprecated // public static void log(String name, Throwable e) { // log(name, throwable2String(e)); // } // // // /** // * @param name // * @param info // * @param e // */ // @Deprecated // public static void log(String name, String info, Throwable e) { // log(name, info + "-" + throwable2String(e)); // } // // // /** // * @param clazz // * @param info // * @param e // */ // public static void log(Class clazz, String info, Throwable e) { // log(clazz, info + "-" + throwable2String(e)); // } // // // /** // * 将异常信息转为string // * // * @param e // * @return // */ // // private static String throwable2String(Throwable e) { // if (checkBaseBusinessException(e)) { // BaseBusinessException bbe = (BaseBusinessException) e; // return "----->" + bbe.getErrorMessage() + (bbe.getExtraMessage() == null ? "" : bbe.getExtraMessage()); // } // PrintWriter pw = null; // StringWriter sw = null; // try { // sw = new StringWriter(); // pw = new PrintWriter(sw); // e.printStackTrace(pw); // pw.flush(); // sw.flush(); // } catch (Exception e1) { // logger.info(e.getMessage()); // } finally { // if (sw != null) { // try { // sw.close(); // } catch (Exception e2) { // e2.printStackTrace(); // return ""; // } // } else { // return ""; // } // if (pw != null) { // pw.close(); // } // return sw.toString(); // } // // } // // // /** // * @param @param e // * @param @return 参数 // * @return boolean 返回类型 // * @throws // * @Title: checkBaseBusinessException // * @Description: 判断异常是否为系统异常 // * @author Orange // * @date 2019年1月23日 // */ // // private static boolean checkBaseBusinessException(Throwable e) { // return BaseBusinessException.class.isInstance(e); // } // // // //------------------------------------------多业务日志记录------------------------- // /** // * @param @param e // * @param @param info 参数 // * @return void 返回类型 // * @throws // * @Title: warnLog // * @Description: 警告日志 // * @author Orange // * @date 2019年1月26日 // */ // public static void warnLog(Throwable e, Object... info) { // //系统级别日志不打印 // if (checkBaseBusinessException(e)) { // log(e, info); // } else { // Logger logger = LoggerFactory.getLogger("error_log"); // logger.warn("[System Exception] exception={} ,info={}", throwable2String(e), info); // } // } //}