Logger.cs
1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
}
}