public void Startup(AppDomain appDomain) { Log.Info(typeof(ExceptionlessClient), "Client startup."); try { appDomain.UnhandledException -= OnAppDomainUnhandledException; appDomain.UnhandledException += OnAppDomainUnhandledException; #if !PFX_LEGACY_3_5 TaskScheduler.UnobservedTaskException -= TaskSchedulerOnUnobservedTaskException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; #endif } catch (Exception ex) { Log.Error(typeof(ExceptionlessClient), ex, "An error occurred while wiring up to the unhandled exception events. This will happen when you are not running under full trust."); } if (!Configuration.HasValidApiKey) { Log.Error(typeof(ExceptionlessClient), "Invalid Exceptionless API key. Please ensure that your API key is configured properly."); } Log.Info(typeof(ExceptionlessClient), "Triggering configuration update and queue processing..."); UpdateConfigurationAsync(); ProcessQueueAsync(1000); Log.Info(typeof(ExceptionlessClient), "Done triggering configuration update and queue processing."); #if !SILVERLIGHT if (Configuration.TraceLogLimit > 0) { if (_traceListener != null && Trace.Listeners.Contains(_traceListener)) { Trace.Listeners.Remove(_traceListener); } _traceListener = new ExceptionlessTraceListener(Configuration.TraceLogLimit); Trace.Listeners.Add(_traceListener); } #endif if (!_startupCalled) { LocalConfiguration.StartCount++; // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately. LocalConfiguration.IsDirty = true; LocalConfiguration.Save(); } _startupCalled = true; Log.Info(typeof(ExceptionlessClient), "Startup done."); }
/// <summary> /// Updates the configuration. /// </summary> /// <param name="forceUpdate">if set to <c>true</c> to force update.</param> public void UpdateConfiguration(bool forceUpdate = false) { if (LocalConfiguration == null || _updatingConfiguration || (!forceUpdate && !IsConfigurationUpdateNeeded())) { Log.Info(typeof(ExceptionlessClient), "Configuration is up to date."); return; } Log.Info(typeof(ExceptionlessClient), "Updating configuration settings."); _updatingConfiguration = true; ClientConfiguration configuration = null; Exception error; try { RestClient client = CreateClient(); configuration = client.Get <ClientConfiguration>("project/config"); error = client.Error; } catch (Exception ex) { error = ex; } var args = new ConfigurationUpdatedEventArgs(configuration, error, false, _configuration); if (configuration == null) { Log.FormattedError(typeof(ExceptionlessClient), "Configuration response was null: {0}", error != null ? error.Message : ""); LocalConfiguration.NextConfigurationUpdate = DateTime.UtcNow.AddHours(1); } else { Config.ClientConfiguration.ProcessServerConfigResponse(this, configuration.Settings, _configuration.StoreId); LocalConfiguration.CurrentConfigurationVersion = configuration.Version; LocalConfiguration.NextConfigurationUpdate = DateTime.UtcNow.AddDays(1); } // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately. LocalConfiguration.IsDirty = true; LocalConfiguration.Save(); _updatingConfiguration = false; OnConfigurationUpdated(args); }
private void SaveEmailAddress(string emailAddress, bool save) { if (String.Equals(LocalConfiguration.EmailAddress, emailAddress, StringComparison.OrdinalIgnoreCase)) { return; } Log.FormattedInfo(typeof(ExceptionlessClient), "Saving email address '{0}'.", emailAddress); LocalConfiguration.EmailAddress = emailAddress; // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately. LocalConfiguration.IsDirty = true; if (save) { LocalConfiguration.Save(); } }
/// <summary> /// Submits the error report. /// </summary> /// <param name="data">The error data.</param> public void SubmitError(Error data) { Log.FormattedInfo(typeof(ExceptionlessClient), "Submitting error: id={0} type={1}", data != null ? data.Id : "null", data != null ? data.Type : "null"); if (CheckForDuplicateError(data)) { return; } if (!Configuration.Enabled) { Log.Info(typeof(ExceptionlessClient), "Configuration is disabled. The error will not be submitted."); return; } if (data == null) { throw new ArgumentNullException("data"); } if (data.ExceptionlessClientInfo == null) { data.ExceptionlessClientInfo = ExceptionlessClientInfoCollector.Collect(this, Configuration.IncludePrivateInformation); } if (String.IsNullOrEmpty(data.Id)) { data.Id = ObjectId.GenerateNewId().ToString(); } _queue.Enqueue(data); Log.FormattedInfo(typeof(ExceptionlessClient), "Setting last error id '{0}'", data.Id); LastErrorIdManager.SetLast(data.Id); QuickTimer(); SaveEmailAddress(data.UserEmail, false); LocalConfiguration.SubmitCount++; // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately. LocalConfiguration.IsDirty = true; LocalConfiguration.Save(); }