private void WriteLocalText(string text, Level level) { MainConsole.TriggerLog(level.Name, text); string logtext = ""; if (text != "") { int CurrentLine = 0; string[] Lines = text.Split(new char[2] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); //This exists so that we don't have issues with multiline stuff, since something is messed up with the Regex foreach (string line in Lines) { string[] split = line.Split(new string[2] { "[", "]" }, StringSplitOptions.None); int currentPos = 0; int boxNum = 0; foreach (string s in split) { if (line[currentPos] == '[') { if (level == Level.Alert) { WriteColorText(ConsoleColor.Magenta, "["); } else if (level.Value >= Level.Fatal.Value) { WriteColorText(ConsoleColor.White, "["); } else if (level.Value >= Level.Error.Value) { WriteColorText(ConsoleColor.Red, "["); } else if (level.Value >= Level.Warn.Value) { WriteColorText(ConsoleColor.Yellow, "["); } else { WriteColorText(ConsoleColor.Gray, "["); } boxNum++; currentPos++; } else if (line[currentPos] == ']') { if (level == Level.Error) { WriteColorText(ConsoleColor.Red, "]"); } else if (level == Level.Warn) { WriteColorText(ConsoleColor.Yellow, "]"); } else if (level == Level.Alert) { WriteColorText(ConsoleColor.Magenta, "]"); } else { WriteColorText(ConsoleColor.Gray, "]"); } boxNum--; currentPos++; } if (boxNum == 0) { if (level == Level.Error) { WriteColorText(ConsoleColor.Red, s); } else if (level == Level.Warn) { WriteColorText(ConsoleColor.Yellow, s); } else if (level == Level.Alert) { WriteColorText(ConsoleColor.Magenta, s); } else { WriteColorText(ConsoleColor.Gray, s); } } else //We're in a box { WriteColorText(DeriveColor(s), s); } currentPos += s.Length; //Include the extra 1 for the [ or ] } CurrentLine++; if (Lines.Length - CurrentLine != 0) { Console.WriteLine(); } logtext += line; } } Console.WriteLine(); }
public virtual void Output(string text, string lvl) { MainConsole.TriggerLog(lvl, text); Console.WriteLine(text); }