better crash logging
This commit is contained in:
parent
645a41b193
commit
3d3876c9a9
|
@ -471,7 +471,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
|
||||
foreach (var pair in options.RequestHeaders.ToList())
|
||||
{
|
||||
message.Headers.Add(pair.Key, pair.Value);
|
||||
if (!message.Headers.TryAddWithoutValidation(pair.Key, pair.Value))
|
||||
{
|
||||
_logger.Error("Unable to add request header {0} with value {1}", pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
|
@ -484,9 +487,31 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
/// <returns>System.Nullable{System.Int64}.</returns>
|
||||
private long? GetContentLength(HttpResponseMessage response)
|
||||
{
|
||||
IEnumerable<string> lengthValues;
|
||||
IEnumerable<string> lengthValues = null;
|
||||
|
||||
if (!response.Headers.TryGetValues("content-length", out lengthValues) && !response.Content.Headers.TryGetValues("content-length", out lengthValues))
|
||||
// Seeing some InvalidOperationException here under mono
|
||||
try
|
||||
{
|
||||
response.Headers.TryGetValues("content-length", out lengthValues);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.ErrorException("Error accessing response.Headers.TryGetValues Content-Length", ex);
|
||||
}
|
||||
|
||||
if (lengthValues == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
response.Content.Headers.TryGetValues("content-length", out lengthValues);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.ErrorException("Error accessing response.Content.Headers.TryGetValues Content-Length", ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (lengthValues == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
<Properties>
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloadInfo.cs">
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Model\Web\QueryStringDictionary.cs">
|
||||
<Files>
|
||||
<File FileName="MediaBrowser.Server.Implementations\HttpServer\HttpServer.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.Server.Mono\Networking\NetworkManager.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.ServerApplication\ApplicationHost.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.ServerApplication\FFMpeg\FFMpegDownloader.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloadInfo.cs" Line="21" Column="1" />
|
||||
<File FileName="MediaBrowser.ServerApplication\FFMpeg\FFMpegDownloader.cs" Line="31" Column="30" />
|
||||
<File FileName="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloadInfo.cs" Line="1" Column="1" />
|
||||
<File FileName="MediaBrowser.Model\Web\QueryStringDictionary.cs" Line="26" Column="10" />
|
||||
</Files>
|
||||
<Pads>
|
||||
<Pad Id="ProjectPad">
|
||||
<State expanded="True">
|
||||
<Node name="MediaBrowser.Model" expanded="True" />
|
||||
<Node name="MediaBrowser.Model" expanded="True">
|
||||
<Node name="References" expanded="True" selected="True" />
|
||||
<Node name="Web" expanded="True" />
|
||||
</Node>
|
||||
<Node name="MediaBrowser.Server.Mono" expanded="True">
|
||||
<Node name="FFMpeg" expanded="True">
|
||||
<Node name="FFMpegDownloadInfo.cs" selected="True" />
|
||||
</Node>
|
||||
<Node name="FFMpeg" expanded="True" />
|
||||
</Node>
|
||||
</State>
|
||||
</Pad>
|
||||
|
|
|
@ -259,7 +259,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="sqlite3.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="swagger-ui\css\hightlight.default.css">
|
||||
|
|
|
@ -135,5 +135,8 @@
|
|||
<None Include="tray.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="sqlite3.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -206,7 +206,7 @@ namespace MediaBrowser.Server.Mono
|
|||
{
|
||||
var exception = (Exception)e.ExceptionObject;
|
||||
|
||||
_logger.ErrorException("UnhandledException", exception);
|
||||
LogUnhandledException(exception);
|
||||
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
|
@ -214,6 +214,19 @@ namespace MediaBrowser.Server.Mono
|
|||
}
|
||||
}
|
||||
|
||||
private static void LogUnhandledException(Exception ex)
|
||||
{
|
||||
_logger.ErrorException("UnhandledException", ex);
|
||||
|
||||
_appHost.LogManager.Flush ();
|
||||
|
||||
var path = Path.Combine(_appHost.ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, "crash_" + Guid.NewGuid() + ".txt");
|
||||
|
||||
var builder = LogHelper.GetLogMessage(ex);
|
||||
|
||||
File.WriteAllText(path, builder.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the update if needed.
|
||||
/// </summary>
|
||||
|
|
|
@ -398,7 +398,7 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
var exception = (Exception)e.ExceptionObject;
|
||||
|
||||
_logger.ErrorException("UnhandledException", exception);
|
||||
LogUnhandledException(exception);
|
||||
|
||||
_appHost.LogManager.Flush();
|
||||
|
||||
|
@ -413,6 +413,17 @@ namespace MediaBrowser.ServerApplication
|
|||
}
|
||||
}
|
||||
|
||||
private static void LogUnhandledException(Exception ex)
|
||||
{
|
||||
_logger.ErrorException("UnhandledException", ex);
|
||||
|
||||
var path = Path.Combine(_appHost.ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, "crash_" + Guid.NewGuid() + ".txt");
|
||||
|
||||
var builder = LogHelper.GetLogMessage(ex);
|
||||
|
||||
File.WriteAllText(path, builder.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the update if needed.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user