consolidate exception logging

This commit is contained in:
Luke Pulverenti
2014-11-23 17:36:40 -05:00
parent 70c5b341db
commit 1923de72bf
6 changed files with 48 additions and 38 deletions

View File

@@ -7,7 +7,6 @@ using MediaBrowser.Server.Startup.Common;
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Reflection;
@@ -124,7 +123,7 @@ namespace MediaBrowser.Server.Mono
{
var exception = (Exception)e.ExceptionObject;
LogUnhandledException(exception);
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
if (!Debugger.IsAttached)
{
@@ -132,22 +131,6 @@ 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);
Console.WriteLine ("UnhandledException");
Console.WriteLine (builder.ToString());
File.WriteAllText(path, builder.ToString());
}
public static void Shutdown()
{
ApplicationTaskCompletionSource.SetResult (true);