You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added EventViewer logging of Exceptions from the Service
Removed the need for a batch file
Fixed logging not working
Fixed graceful shutdown
Fixed folder path needing trim on installer
Copy file name to clipboardExpand all lines: PhantomBotService/GlobalSuppressions.cs
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,6 @@
5
5
// a specific target and scoped to a namespace, type, member, etc.
6
6
7
7
[assembly:System.Diagnostics.CodeAnalysis.SuppressMessage("Security","SG0018:Path traversal",Justification="Safe usage for log file names",Scope="member",Target="~M:PhantomBotService.PhantomBotService.OnStart(System.String[])")]
8
-
[assembly:System.Diagnostics.CodeAnalysis.SuppressMessage("Design","RCS1075:Avoid empty catch clause that catches System.Exception.",Justification="Catches log file Exceptions",Scope="member",Target="~M:PhantomBotService.PhantomBotService.OnStart(System.String[])")]
9
-
[assembly:System.Diagnostics.CodeAnalysis.SuppressMessage("Design","RCS1075:Avoid empty catch clause that catches System.Exception.",Justification="Catches log file Exceptions",Scope="member",Target="~M:PhantomBotService.PhantomBotService.OnStop")]
10
8
[assembly:System.Diagnostics.CodeAnalysis.SuppressMessage("Security","SG0018:Path traversal",Justification="Path provided by installer",Scope="member",Target="~M:PhantomBotService.PhantomBotServiceInstaller.CreateConfig")]
11
9
[assembly:System.Diagnostics.CodeAnalysis.SuppressMessage("Security","SG0018:Path traversal",Justification="Path provided by installer",Scope="member",Target="~M:PhantomBotService.PhantomBotServiceInstaller.DeleteConfig")]
this.EventLog.WriteEntry("Failed to open config file: "+path+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
this.EventLog.WriteEntry("Failed to open log file: "+path+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
152
+
}
153
+
154
+
try
155
+
{
132
156
this.phantomBotProcess.Start();
157
+
this.phantomBotProcess.BeginErrorReadLine();
158
+
this.phantomBotProcess.BeginOutputReadLine();
133
159
}
134
-
catch(Exception)
160
+
catch(Exceptione)
135
161
{
162
+
this.EventLog.WriteEntry("Failed to start process: "+this.phantomBotProcess.StartInfo.WorkingDirectory+"\\"+this.phantomBotProcess.StartInfo.FileName+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
this.EventLog.WriteEntry("Failed to end process"+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
192
+
}
193
+
194
+
try
195
+
{
196
+
if(!this.phantomBotProcess.HasExited)
158
197
{
159
198
this.phantomBotProcess.Kill();
160
199
}
161
200
}
162
-
catch(Exception)
201
+
catch(Exceptione)
163
202
{
203
+
this.EventLog.WriteEntry("Failed to kill process"+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
this.EventLog.WriteEntry("Failed to close log file"+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
this.EventLog.WriteEntry("Failed to write to log file: "+logline+Environment.NewLine+Environment.NewLine+e.GetType().FullName+": "+e.Message+Environment.NewLine+e.StackTrace,EventLogEntryType.Error);
0 commit comments