mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
consolidate exception logging
This commit is contained in:
parent
70c5b341db
commit
1923de72bf
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"LabelExit": "Exit",
|
"LabelExit": "Exit",
|
||||||
"LabelVisitCommunity": "Visit Community",
|
"LabelVisitCommunity": "Visit Community",
|
||||||
"LabelGithubWiki": "Github Wiki",
|
"LabelGithub": "Github",
|
||||||
"LabelSwagger": "Swagger",
|
"LabelSwagger": "Swagger",
|
||||||
"LabelStandard": "Standard",
|
"LabelStandard": "Standard",
|
||||||
"LabelViewApiDocumentation": "View Api Documentation",
|
"LabelApiDocumentation": "Api Documentation",
|
||||||
|
"LabelDeveloperResources": "Developer Resources",
|
||||||
"LabelBrowseLibrary": "Browse Library",
|
"LabelBrowseLibrary": "Browse Library",
|
||||||
"LabelConfigureMediaBrowser": "Configure Media Browser",
|
"LabelConfigureMediaBrowser": "Configure Media Browser",
|
||||||
"LabelOpenLibraryViewer": "Open Library Viewer",
|
"LabelOpenLibraryViewer": "Open Library Viewer",
|
||||||
|
@ -7,7 +7,6 @@ using MediaBrowser.Server.Startup.Common;
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -124,7 +123,7 @@ namespace MediaBrowser.Server.Mono
|
|||||||
{
|
{
|
||||||
var exception = (Exception)e.ExceptionObject;
|
var exception = (Exception)e.ExceptionObject;
|
||||||
|
|
||||||
LogUnhandledException(exception);
|
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
|
||||||
|
|
||||||
if (!Debugger.IsAttached)
|
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()
|
public static void Shutdown()
|
||||||
{
|
{
|
||||||
ApplicationTaskCompletionSource.SetResult (true);
|
ApplicationTaskCompletionSource.SetResult (true);
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
<Compile Include="NativeEnvironment.cs" />
|
<Compile Include="NativeEnvironment.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="StartupOptions.cs" />
|
<Compile Include="StartupOptions.cs" />
|
||||||
|
<Compile Include="UnhandledExceptionWriter.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj">
|
<ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj">
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.Implementations.Logging;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Startup.Common
|
||||||
|
{
|
||||||
|
public class UnhandledExceptionWriter
|
||||||
|
{
|
||||||
|
private readonly IApplicationPaths _appPaths;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ILogManager _logManager;
|
||||||
|
|
||||||
|
public UnhandledExceptionWriter(IApplicationPaths appPaths, ILogger logger, ILogManager logManager)
|
||||||
|
{
|
||||||
|
_appPaths = appPaths;
|
||||||
|
_logger = logger;
|
||||||
|
_logManager = logManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Log(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("UnhandledException", ex);
|
||||||
|
_logManager.Flush();
|
||||||
|
|
||||||
|
var path = Path.Combine(_appPaths.LogDirectoryPath, "unhandled_" + Guid.NewGuid() + ".txt");
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
|
var builder = LogHelper.GetLogMessage(ex);
|
||||||
|
|
||||||
|
// Write to console just in case file logging fails
|
||||||
|
Console.WriteLine("UnhandledException");
|
||||||
|
Console.WriteLine(builder.ToString());
|
||||||
|
|
||||||
|
File.WriteAllText(path, builder.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -455,9 +455,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
var exception = (Exception)e.ExceptionObject;
|
var exception = (Exception)e.ExceptionObject;
|
||||||
|
|
||||||
LogUnhandledException(exception);
|
new UnhandledExceptionWriter(_appHost.ServerConfigurationManager.ApplicationPaths, _logger, _appHost.LogManager).Log(exception);
|
||||||
|
|
||||||
_appHost.LogManager.Flush();
|
|
||||||
|
|
||||||
if (!_isRunningAsService)
|
if (!_isRunningAsService)
|
||||||
{
|
{
|
||||||
@ -470,18 +468,6 @@ namespace MediaBrowser.ServerApplication
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void LogUnhandledException(Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("UnhandledException", ex);
|
|
||||||
|
|
||||||
var path = Path.Combine(_appHost.ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, "unhandled_" + Guid.NewGuid() + ".txt");
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
||||||
|
|
||||||
var builder = LogHelper.GetLogMessage(ex);
|
|
||||||
|
|
||||||
File.WriteAllText(path, builder.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs the update if needed.
|
/// Performs the update if needed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -174,9 +174,9 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
cmdExit.Text = _localization.GetLocalizedString("LabelExit");
|
cmdExit.Text = _localization.GetLocalizedString("LabelExit");
|
||||||
cmdCommunity.Text = _localization.GetLocalizedString("LabelVisitCommunity");
|
cmdCommunity.Text = _localization.GetLocalizedString("LabelVisitCommunity");
|
||||||
cmdGtihub.Text = _localization.GetLocalizedString("LabelGithubWiki");
|
cmdGtihub.Text = _localization.GetLocalizedString("LabelGithub");
|
||||||
cmdSwagger.Text = _localization.GetLocalizedString("LabelSwagger");
|
cmdSwagger.Text = _localization.GetLocalizedString("LabelApiDocumentation");
|
||||||
cmdApiDocs.Text = _localization.GetLocalizedString("LabelViewApiDocumentation");
|
cmdApiDocs.Text = _localization.GetLocalizedString("LabelDeveloperResources");
|
||||||
cmdBrowse.Text = _localization.GetLocalizedString("LabelBrowseLibrary");
|
cmdBrowse.Text = _localization.GetLocalizedString("LabelBrowseLibrary");
|
||||||
cmdConfigure.Text = _localization.GetLocalizedString("LabelConfigureMediaBrowser");
|
cmdConfigure.Text = _localization.GetLocalizedString("LabelConfigureMediaBrowser");
|
||||||
cmdRestart.Text = _localization.GetLocalizedString("LabelRestartServer");
|
cmdRestart.Text = _localization.GetLocalizedString("LabelRestartServer");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user