示例#1
0
        private void AppLog_EntryAdded(LogEntry obj)
        {
            try
            {
                if (obj.Type >= _filterLevel
                    && (_filterSource == LogEntrySource.None || obj.SourceName == _filterSource)
                    && !logList.IsDisposed) // Disposed check last to minimize race conditions
                {
                    logList.SafeInvoke(() =>
                    {
                        logList.SuspendLayout();
                        logList.AppendText("\n");
                        logList.AppendText(obj.Date.ToLongTimeString(), Color.DarkGray);
                        logList.AppendText(" - ");
                        logList.AppendText(obj.Type.ToString().PadRight(8, ' '), AppLog.GetLogEntryTypeColor(obj.Type));
                        //logList.AppendText("\t");

                        string tempSourceName;
                        if (string.IsNullOrEmpty(obj.ExtraSourceInfo))
                            tempSourceName = string.Empty;
                        else
                            tempSourceName = ":" + obj.ExtraSourceInfo;

                        logList.AppendText(
                            string.Concat("(", obj.SourceName.ToString(), tempSourceName, ")").PadRight(18, ' '));
                        logList.AppendText(" - ");
                        logList.AppendText(obj.Message);
                        logList.ResumeLayout();
                    });
                }
            }
            catch (Exception)
            {
                /*Eat shit and die*/
            }
        }
示例#2
0
文件: AppLog.cs 项目: Klocman/MSREG
 private static void OnEntryAdded(LogEntry entry)
 {
     EntryAdded?.Invoke(entry);
 }
示例#3
0
文件: AppLog.cs 项目: Klocman/MSREG
 public static void Write(string message, LogEntryType type, LogEntrySource source, string extraSourceInfo)
 {
     var newEntry = new LogEntry(message, type, source, extraSourceInfo);
     lock (LogEntryList)
     {
         LogEntryList.Add(newEntry);
         TrimLogList();
     }
     OnEntryAdded(newEntry);
 }