|
5 | 5 |
|
6 | 6 | namespace ThinkSharp.FeatureTouring.Logging |
7 | 7 | { |
| 8 | + /// <summary> |
| 9 | + /// Logger that writes messages to the console (<see cref="Console.WriteLine(string)"/>). |
| 10 | + /// </summary> |
8 | 11 | public class ConsoleLogger : ILogger |
9 | 12 | { |
10 | 13 | private readonly string myPrefix; |
11 | 14 |
|
| 15 | + /// <summary> |
| 16 | + /// Creates a new instance of the class. This version does not use a prefix. |
| 17 | + /// </summary> |
12 | 18 | public ConsoleLogger() : this("") |
13 | 19 | { } |
14 | 20 |
|
| 21 | + /// <summary> |
| 22 | + /// Creates a new instance of the class. |
| 23 | + /// </summary> |
| 24 | + /// <param name="prefix"> |
| 25 | + /// The prefix to use for all logging entries. |
| 26 | + /// </param> |
15 | 27 | public ConsoleLogger(string prefix) |
16 | 28 | { |
17 | 29 | myPrefix = prefix; |
18 | 30 | } |
19 | 31 |
|
| 32 | + /// <summary> |
| 33 | + /// Log debug message. |
| 34 | + /// </summary> |
| 35 | + /// <param name="message">The message to log.</param> |
20 | 36 | public void Debug(object message) |
21 | 37 | { |
22 | 38 | if (Debugger.IsAttached) |
23 | 39 | WriteLog(message); |
24 | 40 | } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Log debug message. |
| 44 | + /// </summary> |
| 45 | + /// <param name="message">The message to log.</param> |
| 46 | + /// <param name="exception">The exception to log.</param> |
25 | 47 | public void Debug(object message, Exception exception) |
26 | 48 | { |
27 | 49 | if (Debugger.IsAttached) |
28 | 50 | WriteLog(message + "; Exception: " + exception); |
29 | 51 | } |
30 | | - public void DebugFormat(string format, params object[] args) |
31 | | - { |
32 | | - if (Debugger.IsAttached) |
33 | | - WriteLogFormat(format, args); |
34 | | - } |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// Log error message. |
| 55 | + /// </summary> |
| 56 | + /// <param name="message">The message to log.</param> |
35 | 57 | public void Error(object message) |
36 | 58 | { |
37 | 59 | if (Debugger.IsAttached) |
38 | 60 | WriteLog(message); |
39 | 61 | } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Log error message. |
| 65 | + /// </summary> |
| 66 | + /// <param name="message">The message to log.</param> |
| 67 | + /// <param name="exception">The exception to log.</param> |
40 | 68 | public void Error(object message, Exception exception) |
41 | 69 | { |
42 | 70 | if (Debugger.IsAttached) |
43 | 71 | WriteLog(message + "; Exception: " + exception); |
44 | 72 | } |
45 | | - public void ErrorFormat(string format, params object[] args) |
46 | | - { |
47 | | - if (Debugger.IsAttached) |
48 | | - WriteLogFormat(format, args); |
49 | | - } |
50 | 73 | public void Info(object message) |
51 | 74 | { |
52 | 75 | if (Debugger.IsAttached) |
53 | 76 | WriteLog(message); |
54 | 77 | } |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// Log informational message. |
| 81 | + /// </summary> |
| 82 | + /// <param name="message">The message to log.</param> |
| 83 | + /// <param name="exception">The exception to log.</param> |
55 | 84 | public void Info(object message, Exception exception) |
56 | 85 | { |
57 | 86 | if (Debugger.IsAttached) |
58 | 87 | WriteLog(message + "; Exception: " + exception); |
59 | 88 | } |
60 | | - public void InfoFormat(string format, params object[] args) |
61 | | - { |
62 | | - if (Debugger.IsAttached) |
63 | | - WriteLogFormat(format, args); |
64 | | - } |
65 | 89 | public void Warn(object message) |
66 | 90 | { |
67 | 91 | if (Debugger.IsAttached) |
68 | 92 | WriteLog(message); |
69 | 93 | } |
| 94 | + |
| 95 | + /// <summary> |
| 96 | + /// Log warning message. |
| 97 | + /// </summary> |
| 98 | + /// <param name="message">The message to log.</param> |
| 99 | + /// <param name="exception">The exception to log.</param> |
70 | 100 | public void Warn(object message, Exception exception) |
71 | 101 | { |
72 | 102 | if (Debugger.IsAttached) |
73 | 103 | WriteLog(message + "; Exception: " + exception); |
74 | 104 | } |
75 | | - public void WarnFormat(string format, params object[] args) |
76 | | - { |
77 | | - if (Debugger.IsAttached) |
78 | | - WriteLogFormat(format, args); |
79 | | - } |
80 | | - |
81 | | - private void WriteLogFormat(string logContent, params object[] parameters) |
82 | | - { |
83 | | - Console.WriteLine(myPrefix + ":" + logContent, parameters); |
84 | | - } |
85 | 105 |
|
86 | 106 | private void WriteLog(object logContent) |
87 | 107 | { |
|
0 commit comments