diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs b/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs index dab06455c..7c325ee19 100644 --- a/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs +++ b/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs @@ -13,28 +13,50 @@ namespace Tango.Logging [Serializable] public class ExceptionLogItem : LogItemBase { - private bool _messageSet; - - [NonSerialized] - private Exception _exception; /// <summary> /// Gets or sets the log item exception. /// </summary> - public Exception Exception - { - get { return _exception; } - set { _exception = value; } - } + public Exception Exception { get; set; } /// <summary> - /// Gets the log message. + /// Gets or sets the error description. /// </summary> - public override string Message { get; set; } + public String Description { get; set; } /// <summary> - /// Gets or sets the error description. + /// Gets the log message. /// </summary> - public String Description { get; set; } + public override string Message + { + get + { + if (Exception is AggregateException) + { + try + { + String message = String.Empty; + + if (Description != null) + { + message += Description + Environment.NewLine; + } + + message += String.Join(Environment.NewLine, (Exception as AggregateException).InnerExceptions.Select(x => x.Message)); + + return message; + } + catch + { + return Exception.Message; + } + } + else + { + return Exception.Message; + } + } + set { } + } /// <summary> /// Returns a formatted string of the log item. @@ -43,5 +65,6 @@ namespace Tango.Logging { return String.Format("[{0}] [{6}] [{1}] [{2}] [{3}]: {4}{5}", TimeStamp.ToString("HH:mm:ss.ff"), GetRelativeCallerFilePath(), CallerMethodName, CallerLineNumber, Description, Environment.NewLine + Exception.FlattenException(), Category); } + } } |
