/// <inheritdoc /> public ValueTask <ErrorLogStatus> LogAsync(string exceptionMessage, object errorData = default, UserExceptionIdentifier identifier = default) { return(this.LogAsync(new Exception(exceptionMessage), errorData, identifier)); }
/// <inheritdoc /> public async ValueTask <ErrorLogStatus> LogAsync(Exception exception, object errorData = default, UserExceptionIdentifier userExceptionIdentifier = null) { if (this.ShouldIgnore(exception)) { return(ErrorLogStatus.Ignored); } // Attach extra data to the Exception object via. it's Data property, used in exception sinks to // add metadata useful for diagnostics purposes. if (errorData != null) { var dataAsDictionary = errorData is Dictionary <string, string> data ? data : errorData.ToStringDictionary(); foreach (var kvp in dataAsDictionary) { exception.Data[kvp.Key] = kvp.Value; } } // This is not a known and well-handled exception this._logger.LogError(exception, "An unhandled exception has occurred: {Message}", exception.Message); if (_isTestMode) { _testLoggedExceptions.Add(exception); return(ErrorLogStatus.Recorded); } try { this.Populate(exception); foreach (var sink in this._exceptionSinks) { await sink.RecordAsync(exception, userExceptionIdentifier); } } catch (Exception ex) { this._logger.LogError(ex, "Error logging error"); this._logger.LogError(exception, "Original error"); } return(ErrorLogStatus.Recorded); }
/// <inheritdoc /> /// <remarks> /// This method does nothing but return <see cref="ErrorLogStatus.Recorded" />. /// </remarks> public ValueTask <ErrorLogStatus> LogAsync(string exceptionMessage, object errorData = default, UserExceptionIdentifier identifier = default) { return(_recordedStatus); }