NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.Log.EventLog Class Reference
Inheritance diagram for Ntp.Common.Log.EventLog:
Collaboration diagram for Ntp.Common.Log.EventLog:

Public Member Functions

 EventLog (string name, Severity threshold)
 
override void Close ()
 
override void Initialize ()
 
override void Resume ()
 
override void Suspend ()
 
override void WriteLine (string text, Severity severity)
 
override void WriteLine (Exception exception, Severity severity)
 
override void WriteLine (Exception exception)
 

Private Member Functions

void CreateEventLog ()
 
void WriteEventLogEntry (string text, EventLogEntryType type, int code)
 

Static Private Member Functions

static EventLogEntryType GetEventLogEntryType (Severity severity)
 

Private Attributes

const string Log = "Application"
 
readonly string name
 

Static Private Attributes

static bool initialized
 

Additional Inherited Members

- Protected Member Functions inherited from Ntp.Common.Log.LogBase
 LogBase (Severity threshold, bool isSysLog=false)
 
- Properties inherited from Ntp.Common.Log.LogBase
bool IsSysLog [get]
 
Severity Threshold [get]
 

Detailed Description

Definition at line 28 of file EventLog.cs.

Constructor & Destructor Documentation

Ntp.Common.Log.EventLog.EventLog ( string  name,
Severity  threshold 
)
inline

Definition at line 30 of file EventLog.cs.

31  : base(threshold, true)
32  {
33  this.name = name;
34  }
readonly string name
Definition: EventLog.cs:38

Member Function Documentation

override void Ntp.Common.Log.EventLog.Close ( )
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 40 of file EventLog.cs.

41  {
42  }
void Ntp.Common.Log.EventLog.CreateEventLog ( )
inlineprivate

Definition at line 98 of file EventLog.cs.

99  {
100  try
101  {
102  if (!global::System.Diagnostics.EventLog.SourceExists(name))
103  {
104  global::System.Diagnostics.EventLog.CreateEventSource(name, Log);
105  }
106  }
107  catch (SecurityException)
108  {
109  }
110  }
const string Log
Definition: EventLog.cs:36
readonly string name
Definition: EventLog.cs:38
static EventLogEntryType Ntp.Common.Log.EventLog.GetEventLogEntryType ( Severity  severity)
inlinestaticprivate

Definition at line 112 of file EventLog.cs.

113  {
114  switch (severity)
115  {
116  case Severity.Trace:
117  case Severity.Debug:
118  case Severity.Info:
119  case Severity.Notice:
120  return EventLogEntryType.Information;
121  case Severity.Warn:
122  return EventLogEntryType.Warning;
123  case Severity.Error:
124  return EventLogEntryType.Error;
125  default:
126  return EventLogEntryType.Error;
127  }
128  }
override void Ntp.Common.Log.EventLog.Initialize ( )
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 44 of file EventLog.cs.

45  {
46  if (initialized)
47  return;
48 
50  initialized = true;
51  }
static bool initialized
Definition: EventLog.cs:37
override void Ntp.Common.Log.EventLog.Resume ( )
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 53 of file EventLog.cs.

54  {
55  // EventLog does not support resume
56  }
override void Ntp.Common.Log.EventLog.Suspend ( )
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 58 of file EventLog.cs.

59  {
60  // EventLog does not support suspend
61  }
void Ntp.Common.Log.EventLog.WriteEventLogEntry ( string  text,
EventLogEntryType  type,
int  code 
)
inlineprivate

Definition at line 130 of file EventLog.cs.

131  {
132  try
133  {
134  global::System.Diagnostics.EventLog.WriteEntry(name, text, type, code);
135  }
136  catch (SecurityException)
137  {
138  }
139  }
readonly string name
Definition: EventLog.cs:38
override void Ntp.Common.Log.EventLog.WriteLine ( string  text,
Severity  severity 
)
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 63 of file EventLog.cs.

64  {
65  if (!initialized)
66  Initialize();
67 
68  if (severity < Threshold)
69  return;
70 
71  WriteEventLogEntry(text, GetEventLogEntryType(severity), 0);
72  }
static EventLogEntryType GetEventLogEntryType(Severity severity)
Definition: EventLog.cs:112
void WriteEventLogEntry(string text, EventLogEntryType type, int code)
Definition: EventLog.cs:130
Severity Threshold
Definition: LogBase.cs:34
static bool initialized
Definition: EventLog.cs:37
override void Initialize()
Definition: EventLog.cs:44
override void Ntp.Common.Log.EventLog.WriteLine ( Exception  exception,
Severity  severity 
)
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 74 of file EventLog.cs.

75  {
76  if (!initialized)
77  Initialize();
78 
79  if (severity < Threshold)
80  return;
81 
82  if (!initialized)
83  Initialize();
84 
85  if (severity < Threshold)
86  return;
87 
88  WriteEventLogEntry(exception.ToString(), GetEventLogEntryType(severity), 0);
89  }
static EventLogEntryType GetEventLogEntryType(Severity severity)
Definition: EventLog.cs:112
void WriteEventLogEntry(string text, EventLogEntryType type, int code)
Definition: EventLog.cs:130
Severity Threshold
Definition: LogBase.cs:34
static bool initialized
Definition: EventLog.cs:37
override void Initialize()
Definition: EventLog.cs:44
override void Ntp.Common.Log.EventLog.WriteLine ( Exception  exception)
inlinevirtual

Implements Ntp.Common.Log.LogBase.

Definition at line 91 of file EventLog.cs.

92  {
93  WriteEventLogEntry(exception.ToString(), EventLogEntryType.Error, 1);
94  }
void WriteEventLogEntry(string text, EventLogEntryType type, int code)
Definition: EventLog.cs:130

Member Data Documentation

bool Ntp.Common.Log.EventLog.initialized
staticprivate

Definition at line 37 of file EventLog.cs.

const string Ntp.Common.Log.EventLog.Log = "Application"
private

Definition at line 36 of file EventLog.cs.

readonly string Ntp.Common.Log.EventLog.name
private

Definition at line 38 of file EventLog.cs.


The documentation for this class was generated from the following file: