Disable Sentry Reporting based on analytics flag

pull/6/head
Keivan Beigi 8 years ago
parent a1f112e62f
commit dd7fdd8ace

@ -22,7 +22,7 @@ namespace NzbDrone.Api
/// </summary> /// </summary>
public static IEnumerable<Func<Assembly, bool>> DefaultAutoRegisterIgnoredAssemblies = new Func<Assembly, bool>[] public static IEnumerable<Func<Assembly, bool>> DefaultAutoRegisterIgnoredAssemblies = new Func<Assembly, bool>[]
{ {
asm => !asm.FullName.StartsWith("Nancy.", StringComparison.InvariantCulture), asm => !asm.FullName.StartsWith("Nancy.", StringComparison.InvariantCulture)
}; };
/// <summary> /// <summary>

@ -6,7 +6,6 @@ using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using TinyIoC; using TinyIoC;
namespace NzbDrone.Common.Composition namespace NzbDrone.Common.Composition
{ {
public abstract class ContainerBuilderBase public abstract class ContainerBuilderBase

@ -59,6 +59,12 @@ namespace NzbDrone.Common.Instrumentation
LogManager.ReconfigExistingLoggers(); LogManager.ReconfigExistingLoggers();
} }
public static void UnRegisterRemoteLoggers()
{
LogManager.Configuration.RemoveTarget("sentryTarget");
LogManager.ReconfigExistingLoggers();
}
private static void RegisterLogEntries() private static void RegisterLogEntries()
{ {
var target = new LogentriesTarget(); var target = new LogentriesTarget();
@ -112,7 +118,6 @@ namespace NzbDrone.Common.Instrumentation
LogManager.Configuration.LoggingRules.Add(loggingRule); LogManager.Configuration.LoggingRules.Add(loggingRule);
} }
private static void RegisterConsole() private static void RegisterConsole()
{ {
var level = LogLevel.Trace; var level = LogLevel.Trace;
@ -128,7 +133,7 @@ namespace NzbDrone.Common.Instrumentation
LogManager.Configuration.LoggingRules.Add(loggingRule); LogManager.Configuration.LoggingRules.Add(loggingRule);
} }
const string FILE_LOG_LAYOUT = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}}"; private const string FILE_LOG_LAYOUT = @"${date:format=yy-M-d HH\:mm\:ss.f}|${level}|${logger}|${message}${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}}";
private static void RegisterAppFile(IAppFolderInfo appFolderInfo) private static void RegisterAppFile(IAppFolderInfo appFolderInfo)
{ {
@ -137,7 +142,7 @@ namespace NzbDrone.Common.Instrumentation
RegisterAppFile(appFolderInfo, "appFileTrace", "sonarr.trace.txt", 50, LogLevel.Off); RegisterAppFile(appFolderInfo, "appFileTrace", "sonarr.trace.txt", 50, LogLevel.Off);
} }
private static LoggingRule RegisterAppFile(IAppFolderInfo appFolderInfo, string name, string fileName, int maxArchiveFiles, LogLevel minLogLevel) private static void RegisterAppFile(IAppFolderInfo appFolderInfo, string name, string fileName, int maxArchiveFiles, LogLevel minLogLevel)
{ {
var fileTarget = new NzbDroneFileTarget(); var fileTarget = new NzbDroneFileTarget();
@ -158,8 +163,6 @@ namespace NzbDrone.Common.Instrumentation
LogManager.Configuration.AddTarget(name, fileTarget); LogManager.Configuration.AddTarget(name, fileTarget);
LogManager.Configuration.LoggingRules.Add(loggingRule); LogManager.Configuration.LoggingRules.Add(loggingRule);
return loggingRule;
} }
private static void RegisterUpdateFile(IAppFolderInfo appFolderInfo) private static void RegisterUpdateFile(IAppFolderInfo appFolderInfo)

@ -12,7 +12,7 @@ using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using NzbDrone.Test.Common.Categories; using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.InstrumentationTests namespace NzbDrone.Core.Test.Instrumentation
{ {
[TestFixture] [TestFixture]
public class DatabaseTargetFixture : DbTest<DatabaseTarget, Log> public class DatabaseTargetFixture : DbTest<DatabaseTarget, Log>

@ -265,7 +265,7 @@
<Compile Include="IndexerTests\TorrentRssIndexerTests\TestTorrentRssIndexer.cs" /> <Compile Include="IndexerTests\TorrentRssIndexerTests\TestTorrentRssIndexer.cs" />
<Compile Include="IndexerTests\WomblesTests\WomblesFixture.cs" /> <Compile Include="IndexerTests\WomblesTests\WomblesFixture.cs" />
<Compile Include="IndexerTests\XElementExtensionsFixture.cs" /> <Compile Include="IndexerTests\XElementExtensionsFixture.cs" />
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" /> <Compile Include="Instrumentation\DatabaseTargetFixture.cs" />
<Compile Include="JobTests\JobRepositoryFixture.cs" /> <Compile Include="JobTests\JobRepositoryFixture.cs" />
<Compile Include="JobTests\TestJobs.cs" /> <Compile Include="JobTests\TestJobs.cs" />
<Compile Include="MediaCoverTests\CoverExistsSpecificationFixture.cs" /> <Compile Include="MediaCoverTests\CoverExistsSpecificationFixture.cs" />
@ -570,6 +570,7 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="InstrumentationTests\" />
<Folder Include="ProviderTests\UpdateProviderTests\" /> <Folder Include="ProviderTests\UpdateProviderTests\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -9,6 +9,7 @@ using NzbDrone.Common.Cache;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.Authentication; using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration.Events; using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Lifecycle;
@ -154,7 +155,7 @@ namespace NzbDrone.Core.Configuration
SetValue("AuthenticationMethod", AuthenticationType.Basic); SetValue("AuthenticationMethod", AuthenticationType.Basic);
return AuthenticationType.Basic; return AuthenticationType.Basic;
} }
return GetValueEnum("AuthenticationMethod", AuthenticationType.None); return GetValueEnum("AuthenticationMethod", AuthenticationType.None);
} }
} }
@ -188,7 +189,7 @@ namespace NzbDrone.Core.Configuration
public UpdateMechanism UpdateMechanism => GetValueEnum("UpdateMechanism", UpdateMechanism.BuiltIn, false); public UpdateMechanism UpdateMechanism => GetValueEnum("UpdateMechanism", UpdateMechanism.BuiltIn, false);
public string UpdateScriptPath => GetValue("UpdateScriptPath", "", false ); public string UpdateScriptPath => GetValue("UpdateScriptPath", "", false);
public int GetValueInt(string key, int defaultValue) public int GetValueInt(string key, int defaultValue)
{ {
@ -344,6 +345,11 @@ namespace NzbDrone.Core.Configuration
{ {
EnsureDefaultConfigFile(); EnsureDefaultConfigFile();
DeleteOldValues(); DeleteOldValues();
if (!AnalyticsEnabled)
{
NzbDroneLogger.UnRegisterRemoteLoggers();
}
} }
public void Execute(ResetApiKeyCommand message) public void Execute(ResetApiKeyCommand message)

@ -33,12 +33,12 @@ namespace NzbDrone.Update
SecurityProtocolPolicy.Register(); SecurityProtocolPolicy.Register();
X509CertificateValidationPolicy.Register(); X509CertificateValidationPolicy.Register();
var startupArgument = new StartupContext(args); var startupContext = new StartupContext(args);
NzbDroneLogger.Register(startupArgument, true, true); NzbDroneLogger.Register(startupContext, true, true);
Logger.Info("Starting Sonarr Update Client"); Logger.Info("Starting Sonarr Update Client");
_container = UpdateContainerBuilder.Build(startupArgument); _container = UpdateContainerBuilder.Build(startupContext);
_container.Resolve<UpdateApp>().Start(args); _container.Resolve<UpdateApp>().Start(args);

Loading…
Cancel
Save