From 32b5f366ceaad4aa9a33eccf0b109eef24175495 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期二, 10 十月 2023 14:55:01 +0800 Subject: [PATCH] 2023年10月10日14:54:56 --- app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java | 83 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 83 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java index 8c9892c..986d82f 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlLogLogic.java @@ -2,13 +2,26 @@ import android.util.Log; +import com.google.gson.Gson; + /** * 鏃ュ織閫昏緫 */ public class HdlLogLogic { + + /** + * 鏄惁闇�瑕佹墦鍗�(true涓嶉渶瑕佹墦鍗�) + */ + public static boolean isDebug = false; + private static volatile HdlLogLogic sHdlLogLogic; + /** + * 鑾峰彇褰撳墠瀵硅薄 + * + * @return HdlLogLogic + */ public static synchronized HdlLogLogic getInstance() { if (sHdlLogLogic == null) { synchronized (HdlLogLogic.class) { @@ -20,11 +33,81 @@ return sHdlLogLogic; } + /** + * android鎵撳嵃 + * + * @param tag 鏍囩 + * @param mgs 閿欒淇℃伅 + */ public static void print(String tag, String mgs) { + if (isDebug) { + return; + } Log.d(tag, mgs); } + /** + * java鎵撳嵃 + * + * @param mgs 杈撳嚭淇℃伅 + */ + public static void print(String mgs) { + if (isDebug) { + return; + } + System.out.println(mgs); + } + /** + * java鎵撳嵃 + * + * @param tag 鏍囬 + * @param mgs 閿欒淇℃伅 + * @param code 閿欒鐮� + */ + public static void print(String tag, String mgs, int code) { + if (isDebug) { + return; + } + System.out.println(title + tag + "======" + mgs + "(" + code + ")"); + } + /** + * java鎵撳嵃 + * + * @param tag 鏍囬 + * @param mgs 閿欒淇℃伅 + * @param code 閿欒鐮� + */ + public static void print(String tag, String mgs, String code) { + if (isDebug) { + return; + } + System.out.println(title + tag + "======" + mgs + "(" + code + ")"); + } + + /** + * java鎵撳嵃 + * + * @param tag 鏍囬 + * @param o 閿欒淇℃伅 + */ + public static void print(String tag, Object o) { + + if (isDebug) { + return; + } + if (o == null) { + System.out.println(title + tag); + } else { + try { + System.out.println(title + tag + "======" + new Gson().toJson(o)); + } catch (Exception e) { + System.out.println(title + tag + "======" + e.getMessage()); + } + } + } + + private static final String title = "鑷畾涔夎緭鍑烘墦鍗颁俊鎭�:"; } -- Gitblit v1.8.0