You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics.Tracing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace LogStudy.EventLog.Next
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 日志接口
|
|
|
|
|
/// EventSource 类型可能实现接口,以便无缝集成到使用接口定义常用日志记录目标的各种高级日志记录系统中。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface ILogger
|
|
|
|
|
{
|
|
|
|
|
void Error(int errorCode, string msg);
|
|
|
|
|
void Warning(string msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[EventSource(Name = "EventLogNext-InterfaceEventSource")]
|
|
|
|
|
public class InterfaceEventSource : EventSource, ILogger
|
|
|
|
|
{
|
|
|
|
|
public InterfaceEventSource() { }
|
|
|
|
|
|
|
|
|
|
public static InterfaceEventSource Logger { get; set; } = new InterfaceEventSource();
|
|
|
|
|
|
|
|
|
|
[Event(1)]
|
|
|
|
|
public void Error(int errorCode, string msg)
|
|
|
|
|
{
|
|
|
|
|
WriteEvent(1, errorCode, msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Event(2)]
|
|
|
|
|
public void Warning(string msg)
|
|
|
|
|
{
|
|
|
|
|
WriteEvent(2, msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|