using DH.RBAC.Model.Sys; using DH.RBAC.Logic.Base; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using DH.RBAC.Utility.Other; namespace DH.RBAC.Logic { /// /// 日志 /// public class Logger { private static object _lock = new object(); private static void Log(string type, string message) { lock (_lock) { SimpleClient client = new SimpleClient(BaseLogic.GetInstance()); SysLog log = new SysLog(); log.Id = UUID.SnowId; log.Type = type; #if !NETFRAMEWORK log.ThreadId = Thread.GetCurrentProcessorId(); #else log.ThreadId = Thread.CurrentThread.ManagedThreadId; #endif log.Message = message; log.EnableFlag = "Y"; log.DeleteFlag = "N"; log.CreateTime = DateTime.Now; log.CreateUserId = "1"; log.ModifyUserId = "1"; log.ModifyTime = log.CreateTime; client.Insert(log); } } /// /// 操作日志写入 /// /// public static void OperateInfo(string message) { Log("Operate", message); } /// /// 运行日志写入 /// /// public static void RunningInfo(string message) { Log("Running", message); } /// /// 错误日志写入 /// /// public static void ErrorInfo(string message) { Log("Error", message); } } }