private static void WriteToFile(string description, string category) { if (!File.Exists(Tracer.LogPath)) { string dir = Path.GetDirectoryName(Tracer.LogPath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } StreamWriter w = File.CreateText(Tracer.LogPath); w.Close(); } StreamWriter writer = null; try { writer = File.AppendText(Tracer.LogPath); writer.Write(category + ": "); writer.WriteLine(description); } catch (Exception exception) { Tracer.writeToLogFile = false; Tracer.Write(exception.ToString(), "Tracer.WriteToFile"); } finally { writer.Close(); } }
private static void Write(Level level, string category, string format, params object[] args) { if (level <= Tracer.currentLevel) { Tracer.Write(string.Format(CultureInfo.InvariantCulture, format, args), category); } }
public static void Fatal(string category, string description) { Tracer.Write(Level.Fatal, category, description); }
//public static void Report(string category, string message, Exception exception) { // Tracer.Write(Level.ApplicationError, category, "{0}: {1}", message, exception); //} public static void Report(string category, Exception exception) { Tracer.Write(Level.ApplicationError, category, "{0}", exception); }
//public static void Info(string category, string message, params object[] args) { // Tracer.Write(Level.Info, category, message, args); //} public static void FullInfo(string category, string description, params object[] args) { Tracer.Write(Level.FullInfo, category, description, args); }