namespace bdf { using System; using System.Text; internal static class Logger { public static void Log(uint level, string format, params object[] objs) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("[{0}] ", DateTime.Now); try { sb.AppendFormat(format, objs); } catch (Exception e) { Console.WriteLine("Logger: invalid parameters for formatting. {0}:{1}", e.Message, e.InnerException.Message); } if (level <= bdf.debug ) { Console.WriteLine(sb.ToString()); bdf.outfile.WriteLine(sb.ToString()); } if (level <= bdf.adlvl ) { bdf.adminLog.AppendLine(sb.ToString()); } } /* public static void Log(uint level, string format, string s1, string s2) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("[{0}] ", DateTime.Now); sb.AppendFormat(format, s1, s2); if (level <= bdf.debug ) { Console.WriteLine(sb.ToString()); bdf.outfile.WriteLine(sb.ToString()); } if (level <= bdf.adlvl ) { bdf.adminLog.AppendLine(sb.ToString()); } } public static void Log(uint level, string format, string s1) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("[{0}] ", DateTime.Now); sb.AppendFormat(format, s1); if (level <= bdf.debug ) { Console.WriteLine(sb.ToString()); bdf.outfile.WriteLine(sb.ToString()); } if (level <= bdf.adlvl ) { bdf.adminLog.AppendLine(sb.ToString()); } } public static void Log(uint level, string message) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("[{0}] {1}", DateTime.Now, message); if (level <= bdf.debug ) { Console.WriteLine(sb.ToString()); bdf.outfile.WriteLine(sb.ToString()); } if (level <= bdf.adlvl ) { bdf.adminLog.AppendLine(sb.ToString()); } } */ public static void Log(string message) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("[{0}] {1}", DateTime.Now, message); Console.WriteLine(sb.ToString()); bdf.outfile.WriteLine(sb.ToString()); bdf.adminLog.AppendLine(sb.ToString()); } } }