1- using Microsoft . Extensions . Logging ;
2- using System ;
3-
4- namespace Shared . General
1+ namespace Shared . Logger
52{
3+ using System ;
4+
5+ /// <summary>
6+ ///
7+ /// </summary>
68 public static class Logger
79 {
8- #region Private Properties
10+ #region Fields
11+
912 /// <summary>
1013 /// The logger object
1114 /// </summary>
1215 private static ILogger LoggerObject ;
16+
1317 #endregion
1418
15- #region Public Properties
19+ #region Properties
20+
1621 /// <summary>
1722 /// Gets or sets a value indicating whether this instance is initialised.
1823 /// </summary>
1924 /// <value>
2025 /// <c>true</c> if this instance is initialised; otherwise, <c>false</c>.
2126 /// </value>
2227 public static Boolean IsInitialised { get ; set ; }
28+
2329 #endregion
2430
25- #region Public Methods
31+ #region Methods
32+
33+ /// <summary>
34+ /// Initialises the specified logger object.
35+ /// </summary>
36+ /// <param name="loggerObject">The logger object.</param>
37+ /// <param name="fileName">Name of the file.</param>
38+ public static void Initialise ( NLog . Logger loggerObject ,
39+ String fileName )
40+ {
41+ NlogLogger logger = new NlogLogger ( ) ;
42+ logger . Initialise ( loggerObject , fileName ) ;
43+ Logger . Initialise ( logger ) ;
44+ }
2645
27- #region public static void Initialise(ILogger loggerObject)
2846 /// <summary>
2947 /// Initialises the specified logger object.
3048 /// </summary>
3149 /// <param name="loggerObject">The logger object.</param>
50+ /// <exception cref="ArgumentNullException">loggerObject</exception>
3251 public static void Initialise ( ILogger loggerObject )
3352 {
34- LoggerObject = loggerObject ?? throw new ArgumentNullException ( nameof ( loggerObject ) ) ;
53+ Logger . LoggerObject = loggerObject ?? throw new ArgumentNullException ( nameof ( loggerObject ) ) ;
3554
3655 Logger . IsInitialised = true ;
3756 }
38- #endregion
3957
40- #region public static void LogTrace(String message)
4158 /// <summary>
42- /// Logs the trace .
59+ /// Logs the critical .
4360 /// </summary>
44- /// <param name="message ">The message .</param>
45- public static void LogTrace ( String message )
61+ /// <param name="exception ">The exception .</param>
62+ public static void LogCritical ( Exception exception )
4663 {
47- ValidateLoggerObject ( ) ;
64+ Logger . ValidateLoggerObject ( ) ;
4865
49- LoggerObject . LogTrace ( new EventId ( ) , message ) ;
66+ Logger . LoggerObject . LogCritical ( exception ) ;
5067 }
51- #endregion
5268
53- #region public static void LogDebug(String message)
5469 /// <summary>
5570 /// Logs the debug.
5671 /// </summary>
5772 /// <param name="message">The message.</param>
5873 public static void LogDebug ( String message )
5974 {
60- ValidateLoggerObject ( ) ;
75+ Logger . ValidateLoggerObject ( ) ;
6176
62- LoggerObject . LogDebug ( new EventId ( ) , message ) ;
77+ Logger . LoggerObject . LogDebug ( message ) ;
6378 }
64- #endregion
6579
66- #region public static void LogInformation(String message)
6780 /// <summary>
68- /// Logs the information .
81+ /// Logs the error .
6982 /// </summary>
70- /// <param name="message ">The message .</param>
71- public static void LogInformation ( String message )
83+ /// <param name="exception ">The exception .</param>
84+ public static void LogError ( Exception exception )
7285 {
73- ValidateLoggerObject ( ) ;
86+ Logger . ValidateLoggerObject ( ) ;
7487
75- LoggerObject . LogInformation ( new EventId ( ) , message ) ;
88+ Logger . LoggerObject . LogError ( exception ) ;
7689 }
77- #endregion
7890
79- #region public static void LogWarning(String message)
8091 /// <summary>
81- /// Logs the warning .
92+ /// Logs the information .
8293 /// </summary>
8394 /// <param name="message">The message.</param>
84- public static void LogWarning ( String message )
95+ public static void LogInformation ( String message )
8596 {
86- ValidateLoggerObject ( ) ;
97+ Logger . ValidateLoggerObject ( ) ;
8798
88- LoggerObject . LogWarning ( new EventId ( ) , message ) ;
99+ Logger . LoggerObject . LogInformation ( message ) ;
89100 }
90- #endregion
91101
92- #region public static void LogError(Exception exception)
93102 /// <summary>
94- /// Logs the error .
103+ /// Logs the trace .
95104 /// </summary>
96- /// <param name="exception ">The exception .</param>
97- public static void LogError ( Exception exception )
105+ /// <param name="message ">The message .</param>
106+ public static void LogTrace ( String message )
98107 {
99- ValidateLoggerObject ( ) ;
108+ Logger . ValidateLoggerObject ( ) ;
100109
101- LoggerObject . LogError ( new EventId ( ) , exception , exception . Message ) ;
110+ Logger . LoggerObject . LogTrace ( message ) ;
102111 }
103- #endregion
104112
105- #region public static void LogCritical(Exception exception)
106113 /// <summary>
107- /// Logs the critical .
114+ /// Logs the warning .
108115 /// </summary>
109- /// <param name="exception ">The exception .</param>
110- public static void LogCritical ( Exception exception )
116+ /// <param name="message ">The message .</param>
117+ public static void LogWarning ( String message )
111118 {
112- ValidateLoggerObject ( ) ;
119+ Logger . ValidateLoggerObject ( ) ;
113120
114- LoggerObject . LogCritical ( new EventId ( ) , exception , exception . Message ) ;
121+ Logger . LoggerObject . LogWarning ( message ) ;
115122 }
116- #endregion
117123
118- #endregion
119-
120- #region Private Methods
121-
122- #region private static void ValidateLoggerObject()
123124 /// <summary>
124125 /// Validates the logger object.
125126 /// </summary>
126127 /// <exception cref="InvalidOperationException">Logger has not been initialised</exception>
127128 private static void ValidateLoggerObject ( )
128129 {
129- if ( LoggerObject == null )
130+ if ( Logger . LoggerObject == null )
130131 {
131132 throw new InvalidOperationException ( "Logger has not been initialised" ) ;
132133 }
133134 }
134- #endregion
135135
136136 #endregion
137-
138137 }
139-
140- }
138+ }
0 commit comments