Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
LogMessage.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 base log message used by the logging infrastructure.
9  /// </summary>
10  /// <remarks>
11  /// This class can be derived in order to provide additional custom log information.
12  /// </remarks>
13  public class LogMessage : ILogMessage
14  {
15  /// <summary>
16  /// Initializes a new instance of the <see cref="LogMessage" /> class.
17  /// </summary>
18  public LogMessage()
19  {
20  }
21 
22  /// <summary>
23  /// Initializes a new instance of the <see cref="LogMessage" /> class.
24  /// </summary>
25  /// <param name="module">The module.</param>
26  /// <param name="type">The type.</param>
27  /// <param name="text">The text.</param>
28  public LogMessage(string module, LogMessageType type, string text)
29  {
30  Module = module;
31  Type = type;
32  Text = text;
33  }
34 
35  /// <summary>
36  /// Initializes a new instance of the <see cref="LogMessage" /> class.
37  /// </summary>
38  /// <param name="module">The module.</param>
39  /// <param name="type">The type.</param>
40  /// <param name="text">The text.</param>
41  /// <param name="exception">The exception.</param>
42  /// <param name="callerInfo">The caller info.</param>
43  public LogMessage(string module, LogMessageType type, string text, Exception exception, CallerInfo callerInfo)
44  {
45  Module = module;
46  Type = type;
47  Text = text;
48  Exception = exception;
49  CallerInfo = callerInfo;
50  }
51 
52  /// <summary>
53  /// Gets or sets the module.
54  /// </summary>
55  /// <value>The module.</value>
56  /// <remarks>
57  /// 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.
58  /// </remarks>
59  public string Module { get; set; }
60 
61  /// <summary>
62  /// Gets or sets the type of this message.
63  /// </summary>
64  /// <value>The type.</value>
65  public LogMessageType Type { get; set; }
66 
67  /// <summary>
68  /// Gets or sets the text.
69  /// </summary>
70  /// <value>The text.</value>
71  public string Text { get; set; }
72 
73  /// <summary>
74  /// Gets or sets the exception.
75  /// </summary>
76  /// <value>The exception.</value>
77  public Exception Exception { get; set; }
78 
79  /// <summary>
80  /// Gets or sets the caller information.
81  /// </summary>
82  /// <value>The caller information.</value>
83  public CallerInfo CallerInfo { get; set; }
84 
85  /// <summary>
86  /// Returns a <see cref="System.String" /> that represents this instance.
87  /// </summary>
88  /// <returns>A <see cref="System.String" /> that represents this instance.</returns>
89  public override string ToString()
90  {
91  return string.Format("[{0}]: {1}: {2}{3}", Module, Type, Text, Exception == null ? string.Empty : string.Format(". {0}", Exception));
92  }
93  }
94 }
override string ToString()
Returns a System.String that represents this instance.
Definition: LogMessage.cs:89
LogMessage()
Initializes a new instance of the LogMessage class.
Definition: LogMessage.cs:18
LogMessage(string module, LogMessageType type, string text, Exception exception, CallerInfo callerInfo)
Initializes a new instance of the LogMessage class.
Definition: LogMessage.cs:43
A class to store Caller Information attributes.
Definition: CallerInfo.cs:10
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
LogMessage(string module, LogMessageType type, string text)
Initializes a new instance of the LogMessage class.
Definition: LogMessage.cs:28