Logging Refactor + Event IDs (#57)

* Logging Refactor + Event IDs

* x1000

* Fixes

* Some misses
This commit is contained in:
Jordan Brown
2017-06-19 20:41:34 +02:00
committed by AnturK
parent 030fe93e00
commit 09309cc674
11 changed files with 178 additions and 56 deletions
+76 -4
View File
@@ -9,12 +9,84 @@ using TGServiceInterface;
namespace TGServerService
{
public partial class TGServerService : ServiceBase
{
{
//only deprecate events, do not reuse them
public enum EventID
{
ChatCommand = 1000,
ChatConnectFail = 2000,
ChatProviderStartFail = 3000,
InvalidChatProvider = 4000,
UpdateRequest = 5000,
BYONDUpdateFail = 6000,
BYONDUpdateStaged = 7000,
BYONDUpdateComplete = 8000,
ServerMoveFailed = 9000,
ServerMovePartial = 10000,
ServerMoveComplete = 11000,
DMCompileCrash = 12000,
DMInitializeCrash = 13000,
DMCompileError = 14000,
DMCompileSuccess = 15000,
DMCompileCancel = 16000,
DDReattachFail = 17000,
DDReattachSuccess = 18000,
DDWatchdogCrash = 19000,
DDWatchdogExit = 20000,
DDWatchdogRebootedServer = 21000,
DDWatchdogRebootingServer = 22000,
DDWatchdogRestart = 23000,
DDWatchdogRestarted = 24000,
DDWatchdogStarted = 25000,
ChatSend = 26000,
ChatBroadcast = 27000,
ChatAdminBroadcast = 28000,
ChatDisconnectFail = 29000,
TopicSent = 300000,
TopicFailed = 31000,
CommsKeySet = 32000,
NudgeStartFail = 33000,
NudgeCrash = 34000,
RepoClone = 35000,
RepoCloneFail = 36000,
RepoCheckout = 37000,
RepoCheckoutFail = 38000,
RepoHardUpdate = 39000,
RepoHardUpdateFail = 40000,
RepoMergeUpdate = 41000,
RepoMergeUpdateFail = 42000,
RepoBackupTag = 43000,
RepoBackupTagFail = 44000,
RepoResetTracked = 45000,
RepoResetTrackedFail = 46000,
RepoReset = 47000,
RepoResetFail = 48000,
RepoPRListError = 49000,
RepoPRMerge = 50000,
RepoPRMergeFail = 51000,
RepoCommit = 52000,
RepoCommitFail = 53000,
RepoPush = 54000,
RepoPushFail = 55000,
RepoChangelog = 56000,
RepoChangelogFail = 57000,
ServiceShutdownFail = 61000,
WorldReboot = 62000,
}
static TGServerService ActiveService; //So everyone else can write to our eventlog
public static void WriteLog(string message, EventLogEntryType type = EventLogEntryType.Information)
public static void WriteInfo(string message, EventID id)
{
ActiveService.EventLog.WriteEntry(message, type);
ActiveService.EventLog.WriteEntry(message, EventLogEntryType.Information, (int)id);
}
public static void WriteError(string message, EventID id)
{
ActiveService.EventLog.WriteEntry(message, EventLogEntryType.Error, (int)id);
}
public static void WriteWarning(string message, EventID id)
{
ActiveService.EventLog.WriteEntry(message, EventLogEntryType.Warning, (int)id);
}
public static void LocalStop()
@@ -84,7 +156,7 @@ namespace TGServerService
}
catch (Exception e)
{
WriteLog(e.ToString(), EventLogEntryType.Error);
WriteError(e.ToString(), EventID.ServiceShutdownFail);
}
}
}