From f8d23dcf8d6501482db1a5180325194232afe96c Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期五, 18 七月 2025 17:30:09 +0800
Subject: [PATCH] 封装部分业务代码,继续优化日志打印流程

---
 util/LogHelper.cs |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/util/LogHelper.cs b/util/LogHelper.cs
index 7621d26..b13aff4 100644
--- a/util/LogHelper.cs
+++ b/util/LogHelper.cs
@@ -1,6 +1,7 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Xml.Linq;
 
 using Newtonsoft.Json;
 
@@ -71,16 +72,20 @@
         }
 
         #region 鑷畾涔夋柟娉�-        public static void InfoEx(Exception ex) {
-            Info($"鍙戠敓浜嗗紓甯革細{ex.Message}\n{ex.StackTrace}");
+        public static void Warn(string msg, string preLog = "") {
+            Info(preLog + $"鍑虹幇浜哰璀﹀憡]:{msg}", "Warn");
+        }
+
+        public static void InfoEx(Exception ex, string preLog = "") {
+            Info(preLog + $"鍙戠敓浜哰寮傚父]:{ex.Message}\n\n{ex.StackTrace}\n", "Exception");
         }
 
         public static void InfoApi(string apiName, object model) {
-            Info($"瑙﹀彂API锛歿apiName} " + JsonConvert.SerializeObject(model), "API");
+            Info($"瑙﹀彂API:{apiName} " + JsonConvert.SerializeObject(model), "API");
         }
 
         public static void InfoHostToAGV(string taskName, object model) {
-            Info($"AGV浠诲姟锛歿taskName}" + JsonConvert.SerializeObject(model), "HosttoagvTask");
+            Info($"AGV浠诲姟:{taskName}" + JsonConvert.SerializeObject(model), "HosttoagvTask");
         }
         #endregion
     }
@@ -91,7 +96,7 @@
         /// 閫氳繃閰嶇疆鏂囦欢閰嶇疆鏃ュ織
         /// </summary>
         static LogFactory() {
-            var loggerNames = new List<string>() { "HosttoagvTask", "HosttoagvCar", "NDC", "鏉ゥ", "PLC", "API", "OPC" };
+            var loggerNames = new List<string>() { "HosttoagvTask", "HosttoagvCar", "NDC", "鏉ゥ", "PLC", "API", "OPC", "Warn", "Exception" };
             LogManager.Configuration = DefaultConfig(loggerNames);
         }
 

--
Gitblit v1.9.1