From fc25dda9baf3b5f4df23d35914f3dd343cf492e3 Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期一, 28 七月 2025 17:30:21 +0800 Subject: [PATCH] 优化WCSHelper / 序列号生成逻辑 , 添加强制任务处理模块 --- util/LogHelper.cs | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/util/LogHelper.cs b/util/LogHelper.cs index 7221e4e..615f2c1 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; @@ -8,11 +9,11 @@ using NLog.Config; using NLog.Targets; -namespace HH.WCS.Mobox3.DSZSH { - public class LogHelper - { +namespace HH.WCS.Mobox3.DSZSH.util { + public class LogHelper { public static Dictionary<string, ILogger> loggers = new Dictionary<string, ILogger>(); + #region 鍒濆鏂规硶 ( Error 榛樿涓嶄娇鐢�) public static void Debug(string message, string name = "") { ILogger logger = null; if (loggers.Keys.Contains(name)) { @@ -68,27 +69,34 @@ if (logger != null) { logger.Error($"{message}{ex.StackTrace}"); } - } - - #region 鑷畾涔夋柟娉�- public static void InfoEx(Exception ex) { - Info($"寮傚父锛歿ex.Message}"); - } - - public static void InfoApi(string taskType, object model) { - Info($"瑙﹀彂API锛歿taskType} " + JsonConvert.SerializeObject(model), "API"); } #endregion + #region 鑷畾涔夋柟娉�+ 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"); + } + + public static void InfoHostToAGV(string taskName, object model) { + Info($"AGV浠诲姟:{taskName}" + JsonConvert.SerializeObject(model), "HosttoagvTask"); + } + #endregion } - internal class LogFactory - { + internal class LogFactory { /// <summary> /// 閫氳繃閰嶇疆鏂囦欢閰嶇疆鏃ュ織 /// </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