示例#1
0
        public void Write(object source, LogPrio priority, string message)
        {
            switch (priority)
            {
                case LogPrio.Trace:
                case LogPrio.Debug:
                    m_log.DebugFormat("[WORLDINVENTORY]: {0}: {1}", source.ToString(), message);
                    break;
                case LogPrio.Error:
                    m_log.ErrorFormat("[WORLDINVENTORY]: {0}: {1}", source.ToString(), message);
                    break;
                case LogPrio.Info:
                    m_log.InfoFormat("[WORLDINVENTORY]: {0}: {1}", source.ToString(), message);
                    break;
                case LogPrio.Warning:
                    m_log.WarnFormat("[WORLDINVENTORY]: {0}: {1}", source.ToString(), message);
                    break;
                case LogPrio.Fatal:
                    m_log.FatalFormat("[WORLDINVENTORY]: {0}: FATAL! - {1}", source.ToString(), message);
                    break;
                default:
                    m_log.DebugFormat("[WORLDINVENTORY]: {0}: {1}", source.ToString(), message);
                    break;
            }

            return;
        }
示例#2
0
        /// <summary>
        /// Logwriters the specified source.
        /// </summary>
        /// <param name="source">object that wrote the logentry.</param>
        /// <param name="prio">Importance of the log message</param>
        /// <param name="message">The message.</param>
        public void Write(object source, LogPrio prio, string message)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(DateTime.Now.ToString());
            sb.Append(" ");
            sb.Append(prio.ToString().PadRight(10));
            sb.Append(" | ");
#if DEBUG
            StackTrace trace = new StackTrace();
            StackFrame[] frames = trace.GetFrames();
            int endFrame = frames.Length > 4 ? 4 : frames.Length;
            int startFrame = frames.Length > 0 ? 1 : 0;
            for (int i = startFrame; i < endFrame; ++i)
            {
                sb.Append(frames[i].GetMethod().Name);
                sb.Append(" -> ");
            }
#else
            sb.Append(System.Reflection.MethodBase.GetCurrentMethod().Name);
            sb.Append(" | ");
#endif
            sb.Append(message);

            Console.ForegroundColor = GetColor(prio);
            Console.WriteLine(sb.ToString());
            Console.ForegroundColor = ConsoleColor.Gray;
        }
示例#3
0
 public void Write(object source, LogPrio priority, string message)
 {
   string msg = source + ": " + message;
   ILogger logger = ServiceRegistration.Get<ILogger>();
   switch (priority)
   {
     case LogPrio.Trace:
       // Don't write trace messages (we don't support a trace level in MP - would have to map it to debug level)
       break;
     case LogPrio.Debug:
       logger.Debug(msg);
       break;
     case LogPrio.Info:
       logger.Info(msg);
       break;
     case LogPrio.Warning:
       logger.Warn(msg);
       break;
     case LogPrio.Error:
       logger.Error(msg);
       break;
     case LogPrio.Fatal:
       logger.Critical(msg);
       break;
   }
 }
示例#4
0
 public void Write(object source, LogPrio priority, string message)
 {
     if (!_textBox.InvokeRequired && !_textBox.IsDisposed)
     {
         _textBox.AppendText(".");
         //_textBox.AppendText(String.Format("{0}:{1} on {2}" + Environment.NewLine, DateTime.Now, message, source ?? "<null>"));
     }
     else
     {
         Action<object, LogPrio, string> marshal = Write;
         _textBox.BeginInvoke(marshal, source, priority, message);
     }
 }
 public void Write(object source, LogPrio prio, string message)
 {
     switch (prio)
     {
         case LogPrio.Trace:
         case LogPrio.Debug:
             Log.DebugFormat("{0}: {1}", source, message);
             break;
         case LogPrio.Info:
             Log.InfoFormat("{0}: {1}", source, message);
             break;
         case LogPrio.Warning:
             Log.WarnFormat("{0}: {1}", source, message);
             break;
         case LogPrio.Error:
             Log.ErrorFormat("{0}: {1}", source, message);
             break;
         case LogPrio.Fatal:
             Log.FatalFormat("{0}: {1}", source, message);
             break;
     }
 }
示例#6
0
 public void Write(object source, LogPrio prio, string message)
 {
     switch (prio)
     {
         case LogPrio.Trace:
             //Log.DebugFormat("{0}: {1}", source, message); // This logging is very noisy
             break;
         case LogPrio.Debug:
             //Log.DebugFormat("{0}: {1}", source, message); // This logging is slightly noisy
             break;
         case LogPrio.Info:
             Log.Info(source + ": " + message);
             break;
         case LogPrio.Warning:
             Log.WarnFormat("{0}: {1}", source, message);
             break;
         case LogPrio.Error:
             Log.ErrorFormat("{0}: {1}", source, message);
             break;
         case LogPrio.Fatal:
             Log.FatalFormat("{0}: {1}", source, message);
             break;
     }
 }
示例#7
0
		/// <summary>
		/// write an entry to the log file
		/// </summary>
		/// <param name="source">object that wrote the message</param>
		/// <param name="prio">importance of the message</param>
		/// <param name="message">log message</param>
		public void WriteLog(object source, LogPrio prio, string message)
		{
			LogWriter.Write(source, prio, message);
		}
示例#8
0
		/// <summary>
		/// write an entry to the log file
		/// </summary>
		/// <param name="prio">importance of the message</param>
		/// <param name="message">log message</param>
		protected virtual void WriteLog(LogPrio prio, string message)
		{
			LogWriter.Write(this, prio, message);
		}
        //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public void Write(object source, LogPrio priority, string message)
        {
            /*
            switch (priority)
            {
                case HttpServer.LogPrio.Debug:
                    m_log.DebugFormat("[{0}]: {1}", source.ToString(), message);
                    break;
                case HttpServer.LogPrio.Error:
                    m_log.ErrorFormat("[{0}]: {1}", source.ToString(), message);
                    break;
                case HttpServer.LogPrio.Info:
                    m_log.InfoFormat("[{0}]: {1}", source.ToString(), message);
                    break;
                case HttpServer.LogPrio.Warning:
                    m_log.WarnFormat("[{0}]: {1}", source.ToString(), message);
                    break;
                case HttpServer.LogPrio.Fatal:
                    m_log.ErrorFormat("[{0}]: FATAL! - {1}", source.ToString(), message);
                    break;
                default:
                    break;
            }
            */
            
            return;
        }
示例#10
0
 /// <summary>
 /// Writes everything to null
 /// </summary>
 /// <param name="source">object that wrote the log entry.</param>
 /// <param name="prio">Importance of the log message</param>
 /// <param name="message">The message.</param>
 public void Write(object source, LogPrio prio, string message)
 {}
示例#11
0
        /// <summary>
        /// Get color for the specified logprio
        /// </summary>
        /// <param name="prio">prio for the log entry</param>
        /// <returns>A <see cref="ConsoleColor"/> for the prio</returns>
        public static ConsoleColor GetColor(LogPrio prio)
        {
            switch (prio)
            {
                case LogPrio.Trace:
                    return ConsoleColor.DarkGray;
                case LogPrio.Debug:
                    return ConsoleColor.Gray;
                case LogPrio.Info:
                    return ConsoleColor.White;
                case LogPrio.Warning:
                    return ConsoleColor.DarkMagenta;
                case LogPrio.Error:
                    return ConsoleColor.Magenta;
                case LogPrio.Fatal:
                    return ConsoleColor.Red;
            }

            return ConsoleColor.Yellow;
        }
 public void Write(object source, LogPrio priority, string message)
 {
     traceLog(priority.ToString(), message);
 }
 /// <summary>
 /// Log something.
 /// </summary>
 /// <param name="prio">importance of log message</param>
 /// <param name="message">message</param>
 protected virtual void Write(LogPrio prio, string message)
 {
     _log.Write(this, prio, message);
 }
 public void Write(object source, LogPrio priority, string message)
 {
     Logger.Write(source, priority, message);
 }
        //#region Implementation of ILogWriter

        internal void Write(object source, LogPrio priority, string message)
        {
            WriteLine(priority + " " + message);
        }