/* Thor Server 2.0 Project - Codenamed "Stockholm" Copyright 2008 - 2009 Joe Hegarty This file is part of The Thor Server 2.0 Project - Codenamed "Stockholm". The Thor Server 2.0 Project - Codenamed "Stockholm" is free software: you can redistribute it and/or modify it under the terms of the Microsoft Public License The Thor Server Project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Microsoft Public License for more details. You should have received a copy of the Microsoft Public License along with The Thor Server Project. If not, see http://www.opensource.org/licenses/ms-pl.html */ using System; namespace StockholmLibrary.Util { //------------------------------------ public static class Logging { private static object _loggingLock = new object(); //------------------------------------ public enum ELogLevel { DEBUG, INFO, WARNING, ERROR } //********************************************** public static void WriteRaw(string text) { lock (_loggingLock) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(text); } } //********************************************** public static void LogEvent(string system, string message, ELogLevel level) { message = message.Replace("\r", "\r\n"); lock (_loggingLock) { Console.ForegroundColor = ConsoleColor.Blue; Console.Write("["); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write(DateTime.Now.ToString()); Console.ForegroundColor = ConsoleColor.Blue; Console.Write("] ["); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write(system); Console.ForegroundColor = ConsoleColor.Blue; Console.Write("] "); if (level == ELogLevel.DEBUG) { Console.ForegroundColor = ConsoleColor.DarkGreen; } else if (level == ELogLevel.INFO) { Console.ForegroundColor = ConsoleColor.Green; } else if (level == ELogLevel.WARNING) { Console.ForegroundColor = ConsoleColor.DarkRed; } else if (level == ELogLevel.ERROR) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine(message); } } } }