コード例 #1
0
            private LoggingEvent HandlePropertiesBuildingException(Exception ex, Severity severity)
            {
                var properties = new PropertiesDictionary();

                if (_exception != null)
                {
                    properties["Original.Exception.Message"]    = _exception.Message;
                    properties["Original.Exception.StackTrace"] = _exception.StackTrace;
                }

                if (!string.IsNullOrEmpty(_message))
                {
                    properties["Original.Message"] = _message;
                }

                try
                {
                    properties["Exception"] = new LoggableException(ex);
                }
                catch
                {
                    properties["Exception.Message"]    = ex.Message;
                    properties["Exception.StackTrace"] = ex.StackTrace;
                }

                properties["MachineName"] = Environment.MachineName;
                var eventData = new LoggingEventData
                {
                    Message    = "Error building log properties",
                    Properties = properties,
                    Level      = severity.ToLog4NetLevel()
                };

                return(new LoggingEvent(eventData));
            }
コード例 #2
0
        public void Should_sanitize_passwords_from_loggable_exception()
        {
            string expectedValue =
                "{\"user\":{\"************\":\"****\"},\"userPreferences\":{\"currency\":\"USD\",\"siteId\":\"UnitedStates\",\"language\":\"en-US\",\"timeZone\":\"UTC\"},\"profile\":{}}";

            var exception = new Exception();

            exception.Data["APIRequestContent"] =
                "{\"user\":{\"password\":\"foobar484634198\"},\"userPreferences\":{\"currency\":\"USD\",\"siteId\":\"UnitedStates\",\"language\":\"en-US\",\"timeZone\":\"UTC\"},\"profile\":{}}";

            var loggableException = new LoggableException(exception);

            loggableException.Data["APIRequestContent"].ShouldBeEquivalentTo(expectedValue);
        }
コード例 #3
0
        private static FormattedException FormatException(LoggableException exception)
        {
            var message = new FormattedException
            {
                Message = exception.Message,
                EnvironmentStackTrace = Environment.StackTrace,
                Source     = exception.Source,
                StackTrace = exception.StackTrace,
                TargetSite = exception.TargetSite.IfNotNull(x => x.ToString())
            };

            if (exception.InnerException != null)
            {
                message.InnerException = FormatException(exception.InnerException);
            }
            return(message);
        }
コード例 #4
0
ファイル: Flow.cs プロジェクト: thierry-prost/TPL-extension
 public Flow(LoggableException exception)
 {
     Fail(exception);
 }
コード例 #5
0
ファイル: Flow.cs プロジェクト: thierry-prost/TPL-extension
 /// <summary>
 /// Fails the flow to be processed by an FailureBlock with a loggable exception.
 /// </summary>
 public void Fail(LoggableException exception)
 {
     Exception = exception;
 }