Some logging changes

This commit is contained in:
zone117x
2015-04-22 20:04:57 -06:00
parent 012cec3a8b
commit 0530bed226

View File

@@ -60,12 +60,15 @@ namespace Jackett
} }
catch (HttpListenerException ex) catch (HttpListenerException ex)
{ {
Console.WriteLine("Server start exception: " + ex.ToString()); var errorStr = "App must be ran as Admin for permission to use port "
var dialogResult = MessageBox.Show( + Port + Environment.NewLine
"App must be ran as Admin for permission to use port " + Port + Environment.NewLine + "Restart app with admin privileges?", + "Restart app with admin privileges?";
"Failed to open port",
MessageBoxButtons.YesNo Program.LoggerInstance.FatalException("Failed to start HTTP server", ex);
);
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
var dialogResult = MessageBox.Show(errorStr, "Error", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.No) if (dialogResult == DialogResult.No)
{ {
Program.LoggerInstance.FatalException("App must be ran as Admin for permission to use port " + Port, ex); Program.LoggerInstance.FatalException("App must be ran as Admin for permission to use port " + Port, ex);
@@ -77,12 +80,13 @@ namespace Jackett
Program.RestartAsAdmin(); Program.RestartAsAdmin();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine("Server start exception: " + ex.ToString()); Program.LoggerInstance.ErrorException("Error starting HTTP server: " + ex.Message, ex);
Program.LoggerInstance.ErrorException("Error: " + ex.Message, ex);
return; return;
} }
Program.LoggerInstance.Info("Server started on port " + Port); Program.LoggerInstance.Info("Server started on port " + Port);
try try
@@ -94,10 +98,19 @@ namespace Jackett
catch (Exception) { } catch (Exception) { }
while (true) while (true)
{
try
{ {
var context = await listener.GetContextAsync(); var context = await listener.GetContextAsync();
ProcessHttpRequest(context); ProcessHttpRequest(context);
} }
catch (Exception ex)
{
Program.LoggerInstance.ErrorException("Error processing HTTP request", ex);
}
}
Program.LoggerInstance.Debug("HTTP request servicer thread died");
} }
public void Stop() public void Stop()