using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SuperSocket.SocketBase.Logging { /// /// Console Log /// public class ConsoleLog : ILog { private string m_Name; private const string m_MessageTemplate = "{0}-{1}: {2}"; private const string m_Debug = "DEBUG"; private const string m_Error = "ERROR"; private const string m_Fatal = "FATAL"; private const string m_Info = "INFO"; private const string m_Warn = "WARN"; /// /// Initializes a new instance of the class. /// /// The name. public ConsoleLog(string name) { m_Name = name; } /// /// Gets a value indicating whether this instance is debug enabled. /// /// /// true if this instance is debug enabled; otherwise, false. /// public bool IsDebugEnabled { get { return true; } } /// /// Gets a value indicating whether this instance is error enabled. /// /// /// true if this instance is error enabled; otherwise, false. /// public bool IsErrorEnabled { get { return true; } } /// /// Gets a value indicating whether this instance is fatal enabled. /// /// /// true if this instance is fatal enabled; otherwise, false. /// public bool IsFatalEnabled { get { return true; } } /// /// Gets a value indicating whether this instance is info enabled. /// /// /// true if this instance is info enabled; otherwise, false. /// public bool IsInfoEnabled { get { return true; } } /// /// Gets a value indicating whether this instance is warn enabled. /// /// /// true if this instance is warn enabled; otherwise, false. /// public bool IsWarnEnabled { get { return true; } } /// /// Logs the debug message. /// /// The message. public void Debug(object message) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, message); } /// /// Logs the debug message. /// /// The message. /// The exception. public void Debug(object message, Exception exception) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, message + Environment.NewLine + exception.Message + exception.StackTrace); } /// /// Logs the debug message. /// /// The format. /// The arg0. public void DebugFormat(string format, object arg0) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, string.Format(format, arg0)); } /// /// Logs the debug message. /// /// The format. /// The args. public void DebugFormat(string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, string.Format(format, args)); } /// /// Logs the debug message. /// /// The provider. /// The format. /// The args. public void DebugFormat(IFormatProvider provider, string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, string.Format(provider, format, args)); } /// /// Logs the debug message. /// /// The format. /// The arg0. /// The arg1. public void DebugFormat(string format, object arg0, object arg1) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, string.Format(format, arg0, arg1)); } /// /// Logs the debug message. /// /// The format. /// The arg0. /// The arg1. /// The arg2. public void DebugFormat(string format, object arg0, object arg1, object arg2) { Console.WriteLine(m_MessageTemplate, m_Name, m_Debug, string.Format(format, arg0, arg1, arg2)); } /// /// Logs the error message. /// /// The message. public void Error(object message) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, message); } /// /// Logs the error message. /// /// The message. /// The exception. public void Error(object message, Exception exception) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, message + Environment.NewLine + exception.Message + exception.StackTrace); } /// /// Logs the error message. /// /// The format. /// The arg0. public void ErrorFormat(string format, object arg0) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, string.Format(format, arg0)); } /// /// Logs the error message. /// /// The format. /// The args. public void ErrorFormat(string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, string.Format(format, args)); } /// /// Logs the error message. /// /// The provider. /// The format. /// The args. public void ErrorFormat(IFormatProvider provider, string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, string.Format(provider, format, args)); } /// /// Logs the error message. /// /// The format. /// The arg0. /// The arg1. public void ErrorFormat(string format, object arg0, object arg1) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, string.Format(format, arg0, arg1)); } /// /// Logs the error message. /// /// The format. /// The arg0. /// The arg1. /// The arg2. public void ErrorFormat(string format, object arg0, object arg1, object arg2) { Console.WriteLine(m_MessageTemplate, m_Name, m_Error, string.Format(format, arg0, arg2)); } /// /// Logs the fatal error message. /// /// The message. public void Fatal(object message) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, message); } /// /// Logs the fatal error message. /// /// The message. /// The exception. public void Fatal(object message, Exception exception) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, message + Environment.NewLine + exception.Message + exception.StackTrace); } /// /// Logs the fatal error message. /// /// The format. /// The arg0. public void FatalFormat(string format, object arg0) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, string.Format(format, arg0)); } /// /// Logs the fatal error message. /// /// The format. /// The args. public void FatalFormat(string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, string.Format(format, args)); } /// /// Logs the fatal error message. /// /// The provider. /// The format. /// The args. public void FatalFormat(IFormatProvider provider, string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, string.Format(provider, format, args)); } /// /// Logs the fatal error message. /// /// The format. /// The arg0. /// The arg1. public void FatalFormat(string format, object arg0, object arg1) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, string.Format(format, arg0, arg1)); } /// /// Logs the fatal error message. /// /// The format. /// The arg0. /// The arg1. /// The arg2. public void FatalFormat(string format, object arg0, object arg1, object arg2) { Console.WriteLine(m_MessageTemplate, m_Name, m_Fatal, string.Format(format, arg0, arg1, arg2)); } /// /// Logs the info message. /// /// The message. public void Info(object message) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, message); } /// /// Logs the info message. /// /// The message. /// The exception. public void Info(object message, Exception exception) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, message + Environment.NewLine + exception.Message + exception.StackTrace); } /// /// Logs the info message. /// /// The format. /// The arg0. public void InfoFormat(string format, object arg0) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, string.Format(format, arg0)); } /// /// Logs the info message. /// /// The format. /// The args. public void InfoFormat(string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, string.Format(format, args)); } /// /// Logs the info message. /// /// The provider. /// The format. /// The args. public void InfoFormat(IFormatProvider provider, string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, string.Format(provider, format, args)); } /// /// Logs the info message. /// /// The format. /// The arg0. /// The arg1. public void InfoFormat(string format, object arg0, object arg1) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, string.Format(format, arg0, arg1)); } /// /// Logs the info message. /// /// The format. /// The arg0. /// The arg1. /// The arg2. public void InfoFormat(string format, object arg0, object arg1, object arg2) { Console.WriteLine(m_MessageTemplate, m_Name, m_Info, string.Format(format, arg0, arg1, arg2)); } /// /// Logs the warning message. /// /// The message. public void Warn(object message) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, message); } /// /// Logs the warning message. /// /// The message. /// The exception. public void Warn(object message, Exception exception) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, message + Environment.NewLine + exception.Message + exception.StackTrace); } /// /// Logs the warning message. /// /// The format. /// The arg0. public void WarnFormat(string format, object arg0) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, string.Format(format, arg0)); } /// /// Logs the warning message. /// /// The format. /// The args. public void WarnFormat(string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, string.Format(format, args)); } /// /// Logs the warning message. /// /// The provider. /// The format. /// The args. public void WarnFormat(IFormatProvider provider, string format, params object[] args) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, string.Format(provider, format, args)); } /// /// Logs the warning message. /// /// The format. /// The arg0. /// The arg1. public void WarnFormat(string format, object arg0, object arg1) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, string.Format(format, arg0, arg1)); } /// /// Logs the warning message. /// /// The format. /// The arg0. /// The arg1. /// The arg2. public void WarnFormat(string format, object arg0, object arg1, object arg2) { Console.WriteLine(m_MessageTemplate, m_Name, m_Warn, string.Format(format, arg0, arg1, arg2)); } } }