diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 14:27:05 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 14:27:05 +0200 |
| commit | 1344a54c37f7cbba7a294674b4b733d72ee257ea (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| parent | 281610ac56799f6870c587a942495d91cd55b227 (diff) | |
| download | Tango-1344a54c.tar.gz Tango-1344a54c.zip | |
Hope it is fine
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); } + } } |
