1 // /home/jeremie/TaoParser/NGenerator/Logger.cs
2 // Writtent by jeremie at 17:47 09/06/2007
4 // This file is licensed under the LGPL licence as described in the COPYING file
8 using System
.Diagnostics
;
17 public static class Logger
19 static TextWriter sw
= Console
.Out
;
21 public static TextWriter Output
{
27 throw new ArgumentNullException("value");
33 private static void Log(LogType type
, string mess
)
35 StackTrace st
= new StackTrace();
36 StackFrame sf
= st
.GetFrame(2);
38 if (mess
== null || sf
== null)
41 if (sw
== Console
.Out
)
42 Console
.ForegroundColor
= (type
== LogType
.Error
) ? ConsoleColor
.DarkRed
: ConsoleColor
.DarkBlue
;
44 sw
.WriteLine(type
.ToString()+" -> "+ sf
.GetMethod().Name
+" :: "+mess
);
46 if (sw
== Console
.Out
)
50 [System
.Diagnostics
.ConditionalAttribute("__DEBUG__")]
51 public static void Debug(string mess
)
53 Log(LogType
.Debug
, mess
);
56 public static void Error(string mess
, Exception ex
)
58 string message
= (ex
== null) ? mess
: (mess
+ ", Exception type : " + ex
.GetType().ToString()
59 + ", Exception message : " + ex
.Message
);
60 Log(LogType
.Error
, message
);