namespace Holo { using System; using System.Diagnostics; using System.IO; using System.Text; public static class Out { private static bool bwait = false; public static logFlags minimumImportance; public static void wait() { while (bwait) { } } public static void WriteBlank() { wait(); bwait = true; Console.WriteLine(); bwait = false; } public static void WriteDCError(string logText) { try { FileStream stream = new FileStream("DC.err", FileMode.Append, FileAccess.Write); byte[] bytes = Encoding.ASCII.GetBytes(logText + "\r\n\r\n"); stream.Write(bytes, 0, bytes.Length); } catch (Exception exception) { WritePlain(exception.Message); } wait(); bwait = true; DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = ConsoleColor.Red; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] \x00bb "); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Disconnection has been saved"); Console.ForegroundColor = ConsoleColor.Gray; bwait = false; } public static void WriteError(string logText) { DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = ConsoleColor.Red; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] \x00bb "); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(logText); Console.ForegroundColor = ConsoleColor.Gray; } public static void WriteError(string logText, logFlags logFlag) { if (logFlag >= minimumImportance) { DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = ConsoleColor.Red; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] \x00bb "); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine(logText); Console.ForegroundColor = ConsoleColor.Gray; } } public static void WriteLine(string logText) { wait(); bwait = true; DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = ConsoleColor.Green; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] \x00bb "); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(logText); Console.ForegroundColor = ConsoleColor.Gray; bwait = false; } public static void WriteLine(string logText, logFlags logFlag) { if (logFlag >= minimumImportance) { wait(); bwait = true; DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = ConsoleColor.Green; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] \x00bb "); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(logText); Console.ForegroundColor = ConsoleColor.Gray; bwait = false; } } public static void WriteLine(string logText, logFlags logFlag, ConsoleColor colorOne, ConsoleColor colorTwo) { if (logFlag >= minimumImportance) { wait(); bwait = true; DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = colorOne; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] \x00bb "); Console.ForegroundColor = colorTwo; Console.WriteLine(logText); Console.ForegroundColor = ConsoleColor.Gray; bwait = false; } } public static void WritePlain(string logText) { wait(); bwait = true; Console.WriteLine(logText); bwait = false; } public static void WriteSpecialLine(string logText, logFlags logFlag, ConsoleColor colorOne, ConsoleColor colorTwo, string headerHead, int headerLength, ConsoleColor headerColor) { wait(); bwait = true; DateTime now = DateTime.Now; StackFrame frame = new StackTrace().GetFrame(1); Console.Write("[" + now.ToLongTimeString() + ":" + now.Millisecond.ToString() + "] ["); Console.ForegroundColor = colorOne; Console.Write(frame.GetMethod().ReflectedType.Name + "." + frame.GetMethod().Name); Console.ForegroundColor = ConsoleColor.Gray; Console.Write("] " + headerHead + " "); Console.ForegroundColor = headerColor; try { Console.Write(logText.Substring(0, headerLength)); } catch { Console.Write(logText); } Console.ForegroundColor = colorTwo; Console.WriteLine(logText.Substring(headerLength)); Console.ForegroundColor = ConsoleColor.Gray; bwait = false; } public static void WriteTrace(string logText) { } public enum logFlags { MehAction, BelowStandardAction, StandardAction, ImportantAction } } }