| | |
| | | */ |
| | | public class HdlLogLogic { |
| | | |
| | | //是否启动打印到Logcat上的标签(false不需要打印) |
| | | //是否启动打印到Logcat上的标签(true:表示打印,false:表示不打印) |
| | | public static boolean isStartPrintLogcat = true; |
| | | |
| | | //是否启动加到内存里面的标签 |
| | | public static boolean isStartAddToMemory = false; |
| | | //是否启动加到内存里面的标签(true:表示加入,false:表示不加入) |
| | | public static boolean isStartAddToMemory = true; |
| | | |
| | | //默认打印标题 |
| | | private static String logTitle = "自定义输出打印信息"; |
| | | private static String logTitle = "";//自定义输出打印信息 |
| | | |
| | | private static Gson gson = new Gson(); |
| | | private static final Gson gson = new Gson(); |
| | | |
| | | private static CustomLogObject customLogObject = new CustomLogObject(); |
| | | private static final CustomLogObject customLogObject = new CustomLogObject(); |
| | | |
| | | /** |
| | | * java打印 |
| | |
| | | customLogObject.setCode(code); |
| | | String json = logTitle + (UserConfigManage.getInstance().isBAccount() ? "(B端)==" : "(C端)==") + gson.toJson(customLogObject); |
| | | if (isStartPrintLogcat) { |
| | | System.out.println(json); |
| | | System.out.println(json.replace("\\", "")); |
| | | } |
| | | if (isStartAddToMemory) { |
| | | if (isAddToMemory) { |
| | |
| | | */ |
| | | public static void writeLog(String strLog) { |
| | | synchronized (HdlLogLogic.class) { |
| | | strLog = TimeUtils.getTimeFromTimestamp(System.currentTimeMillis()) + "s%" + " " + strLog;//加打印时间(s%占位符,设置显示时间不同字体颜色) |
| | | HdlFileLogic.getInstance().appendFile(HdlFileLogic.getInstance().getLogFileNamePath(), strLog); |
| | | strLog = TimeUtils.getTimeFromTimestamp(System.currentTimeMillis(), true) + "s%" + " " + strLog;//加打印时间(s%占位符,设置显示时间不同字体颜色) |
| | | |
| | | HdlFileLogic.getInstance().appendFile(HdlFileLogic.getInstance().getLogFileNamePath(), strLog.replace("\\", "")); |
| | | } |
| | | } |
| | | |