| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | 
							- using Aitex.Core.RT.SCCore;
 
- using System;
 
- using System.Linq;
 
- using System.Diagnostics;
 
- using MECF.Framework.Common.Equipment;
 
- using System.Text;
 
- using Aitex.Core.RT.Event;
 
- namespace Aitex.Core.RT.Log
 
- {
 
-     public static class LOG
 
-     {
 
-         public enum Level
 
-         {
 
-             Undefine,
 
-             Debug,
 
-             Info,
 
-             Warning,
 
-             Error         
 
-         }
 
-         public static ICommonLog InnerLogger { set;  private get; }
 
-         private static void Debug(string message)
 
-         {
 
-             if (InnerLogger != null && SC.GetValue<bool>("System.IsOpenDebugLog") ==true)
 
-                 
 
-                 InnerLogger.Debug(message);
 
-         }
 
-         private static void Info(string message)
 
-         {
 
-             if (InnerLogger != null)
 
-                 InnerLogger.Info(message);
 
-         }
 
-         private static void Warning(string message)
 
-         {
 
-             if (InnerLogger != null)
 
-                 InnerLogger.Warning(message);
 
-         }
 
-         private static void Error(string message)
 
-         {
 
-             if (InnerLogger != null)
 
-                 InnerLogger.Error(message);
 
-         }
 
-         static string GetFormatStackFrameInfo(Exception ex, int traceLevel = 2)
 
-         {
 
-             StackFrame sf = new StackTrace(true).GetFrame(traceLevel + 1);
 
-             string pathFile = sf.GetFileName();
 
-             string file = string.IsNullOrEmpty(pathFile) ? "" : pathFile.Substring(pathFile.LastIndexOf('\\') + 1);
 
-             return $"{ex.Message}\r\n{file}\tLine {sf.GetFileLineNumber()}\t{sf.GetMethod().Name}()";
 
-         }
 
-         public static void Write(eEvent id, string module, params string[] values)
 
-         {
 
-             Write(id, ModuleHelper.Converter(module), values);
 
-         }
 
-         public static void WriteExeption(Exception ex)
 
-         {
 
-            Write(eEvent.ERR_EXCEPTION, ModuleName.System, GetFormatStackFrameInfo(ex));
 
-         }
 
-         public static void WriteExeption(string prefix, Exception ex)
 
-         {
 
-             Write(eEvent.ERR_EXCEPTION, ModuleName.System, prefix + GetFormatStackFrameInfo(ex));
 
-         }
 
-         public static void WriteSingeLine(eEvent id, ModuleName module, string log)
 
-         {
 
-             string newLog = log.Replace("\r", "<回车>");
 
-             newLog = newLog.Replace("\n", "<换行>");
 
-             Write(id, module, newLog);
 
-         }
 
-         public static void Write(eEvent id, ModuleName module, params string[] values)
 
-         {
 
-            var logItem= LogDefineManager.LogItems?.Where(x => x.Id == id).FirstOrDefault();
 
-             if (logItem != null)
 
-             {
 
-                 var item1 = logItem.Id;
 
-                 var item2 = string.Format(logItem.GlobalDescription_zh, values);
 
-                 var item3 = module.ToString();
 
-                 StringBuilder text = new StringBuilder();
 
-                 text.Append(((int)item1).ToString().PadLeft(8));
 
-                 text.Append(item3.PadLeft(12));
 
-                 text.Append("    ");
 
-                 text.Append(string.Format(logItem.GlobalDescription_zh, values));              
 
-                 string message = text.ToString();
 
-                 //test += (message + "\r\n");
 
-                 Level level = Level.Undefine;
 
-                 Enum.TryParse<Level>(logItem.Level, out level);
 
-                 switch (level)
 
-                 {
 
-                     case Level.Debug:
 
-                         Debug(message);
 
-                         break;
 
-                     case Level.Info:
 
-                          //EV.PostInfoLog(module.ToString(), id, string.Format(((int)item1).ToString().PadRight(6)+ logItem.GlobalDescription_zh, values));
 
-                         EV.PostInfoLog(module.ToString(), id, string.Format(logItem.GlobalDescription_zh, values));
 
-                         Info(message);
 
-                         break;
 
-                     case Level.Warning:
 
-                         EV.PostWarningLog(module.ToString(),id, string.Format(logItem.GlobalDescription_zh, values));
 
-                         Warning(message);
 
-                         break;
 
-                     case Level.Error:
 
-                         EV.PostAlarmLog(module.ToString(),id, string.Format(logItem.GlobalDescription_zh, values));
 
-                         Error(message);
 
-                         break;
 
-                     default:
 
-                         break;
 
-                 }
 
-             }
 
-         }           
 
-     }
 
- }
 
 
  |