@@ -11,7 +11,7 @@ public static class Log
1111 {
1212 public const string DirectoryName = "Logs" ;
1313
14- public static string CurrentLogDirectory { get ; private set ; }
14+ public static string CurrentLogDirectory { get ; }
1515
1616 static Log ( )
1717 {
@@ -53,23 +53,32 @@ private static bool FormatValid(string message)
5353
5454 [ MethodImpl ( MethodImplOptions . Synchronized ) ]
5555 public static void Exception ( string className , string message , System . Exception exception , [ CallerMemberName ] string methodName = "" )
56+ {
57+ var classNameWithMethod = CheckClassAndMessageAndReturnFullClassWithMethod ( className , message , methodName ) ;
58+
59+ ExceptionInternal ( classNameWithMethod , message , exception ) ;
60+ }
61+
62+ private static string CheckClassAndMessageAndReturnFullClassWithMethod ( string className , string message ,
63+ string methodName )
5664 {
5765 if ( string . IsNullOrWhiteSpace ( className ) )
5866 {
5967 LogFaultyFormat ( $ "Fail to specify a class name during logging of message: { message ?? "no message entered" } ") ;
6068 }
6169
6270 if ( string . IsNullOrWhiteSpace ( message ) )
63- { // todo: not sure we really need that
71+ {
72+ // todo: not sure we really need that
6473 LogFaultyFormat ( $ "Fail to specify a message during logging") ;
6574 }
6675
6776 if ( ! string . IsNullOrWhiteSpace ( methodName ) )
6877 {
69- className += "." + methodName ;
78+ return className + "." + methodName ;
7079 }
7180
72- ExceptionInternal ( className , message , exception ) ;
81+ return className ;
7382 }
7483
7584 private static void ExceptionInternal ( string classAndMethod , string message , System . Exception e )
@@ -140,18 +149,48 @@ public static void Error(string message)
140149 LogInternal ( message , LogLevel . Error ) ;
141150 }
142151
152+ public static void Error ( string className , string message , [ CallerMemberName ] string methodName = "" )
153+ {
154+ LogInternal ( LogLevel . Error , className , message , methodName ) ;
155+ }
156+
157+ private static void LogInternal ( LogLevel level , string className , string message , [ CallerMemberName ] string methodName = "" )
158+ {
159+ var classNameWithMethod = CheckClassAndMessageAndReturnFullClassWithMethod ( className , message , methodName ) ;
160+
161+ var logger = LogManager . GetLogger ( classNameWithMethod ) ;
162+
163+ System . Diagnostics . Debug . WriteLine ( $ "{ level . Name } |{ message } ") ;
164+ logger . Log ( level , message ) ;
165+ }
166+
167+ public static void Debug ( string className , string message , [ CallerMemberName ] string methodName = "" )
168+ {
169+ LogInternal ( LogLevel . Debug , className , message , methodName ) ;
170+ }
171+
143172 /// <param name="message">example: "|prefix|unprefixed" </param>
144173 public static void Debug ( string message )
145174 {
146175 LogInternal ( message , LogLevel . Debug ) ;
147176 }
148177
178+ public static void Info ( string className , string message , [ CallerMemberName ] string methodName = "" )
179+ {
180+ LogInternal ( LogLevel . Info , className , message , methodName ) ;
181+ }
182+
149183 /// <param name="message">example: "|prefix|unprefixed" </param>
150184 public static void Info ( string message )
151185 {
152186 LogInternal ( message , LogLevel . Info ) ;
153187 }
154188
189+ public static void Warn ( string className , string message , [ CallerMemberName ] string methodName = "" )
190+ {
191+ LogInternal ( LogLevel . Warn , className , message , methodName ) ;
192+ }
193+
155194 /// <param name="message">example: "|prefix|unprefixed" </param>
156195 public static void Warn ( string message )
157196 {
0 commit comments