Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SerializableLogMessage.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Core.Diagnostics
6 {
7  /// <summary>
8  /// A class that represents a copy of a <see cref="LogMessage"/> that can be serialized.
9  /// </summary>
10  [DataContract]
12  {
13  /// <summary>
14  /// Initializes a new instance of the <see cref="SerializableLogMessage"/> class with default values for its properties.
15  /// </summary>
17  {
18  }
19 
20  /// <summary>
21  /// Initializes a new instance of the <see cref="SerializableLogMessage"/> class from a <see cref="LogMessage"/> instance.
22  /// </summary>
23  /// <param name="message">The <see cref="LogMessage"/> instance to use to initialize properties.</param>
25  {
26  Module = message.Module;
27  Type = message.Type;
28  Text = message.Text;
29  ExceptionInfo = message.Exception != null ? new ExceptionInfo(message.Exception) : null;
30  }
31 
32  /// <summary>
33  /// Initializes a new instance of the <see cref="SerializableLogMessage"/> class using the given parameters to set its properties.
34  /// </summary>
35  /// <param name="module">The module name.</param>
36  /// <param name="type">The type.</param>
37  /// <param name="text">The text.</param>
38  /// <param name="exceptionInfo">The exception information. This parameter can be null.</param>
39  public SerializableLogMessage(string module, LogMessageType type, string text, ExceptionInfo exceptionInfo = null)
40  {
41  if (module == null) throw new ArgumentNullException("module");
42  if (text == null) throw new ArgumentNullException("text");
43  Module = module;
44  Type = type;
45  Text = text;
46  ExceptionInfo = exceptionInfo;
47  }
48 
49  /// <summary>
50  /// Gets or sets the module.
51  /// </summary>
52  /// <remarks>
53  /// The module is an identifier for a logical part of the system. It can be a class name, a namespace or a regular string not linked to a code hierarchy.
54  /// </remarks>
55  public string Module { get; set; }
56 
57  /// <summary>
58  /// Gets or sets the type of this message.
59  /// </summary>
60  public LogMessageType Type { get; set; }
61 
62  /// <summary>
63  /// Gets or sets the text.
64  /// </summary>
65  public string Text { get; set; }
66 
67  /// <summary>
68  /// Gets or sets the <see cref="ExceptionInfo"/> of this message.
69  /// </summary>
70  public ExceptionInfo ExceptionInfo { get; set; }
71 
72  /// <inheritdoc/>
73  public override string ToString()
74  {
75  return string.Format("[{0}]: {1}: {2}{3}", Module, Type, Text, ExceptionInfo != null ? string.Format(" Exception: {0}", ExceptionInfo.Message) : "");
76  }
77  }
78 }
SerializableLogMessage()
Initializes a new instance of the SerializableLogMessage class with default values for its properties...
Exception Exception
Gets or sets the exception.
Definition: LogMessage.cs:77
SerializableLogMessage(string module, LogMessageType type, string text, ExceptionInfo exceptionInfo=null)
Initializes a new instance of the SerializableLogMessage class using the given parameters to set its ...
A class that represents a copy of a LogMessage that can be serialized.
LogMessageType
Type of a LogMessage.
A base log message used by the logging infrastructure.
Definition: LogMessage.cs:13
The base interface for log messages used by the logging infrastructure.
Definition: ILogMessage.cs:8
SerializableLogMessage(LogMessage message)
Initializes a new instance of the SerializableLogMessage class from a LogMessage instance.
This class is used to store some properties of an exception. It is serializable.