mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Exceptions are now sent to exceptrack
This commit is contained in:
parent
2b5776acbf
commit
aff17f7767
17 changed files with 58 additions and 159 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Exceptrack.Driver;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Contract;
|
||||
|
||||
|
@ -15,9 +16,11 @@ namespace NzbDrone.Common
|
|||
private const string EXCEPTION_URL = SERVICE_URL + "/ReportException";
|
||||
|
||||
public static RestProvider RestProvider { get; set; }
|
||||
private static readonly HashSet<string> parserErrorCache = new HashSet<string>();
|
||||
public static ExceptionClient ExceptrackDriver { get; set; }
|
||||
|
||||
|
||||
private static readonly HashSet<string> parserErrorCache = new HashSet<string>();
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
lock (parserErrorCache)
|
||||
|
@ -30,12 +33,12 @@ namespace NzbDrone.Common
|
|||
{
|
||||
try
|
||||
{
|
||||
VerifyRestProvider();
|
||||
VerifyDependencies();
|
||||
|
||||
lock (parserErrorCache)
|
||||
{
|
||||
if (parserErrorCache.Contains(title.ToLower())) return;
|
||||
|
||||
|
||||
parserErrorCache.Add(title.ToLower());
|
||||
}
|
||||
|
||||
|
@ -58,16 +61,15 @@ namespace NzbDrone.Common
|
|||
{
|
||||
try
|
||||
{
|
||||
VerifyRestProvider();
|
||||
|
||||
var report = new ExceptionReport();
|
||||
report.LogMessage = logEvent.FormattedMessage;
|
||||
report.Stack = logEvent.Exception.StackTrace;
|
||||
report.ExceptionMessage = logEvent.Exception.Message;
|
||||
report.Logger = logEvent.LoggerName;
|
||||
report.Type = logEvent.Exception.GetType().FullName;
|
||||
VerifyDependencies();
|
||||
|
||||
RestProvider.PostData(EXCEPTION_URL, report);
|
||||
var exceptionData = new ExceptionData();
|
||||
|
||||
exceptionData.Exception = logEvent.Exception;
|
||||
exceptionData.Location = logEvent.LoggerName;
|
||||
exceptionData.UserId = EnvironmentProvider.UGuid.ToString().Replace("-", string.Empty);
|
||||
|
||||
ExceptrackDriver.SubmitException(exceptionData);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -81,11 +83,20 @@ namespace NzbDrone.Common
|
|||
}
|
||||
}
|
||||
|
||||
private static void VerifyRestProvider()
|
||||
|
||||
public static void SetupExceptrackDriver()
|
||||
{
|
||||
if(RestProvider == null)
|
||||
ExceptrackDriver = new ExceptionClient(
|
||||
"CB230C312E5C4FF38B4FB9644B05E60D",
|
||||
new EnvironmentProvider().Version.ToString(),
|
||||
new Uri("http://api.exceptrack.com/"));
|
||||
}
|
||||
|
||||
private static void VerifyDependencies()
|
||||
{
|
||||
if (RestProvider == null)
|
||||
{
|
||||
if(EnvironmentProvider.IsProduction)
|
||||
if (EnvironmentProvider.IsProduction)
|
||||
{
|
||||
logger.Warn("Rest provider wasn't provided. creating new one!");
|
||||
RestProvider = new RestProvider(new EnvironmentProvider());
|
||||
|
@ -95,6 +106,19 @@ namespace NzbDrone.Common
|
|||
throw new InvalidOperationException("REST Provider wasn't configured correctly.");
|
||||
}
|
||||
}
|
||||
|
||||
if (ExceptrackDriver == null)
|
||||
{
|
||||
if (EnvironmentProvider.IsProduction)
|
||||
{
|
||||
logger.Warn("Exceptrack Driver wasn't provided. creating new one!");
|
||||
SetupExceptrackDriver();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Exceptrack Driver wasn't configured correctly.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue