public static void LogMessage( string msg, ELogflag flag, string title = "")
 {
     StringBuilder sb = new StringBuilder();
     string type = "";
     sb.Append("[" + EngineName + "]");
     switch (flag)
     {
         case ELogflag.LOG:
             sb.Append("[LOG]");
             type = "Log";
             break;
         case ELogflag.ENGINE:
             sb.Append("[ENGINE]");
             type = "Engine";
             break;
         case ELogflag.CRITICAL:
             sb.Append("[CRITICAL]");
             type = "Critical";
             break;
         case ELogflag.CUSTOM:
             title = title.ToUpper();
             sb.Append("[" + title + "]");
             type = "Custom";
             break;
         default:
             sb.Append("[UNKNOWN]");
             type = "Unknown";
             break;
     }
     sb.Append(msg);
     Console.WriteLine(sb.ToString());
     logdata.Add(sb.ToString());
     EventForwarder.Forward<LogEventArgs>(null, onLogRecieved, new LogEventArgs(title, type, msg));
 }
예제 #2
0
 private bool IsvalidFlag(ELogflag logflag)
 {
     switch (logflag)
     {
         case ELogflag.Error:
             return _errorEnabled;
             break;
         case ELogflag.Warning:
             return _warningEnabled;
             break;
         case ELogflag.Log:
             return _logEnabled;
             break;
         default:
             return false;
             break;
     }
 }
        // static object lockObj = new object();
        public static void LogMessage( string msg, string sender, ELogflag flag, string title)
        {
            StringBuilder sb = new StringBuilder();
            string type = "";

            DateTime dt = DateTime.Now;

            sb.Append("[" + dt.ToShortDateString() + "," + dt.ToLongTimeString() + "]");
            sb.Append("[" + sender + "]");
            switch (flag)
            {
                case ELogflag.LOG:
                    sb.Append("[LOG]");
                    type = "Log";
                    break;
                case ELogflag.WARNING:
                    sb.Append("[WARNING]");
                    type = "Warning";
                    break;
                case ELogflag.ERROR:
                    sb.Append("[ERROR]");
                    type = "Error";
                    break;
                case ELogflag.FATAL:
                    sb.Append("[FATAL]");
                    type = "FATAL";
                    break;
                case ELogflag.CUSTOM:
                    title = title.ToUpper();
                    sb.Append("[" + title + "]");
                    type = "Custom";
                    break;
                default:
                    sb.Append("[UNKNOWN]");
                    type = "Unknown";
                    break;
            }

            sb.Append(msg);
            Console.WriteLine(sb.ToString());
            logdata.Add(sb.ToString());

            EventForwarder.Forward<LogEventArgs>(null, onLogRecieved, new LogEventArgs(sender, dt, title, type, msg));
        }
예제 #4
0
 public void SetFlag(ELogflag flagLog)
 {
     FlagLogflag = flagLog;
     switch (flagLog)
     {
         case ELogflag.Error:
             ForegroundColor = ConsoleColor.Red;
             break;
         case ELogflag.Warning:
             ForegroundColor = ConsoleColor.Yellow;
             break;
         case ELogflag.Log:
             ForegroundColor = ConsoleColor.White;
             break;
         default:
             ForegroundColor = ConsoleColor.Gray;
             break;
     }
 }