예제 #1
0
파일: LogWindow.cs 프로젝트: Klocman/MSREG
        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);
 }