Ejemplo n.º 1
0
        /// <summary>
        /// 是否写文件日志
        /// </summary>
        /// <param name="strSystemMark"></param>
        /// <returns></returns>
        protected bool IsWriteFile(string strSystemMark, ELogType eLogType)
        {
            if (null == this.mConfig)
                return true;

            return this.mConfig.IsWriteFile(strSystemMark, eLogType);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改开关
        /// </summary>
        /// <param name="eLogType"></param>
        /// <param name="bSwitch"></param>
        public void ChangeFileSwitch(ELogType eLogType, bool bSwitch)
        {
            if (!this.mFileSwitch.ContainsKey(eLogType))
                return;

            this.mFileSwitch[eLogType] = bSwitch;
        }
Ejemplo n.º 3
0
        public LogProcessor(string name, string group)
        {
            string path = Path.Combine(Path.Combine("log", fFolderMonth), group);
            Directory.CreateDirectory(path);
            fLocation = Path.Combine(path, name);

            //Allow us to set both kLogLeveXXX and xxx as log levels...
            //This is mostly so configuration files will look nicer :)
            string loglev = Configuration.GetString("log_level", "kLogWarning");
            if (Enum.IsDefined(typeof(ELogType), loglev))
                fMinLevel = (ELogType)Enum.Parse(typeof(ELogType), loglev);
            else if (loglev.ToLower() == "error")
                fMinLevel = ELogType.kLogError;
            else if (loglev.ToLower() == "warn")
                fMinLevel = ELogType.kLogWarning;
            else if (loglev.ToLower() == "info")
                fMinLevel = ELogType.kLogInfo;
            else if (loglev.ToLower() == "debug")
                fMinLevel = ELogType.kLogDebug;
            else if (loglev.ToLower() == "verbose")
                fMinLevel = ELogType.kLogVerbose;
            else {
                fMinLevel = ELogType.kLogWarning;
                Error(String.Format("MUd.conf has invalid log_level \"{0}\"", loglev));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 把所有的文件开关
        /// </summary>
        /// <param name="eLogType"></param>
        /// <param name="bSwitch"></param>
        public void ChangeAllFileSwitch(ELogType eLogType, bool bSwitch)
        {
            if (this.mConfig == null)
                return;

            this.mConfig.ChangeAllFileSwitch(eLogType, bSwitch);
        }
Ejemplo n.º 5
0
 public void Log(ELogType t, string format, params object[] args)
 {
     string strData = string.Format(format, args);
     string strAppend = string.Format("[{0}] {1}", t.ToString(), strData + Environment.NewLine);
     int oldLen = LogRichTextBox.Text.Length;
     LogRichTextBox.AppendText(strAppend);
     LogRichTextBox.Select(oldLen, strAppend.Length);
     switch (t)
     {
         case ELogType.INFO:
         case ELogType.DEBUG:
             LogRichTextBox.SelectionColor = Color.Black;
             break;
         case ELogType.ERROR:
         case ELogType.FATAL:
             LogRichTextBox.SelectionColor = Color.Red;
             break;
         case ELogType.WARN:
             LogRichTextBox.SelectionColor = Color.Blue;
             break;
         default:
             break;
     }
     LogRichTextBox.Select(LogRichTextBox.Text.Length, 0);
     LogRichTextBox.SelectionColor = Color.Black;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 是否打开了开关
        /// </summary>
        /// <param name="eLogType"></param>
        /// <returns></returns>
        public bool IsConsoleSwitch(ELogType eLogType)
        {
            if (!this.mConsoleSwitch.ContainsKey(eLogType))
                return true;

            return this.mConsoleSwitch[eLogType];
        }
Ejemplo n.º 7
0
    protected static string TypeLog(string sIn, ELogType eType)
    {
#if UNITY_EDITOR
        int iType = (int)eType;
        string sOut = string.Format("<color=#{0}>{1}</color><b>{2}</b>", colors[iType], prefixstring[iType], sIn);
        return sOut;
#else
        return sIn;
#endif
    }
Ejemplo n.º 8
0
        public static void Create(string pMessage, ELogType pType, ELogCategory pCategory)
        {
            if (UnityEngine.Debug.isDebugBuild && !string.IsNullOrEmpty(pMessage))
            {
                var creator = new LogCreator();
                var entry = creator.Create(pMessage, pType, pCategory);

                ShowLog(entry);

                ServiceManager.Instance.GetService<LogService>().AddLogEntry(entry);
            }
        }
Ejemplo n.º 9
0
        internal LogEntry Create(string pMessage, ELogType pType, ELogCategory pCategory)
        {
            mEntry = new LogEntry()
            {
                LogType = pType,
                Message = pMessage,
                Time = DateTime.Now,
                Category = pCategory
            };

            HandleStackTrace();

            return mEntry;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="logType"></param>
 /// <param name="strContent"></param>
 public LogContent(ELogType logType, string strSystemMark, string strContent)
 {
     LogType = logType;
     Content = strContent;
     SystemMark = strSystemMark;
 }
Ejemplo n.º 11
0
 private string LogTypeName(ELogType type)
 {
     switch (type)
     {
         case ELogType.Critical:
             return "Critical";
         case ELogType.Error:
             return "Error";
         case ELogType.Warning:
             return "Warning";
         case ELogType.Info:
             return "Info";
         case ELogType.Verbose:
             return "Verbose";
         case ELogType.Debug:
             return "Debug";
         default:
             return string.Format("<value={0}>", (int) type);
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 修改控制台日志开关
        /// </summary>
        /// <param name="strSystemMark"></param>
        /// <param name="eLogType"></param>
        /// <param name="bSwitch"></param>
        public void ChangeConsoleSwitch(string strSystemMark, ELogType eLogType, bool bSwitch)
        {
            if (this.mConfig == null)
                return;

            this.mConfig.ChangeConsoleSwitch(strSystemMark, eLogType, bSwitch);
        }
Ejemplo n.º 13
0
        public void WriteLine(string line, ELogType level)
        {
            if (level <= fMinLevel) {
                string levelstr = "[UNK] ";
                switch (level) {
                    case ELogType.kLogDebug:
                        levelstr = "[DBG] ";
                        break;
                    case ELogType.kLogError:
                        levelstr = "[ERR] ";
                        break;
                    case ELogType.kLogInfo:
                        levelstr = "[INF] ";
                        break;
                    case ELogType.kLogVerbose:
                        levelstr = "[VBS] ";
                        break;
                    case ELogType.kLogWarning:
                        levelstr = "[WRN] ";
                        break;
                }

                IWriteLine(levelstr + line);
            }
        }
Ejemplo n.º 14
0
 public void DumpToLog(byte[] dump, string msg, ELogType level)
 {
     if (level <= fMinLevel) {
         WriteLine(msg, level);
         DumpToLog(BitConverter.ToString(dump).Replace('-', ' '));
     }
 }
Ejemplo n.º 15
0
 public void DumpToLog(string dump, string msg, ELogType level)
 {
     if (level <= fMinLevel) {
         WriteLine(msg, level);
         DumpToLog(dump);
     }
 }
Ejemplo n.º 16
0
 public LogEventArgs(ELogType type, string message)
 {
     EventTime = DateTime.Now;
     Type = type;
     Message = message;
 }
Ejemplo n.º 17
0
 internal ErrorSeverityAttribute(ELogType pLogType)
 {
     LogType = pLogType;
 }
Ejemplo n.º 18
0
 public void Log(ELogType type, string message)
 {
     WriteEvent(new LogEventArgs(type, message));
 }
Ejemplo n.º 19
0
 public override void log(ELogType type, string message)
 {
     if (type < writeLevel) return;
     if (onLog != null) onLog(type, message);
 }
Ejemplo n.º 20
0
 public String format(ELogType type, String message)
 {
     String data = default_format;
     data = data.Replace("{message}", message);
     data = data.Replace("{level}", type.ToString());
     data = data.Replace("{time}", String.Format("{0:HH:mm:ss:fff}",DateTime.Now));
     return data;
 }
Ejemplo n.º 21
0
 public static void Create(string pMessage, ELogType pType)
 {
     Create(pMessage, pType, ELogCategory.NONE);
 }
Ejemplo n.º 22
0
 private static void ProcessLog(ELogType type, string message,bool rcon = true)
 {
     AsyncLoggerQueue.Current.Enqueue(new LogEntry() { Severity = type, Message = message, RCON = rcon });
 }
Ejemplo n.º 23
0
        private static void ProcessInternalLog(ELogType type, string message, bool doWriteToConsole = true)
        {
            if (doWriteToConsole)
            {
                if (type == ELogType.Error || type == ELogType.Exception)
                {

                    // Debug.LogError(message);
                    writeToConsole(message, ConsoleColor.Red);
                }
                else if (type == ELogType.Warning)
                {
                    //  Debug.LogWarning(message);
                    writeToConsole(message, ConsoleColor.Yellow);
                }
                else
                {
                    //Debug.Log(message);
                    writeToConsole(message, ConsoleColor.White);
                }
                ProcessLog(type, message);
            }
        }
Ejemplo n.º 24
0
        // 输出日志
        public static void WriteLog(ELogType type, string msg)
        {
            using (StreamWriter souts = new StreamWriter(LogFile, true, Encoding.Unicode))
            {
                try
                {
                    switch (type)
                    {
                        case ELogType.Info:
                            {
                                souts.WriteLine(string.Format("[Info]: {0}", msg));
                            }
                            break;
                        case ELogType.Warning:
                            {
                                souts.WriteLine(string.Format("[Warning]: {0}", msg));
                            }
                            break;
                        case ELogType.Error:
                            {
                                souts.WriteLine(string.Format("[Info]: {0}", msg));
                            }
                            break;
                    }
                }
                catch (Exception)
                {

                }
            }
        }
Ejemplo n.º 25
0
 public void log(ELogType type, String message)
 {
     foreach (ILogger logger in loggers) {
         logger.log(type, message);
     }
 }
Ejemplo n.º 26
0
 public void DumpToLog(string dump, ELogType level)
 {
     if (level <= fMinLevel) DumpToLog(dump);
 }
Ejemplo n.º 27
0
 public override void log(ELogType type, string message)
 {
     if (type < writeLevel) return;
     Console.WriteLine(base.formatter.format(type, message));
 }
Ejemplo n.º 28
0
 public static void updateLog(string txt, ELogLevel level, ELogType whom)
 {
     if (level == ELogLevel.Debug && (whom != ELogType.SpeechRecog && whom != ELogType.Net)) return;
     if (Form1.server.txtLog.InvokeRequired)
     {
         Form1.updateLog_Callback d = new updateLog_Callback(updateLog);
         Form1.server.Invoke(d, new object[] { txt, level, whom });
     }
     else
     {
         System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString("yyMMdd HH:mm:ss: [") +
             level.ToString() + "] " +
             txt);
         Form1.server.txtLog.AppendText(DateTime.Now.ToString("yyMMdd HH:mm:ss: [") +
             level.ToString()+"] " +
             txt + "\n");
     }
 }
Ejemplo n.º 29
0
 public abstract void log(ELogType type, String message);
Ejemplo n.º 30
0
 public void Log(ELogType type, string format, params object[] args)
 {
     Log(type, (format == null) ? null : string.Format(format, args));
 }