示例#1
0
        private static void LoadHttpProxyOptions(RollbarInfrastructureConfig config, RollbarConfigSection rollbarConfigSection)
        {
            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyAddress))
            {
                HttpProxyOptions httpProxyOptions = new(rollbarConfigSection.ProxyAddress);

                if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyUsername))
                {
                    httpProxyOptions.ProxyUsername = rollbarConfigSection.ProxyUsername;
                }

                if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyPassword))
                {
                    httpProxyOptions.ProxyPassword = rollbarConfigSection.ProxyPassword;
                }

                config.RollbarLoggerConfig.HttpProxyOptions.Reconfigure(httpProxyOptions);
            }
        }
示例#2
0
 /// <summary>
 /// Gets the configuration.
 /// </summary>
 /// <returns></returns>
 public static RollbarConfigSection GetConfiguration()
 {
     try
     {
         RollbarConfigSection configuration =
             ConfigurationManager.GetSection("rollbar")
             as RollbarConfigSection;
         return(configuration);
     }
     catch (Exception ex)
     {
         //let's just trace it for now:
         traceSource.TraceEvent(
             TraceEventType.Warning,
             0,
             $"Error while attempting to get RollbarConfigSection:{System.Environment.NewLine}{ex}");
         return(null);
     }
 }
示例#3
0
        private static void LoadDeveloperOptions(RollbarInfrastructureConfig config, RollbarConfigSection rollbarConfigSection)
        {
            if (rollbarConfigSection.Enabled.HasValue)
            {
                config.RollbarLoggerConfig.RollbarDeveloperOptions.Enabled = rollbarConfigSection.Enabled.Value;
            }

            if (rollbarConfigSection.Transmit.HasValue)
            {
                config.RollbarLoggerConfig.RollbarDeveloperOptions.Transmit = rollbarConfigSection.Transmit.Value;
            }

            if (rollbarConfigSection.RethrowExceptionsAfterReporting.HasValue)
            {
                config.RollbarLoggerConfig.RollbarDeveloperOptions.RethrowExceptionsAfterReporting = rollbarConfigSection.RethrowExceptionsAfterReporting.Value;
            }

            if (rollbarConfigSection.LogLevel.HasValue)
            {
                config.RollbarLoggerConfig.RollbarDeveloperOptions.LogLevel = rollbarConfigSection.LogLevel.Value;
            }
        }
示例#4
0
        private static void LoadOfflinePayloadStoreOptions(RollbarInfrastructureConfig config, RollbarConfigSection rollbarConfigSection)
        {
            RollbarOfflineStoreOptions offlineStoreOptions = new();

            if (rollbarConfigSection.EnableLocalPayloadStore.HasValue)
            {
                offlineStoreOptions.EnableLocalPayloadStore = rollbarConfigSection.EnableLocalPayloadStore.Value;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.LocalPayloadStoreFileName))
            {
                offlineStoreOptions.LocalPayloadStoreFileName = rollbarConfigSection.LocalPayloadStoreFileName;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.LocalPayloadStoreLocationPath))
            {
                offlineStoreOptions.LocalPayloadStoreLocationPath = rollbarConfigSection.LocalPayloadStoreLocationPath;
            }

            config.RollbarOfflineStoreOptions.Reconfigure(offlineStoreOptions);
        }
示例#5
0
        private static void LoadInfrastructureOptions(RollbarInfrastructureConfig config, RollbarConfigSection rollbarConfigSection)
        {
            RollbarInfrastructureOptions infrastructureOptions = new();

            if (rollbarConfigSection.MaxReportsPerMinute.HasValue)
            {
                infrastructureOptions.MaxReportsPerMinute = rollbarConfigSection.MaxReportsPerMinute.Value;
            }

            if (rollbarConfigSection.ReportingQueueDepth.HasValue)
            {
                infrastructureOptions.ReportingQueueDepth = rollbarConfigSection.ReportingQueueDepth.Value;
            }

            if (rollbarConfigSection.MaxItems.HasValue)
            {
                infrastructureOptions.MaxItems = rollbarConfigSection.MaxItems.Value;
            }

            if (rollbarConfigSection.CaptureUncaughtExceptions.HasValue)
            {
                infrastructureOptions.CaptureUncaughtExceptions = rollbarConfigSection.CaptureUncaughtExceptions.Value;
            }

            if (rollbarConfigSection.PayloadPostTimeout.HasValue)
            {
                infrastructureOptions.PayloadPostTimeout = rollbarConfigSection.PayloadPostTimeout.Value;
            }

            config.RollbarInfrastructureOptions.Reconfigure(infrastructureOptions);
        }
示例#6
0
 public static bool LoadAppSettings(RollbarInfrastructureConfig config)
 {
     return(AppConfigUtility.LoadAppSettings(config, RollbarConfigSection.GetConfiguration()));
 }
示例#7
0
        private static void LoadDataSecurityOptions(RollbarInfrastructureConfig config, RollbarConfigSection rollbarConfigSection)
        {
            RollbarDataSecurityOptions dataSecurityOptions = new();

            if (rollbarConfigSection.ScrubFields != null && rollbarConfigSection.ScrubFields.Length > 0)
            {
                dataSecurityOptions.ScrubFields =
                    string.IsNullOrEmpty(rollbarConfigSection.ScrubFields) ? Array.Empty <string>()
                    : rollbarConfigSection.ScrubFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries);
            }

            if (rollbarConfigSection.ScrubSafelistFields != null && rollbarConfigSection.ScrubSafelistFields.Length > 0)
            {
                dataSecurityOptions.ScrubSafelistFields =
                    string.IsNullOrEmpty(rollbarConfigSection.ScrubSafelistFields) ? Array.Empty <string>()
                    : rollbarConfigSection.ScrubSafelistFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries);
            }

            if (rollbarConfigSection.PersonDataCollectionPolicies.HasValue)
            {
                dataSecurityOptions.PersonDataCollectionPolicies = rollbarConfigSection.PersonDataCollectionPolicies.Value;
            }

            if (rollbarConfigSection.IpAddressCollectionPolicy.HasValue)
            {
                dataSecurityOptions.IpAddressCollectionPolicy = rollbarConfigSection.IpAddressCollectionPolicy.Value;
            }

            config.RollbarLoggerConfig.RollbarDataSecurityOptions.Reconfigure(dataSecurityOptions);
        }
示例#8
0
        private static void LoadDestinationOptions(RollbarInfrastructureConfig config, RollbarConfigSection rollbarConfigSection)
        {
            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.AccessToken))
            {
                RollbarDestinationOptions destinationOptions = new(rollbarConfigSection.AccessToken);

                if (!string.IsNullOrWhiteSpace(rollbarConfigSection.Environment))
                {
                    destinationOptions.Environment = rollbarConfigSection.Environment;
                }

                if (!string.IsNullOrWhiteSpace(rollbarConfigSection.EndPoint))
                {
                    destinationOptions.EndPoint = rollbarConfigSection.EndPoint;
                }

                config.RollbarLoggerConfig.RollbarDestinationOptions.Reconfigure(destinationOptions);
            }
        }
示例#9
0
        /// <summary>
        /// Loads the application settings.
        /// </summary>
        /// <param name="rollbarConfig">The configuration.</param>
        /// <param name="rollbarConfigSection">The application settings.</param>
        /// <returns>false when the configuration was not found, otherwise true.</returns>
        public static bool LoadAppSettings(RollbarConfig rollbarConfig, RollbarConfigSection rollbarConfigSection)
        {
            if (rollbarConfigSection == null)
            {
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.AccessToken))
            {
                rollbarConfig.AccessToken = rollbarConfigSection.AccessToken;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.Environment))
            {
                rollbarConfig.Environment = rollbarConfigSection.Environment;
            }

            if (rollbarConfigSection.Enabled.HasValue)
            {
                rollbarConfig.Enabled = rollbarConfigSection.Enabled.Value;
            }

            if (rollbarConfigSection.Transmit.HasValue)
            {
                rollbarConfig.Transmit = rollbarConfigSection.Transmit.Value;
            }

            if (rollbarConfigSection.RethrowExceptionsAfterReporting.HasValue)
            {
                rollbarConfig.RethrowExceptionsAfterReporting = rollbarConfigSection.RethrowExceptionsAfterReporting.Value;
            }

            if (rollbarConfigSection.EnableLocalPayloadStore.HasValue)
            {
                rollbarConfig.EnableLocalPayloadStore = rollbarConfigSection.EnableLocalPayloadStore.Value;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.LocalPayloadStoreFileName))
            {
                rollbarConfig.LocalPayloadStoreFileName = rollbarConfigSection.LocalPayloadStoreFileName;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.LocalPayloadStoreLocationPath))
            {
                rollbarConfig.LocalPayloadStoreLocationPath = rollbarConfigSection.LocalPayloadStoreLocationPath;
            }

            if (rollbarConfigSection.MaxReportsPerMinute.HasValue)
            {
                rollbarConfig.MaxReportsPerMinute = rollbarConfigSection.MaxReportsPerMinute.Value;
            }

            if (rollbarConfigSection.ReportingQueueDepth.HasValue)
            {
                rollbarConfig.ReportingQueueDepth = rollbarConfigSection.ReportingQueueDepth.Value;
            }

            if (rollbarConfigSection.MaxItems.HasValue)
            {
                rollbarConfig.MaxItems = rollbarConfigSection.MaxItems.Value;
            }

            if (rollbarConfigSection.CaptureUncaughtExceptions.HasValue)
            {
                rollbarConfig.CaptureUncaughtExceptions = rollbarConfigSection.CaptureUncaughtExceptions.Value;
            }

            if (rollbarConfigSection.LogLevel.HasValue)
            {
                rollbarConfig.LogLevel = rollbarConfigSection.LogLevel.Value;
            }

            if (rollbarConfigSection.ScrubFields != null && rollbarConfigSection.ScrubFields.Length > 0)
            {
                rollbarConfig.ScrubFields =
                    string.IsNullOrEmpty(rollbarConfigSection.ScrubFields) ? new string[0]
                    : rollbarConfigSection.ScrubFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries);
            }

            if (rollbarConfigSection.ScrubSafelistFields != null && rollbarConfigSection.ScrubSafelistFields.Length > 0)
            {
                rollbarConfig.ScrubSafelistFields =
                    string.IsNullOrEmpty(rollbarConfigSection.ScrubSafelistFields) ? new string[0]
                    : rollbarConfigSection.ScrubSafelistFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries);
            }

            if (rollbarConfigSection.ScrubWhitelistFields != null && rollbarConfigSection.ScrubWhitelistFields.Length > 0)
            {
                rollbarConfig.ScrubWhitelistFields =
                    string.IsNullOrEmpty(rollbarConfigSection.ScrubWhitelistFields) ? new string[0]
                    : rollbarConfigSection.ScrubWhitelistFields.Split(listValueSplitters, StringSplitOptions.RemoveEmptyEntries);
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.EndPoint))
            {
                rollbarConfig.EndPoint = rollbarConfigSection.EndPoint;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyAddress))
            {
                rollbarConfig.ProxyAddress = rollbarConfigSection.ProxyAddress;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyUsername))
            {
                rollbarConfig.ProxyUsername = rollbarConfigSection.ProxyUsername;
            }

            if (!string.IsNullOrWhiteSpace(rollbarConfigSection.ProxyPassword))
            {
                rollbarConfig.ProxyPassword = rollbarConfigSection.ProxyPassword;
            }

            if (rollbarConfigSection.PayloadPostTimeout.HasValue)
            {
                rollbarConfig.PayloadPostTimeout = rollbarConfigSection.PayloadPostTimeout.Value;
            }

            if (rollbarConfigSection.PersonDataCollectionPolicies.HasValue)
            {
                rollbarConfig.PersonDataCollectionPolicies = rollbarConfigSection.PersonDataCollectionPolicies.Value;
            }

            if (rollbarConfigSection.IpAddressCollectionPolicy.HasValue)
            {
                rollbarConfig.IpAddressCollectionPolicy = rollbarConfigSection.IpAddressCollectionPolicy.Value;
            }

            return(true);
        }
示例#10
0
 /// <summary>
 /// Loads the application settings.
 /// </summary>
 /// <param name="rollbarConfig">The Rollbar configuration.</param>
 /// <returns>false when the configuration was not found, otherwise true.</returns>
 public static bool LoadAppSettings(RollbarConfig rollbarConfig)
 {
     return(AppConfigUtility.LoadAppSettings(rollbarConfig, RollbarConfigSection.GetConfiguration()));
 }