Created
October 2, 2020 10:14
-
-
Save 2garryn/5052a364c965e36c5ea7c268c9376a36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger | |
{ | |
private static volatile Logger instance; | |
private EventLog _evLog; | |
private static object lockObject = new object(); | |
public Logger(string logApp, string source) | |
{ | |
if (!EventLog.SourceExists(source)) | |
EventLog.CreateEventSource(source, logApp); | |
_evLog = new EventLog(logApp) | |
{ | |
Source = source | |
}; | |
} | |
public void Info(string format, params object[] args) | |
=> Write(EventLogEntryType.Information, format, args); | |
public void Warning(string format, params object[] args) | |
=> Write(EventLogEntryType.Warning, format, args); | |
public void Error(string format, params object[] args) | |
=> Write(EventLogEntryType.Error, format, args); | |
private void Write(EventLogEntryType t, string format, params object[] args) | |
=> _evLog.WriteEntry(String.Format(format, args), t); | |
public void Dispose() => _evLog.Dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment