Logger.cs 1.65 KB
using HHECS.Model;
using HHECS.Model.Entities;
using HHECS.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HHECS.Bll
{
    public class Logger
    {
        #region 事件

        //public static event Delegates.LogWriteEventHandle LogWrite;

        ///// <summary>
        ///// 日志事件触发
        ///// </summary>
        ///// <param name="content"></param>
        ///// <param name="logLevel"></param>
        ///// <param name="exception"></param>
        //public static void Log(string content, LogLevel logLevel, Exception exception = null)
        //{
        //    LogWrite?.Invoke(null, LogEventArgs.GetLogEventArgs(content, logLevel, exception));
        //}

        /// <summary>
        /// 记录接口日志
        /// </summary>
        /// <param name="interfaceName"></param>
        /// <param name="content"></param>
        public static void LogInterface(string interfaceName, string content, InterfaceOperationResult interfaceOperationResult)
        {
            try
            {
                LogInterface log = new LogInterface() {
                    InterfaceName = interfaceName,
                    Content = content,
                    OperationStatus = interfaceOperationResult.ToString(),
                    Created = DateTime.Now,
                    CreatedBy = "interface"
                };
                AppSession.Bll.SaveCommonModel<LogInterface>(log);
            }
            catch (Exception ex)
            {
#if DEBUG

                Console.WriteLine(ex.ToString());

#endif
            }
        }

        #endregion
    }
}