3
3
4
4
namespace CommonsLibrary . Logging
5
5
{
6
+ /// <summary>
7
+ /// Log container class
8
+ /// </summary>
9
+ /// <remarks>Depends on 'System' & 'System.IO' packages.</remarks>
6
10
public class Log
7
11
{
8
12
private readonly string _filePath ;
9
13
private static Log ? _logger ;
10
14
11
15
private Log ( string filePath ) => _filePath = filePath ;
16
+ /// <summary>
17
+ /// Singleton used to retrieve the active logger
18
+ /// </summary>
19
+ /// <param name="filePath">Full file path of the log file</param>
20
+ /// <returns>Instance of the Log class</returns>
12
21
public static Log GetLogger ( string filePath ) => _logger ??= new Log ( filePath ) ;
13
22
14
23
private void WriteLog ( LogLevel level , string message , Exception ? exception = null )
@@ -17,12 +26,25 @@ private void WriteLog(LogLevel level, string message, Exception? exception = nul
17
26
writer . WriteLine ( $ "{ DateTime . Now } { level } { exception } { message } ") ;
18
27
}
19
28
29
+ /// <summary>
30
+ /// Used to create Info level logs
31
+ /// </summary>
32
+ /// <param name="message">Message to be written</param>
20
33
public void Info ( string message ) =>
21
34
WriteLog ( LogLevel . Info , message ) ;
22
35
36
+ /// <summary>
37
+ /// Used to create Warning level logs
38
+ /// </summary>
39
+ /// <param name="message">Message to be written</param>
23
40
public void Warning ( string message ) =>
24
41
WriteLog ( LogLevel . Warning , message ) ;
25
42
43
+ /// <summary>
44
+ /// Used to create Error level logs
45
+ /// </summary>
46
+ /// <param name="message">Message to be written</param>
47
+ /// <param name="exception">Exception to be logged</param>
26
48
public void Error ( string message , Exception exception ) =>
27
49
WriteLog ( LogLevel . Error , message , exception ) ;
28
50
0 commit comments