-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCEventLog.cs
48 lines (35 loc) · 1.15 KB
/
CEventLog.cs
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace MarsDoorMonitoring
{
class CEventLog
{
public CEventLog(string sSource)
{
_sSource = sSource;
_sLog = "Door_Monitoring";
}
public void LogInfoEvent(string sMessage)
{
if (!EventLog.SourceExists(_sSource))
EventLog.CreateEventSource(_sSource, _sLog);
EventLog.WriteEntry(_sSource, sMessage, EventLogEntryType.Information, 1);
}
public void LogErrorEvent(string sMessage)
{
if (!EventLog.SourceExists(_sSource))
EventLog.CreateEventSource(_sSource, _sLog);
EventLog.WriteEntry(_sSource, sMessage, EventLogEntryType.Error, 5);
}
public void LogWarningEvent(string sMessage)
{
if (!EventLog.SourceExists(_sSource))
EventLog.CreateEventSource(_sSource, _sLog);
EventLog.WriteEntry(_sSource, sMessage, EventLogEntryType.Warning, 1);
}
private string _sSource;
private string _sLog;
}
}