Exemplo n.º 1
0
        public LogMessageItem(LoggerItem parent, LogMessage logMsg)
        {
            Parent  = parent;
            Message = logMsg;

            var parentName = Parent.Name;

            if ((Parent.Name == logMsg.ThreadName) && (Parent.Parent != null))
            {
                parentName = Parent.Parent.Name;
            }

            // Create List View Item
            Item = new ListViewItem(logMsg.TimeStamp.ToString(UserSettings.Instance.TimeStampFormatString));
            Item.SubItems.Add(logMsg.Level.Name);
            Item.SubItems.Add(parentName);
            Item.SubItems.Add(logMsg.ThreadName);

            var msg = logMsg.Message.Replace("\r\n", " ");

            msg = msg.Replace("\n", " ");
            Item.SubItems.Add(msg);
            Item.ToolTipText = msg;

            Item.ForeColor = logMsg.Level.Color;
            Item.Tag       = this;
        }
Exemplo n.º 2
0
        public void Initialize(ILoggerView loggerView, ListView logListView)
        {
            // Root Logger
            RootLoggerItem = LoggerItem.CreateRootLoggerItem("Root", loggerView, logListView);

            // Quick Access Logger Collection
            _fullPathLoggers = new Dictionary <string, LoggerItem>();
        }
Exemplo n.º 3
0
        public static LoggerItem CreateRootLoggerItem(string name, ILoggerView loggerView, ListView logListView)
        {
            var logger = new LoggerItem();

            logger.Name         = name;
            logger._logListView = logListView;

            // Tree Node
            logger.LoggerView = loggerView.AddNew(name, logger);

            return(logger);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the new logger view as a child of the current view and returns the new view.
        /// </summary>
        /// <param name="text">The text to initialize the view with.</param>
        /// <param name="logger">The logger that this instance is a view of.</param>
        /// <returns></returns>
        public ILoggerView AddNew(string text, LoggerItem logger)
        {
            // Creating a new node.
            TreeNode node = _isRoot ? _treeView.Nodes.Add(text, text) : _node.Nodes.Add(text, text);

            node.Tag = logger;
            node.Checked = true;

            node.EnsureVisible();

            return new TreeViewLoggerView(_treeView, node);
        }
Exemplo n.º 5
0
        private static LoggerItem CreateLoggerItem(string name, string fullName, LoggerItem parent)
        {
            if (parent == null)
            {
                throw new ArgumentNullException();
            }

            // Creating the logger item.
            var logger = new LoggerItem();

            logger.Name     = name;
            logger.FullName = fullName;
            logger.Parent   = parent;


            logger._logListView = logger.Parent._logListView;

            // Adding the logger as a child of the parent logger.
            logger.Parent.Loggers.Add(name, logger);

            // Creating a child logger view and saving it in the new logger.
            logger.LoggerView = parent.LoggerView.AddNew(name, logger);

            if (UserSettings.Instance.RecursivlyEnableLoggers)
            {
                logger._enabled           = parent.Enabled;
                logger.LoggerView.Enabled = parent.LoggerView.Enabled;
            }

            // Group
            if (UserSettings.Instance.GroupLogMessages)
            {
                logger.Group = new ListViewGroup(fullName);
                logger._logListView.Groups.Add(logger.Group);
            }

            return(logger);
        }
Exemplo n.º 6
0
 private void RemovedLogMsgsHighlight()
 {
     if (_lastHighlightedLogMsgs != null)
       {
     _lastHighlightedLogMsgs.HighlightLogMessages = false;
     _lastHighlightedLogMsgs = null;
       }
 }
Exemplo n.º 7
0
 private void RemovedLoggerHighlight()
 {
     if (_lastHighlightedLogger != null)
       {
     _lastHighlightedLogger.Highlight = false;
     _lastHighlightedLogger = null;
       }
 }
Exemplo n.º 8
0
        private void logListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            RemovedLoggerHighlight();

              LogMessageItem logMsgItem = null;
              if (logListView.SelectedItems.Count > 0)
            logMsgItem = logListView.SelectedItems[0].Tag as LogMessageItem;

              SetLogMessageDetail(logMsgItem);

              // Highlight Logger in the Tree View
              if ((logMsgItem != null) && (UserSettings.Instance.HighlightLogger))
              {
            logMsgItem.Parent.Highlight = true;
            _lastHighlightedLogger = logMsgItem.Parent;
              }
        }
Exemplo n.º 9
0
        private void loggerTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if ((e.Node == null) || ((e.Node.Tag as LoggerItem) == null))
            return;

              if (UserSettings.Instance.HighlightLogMessages)
              {
            _lastHighlightedLogMsgs = e.Node.Tag as LoggerItem;
            _lastHighlightedLogMsgs.HighlightLogMessages = true;
              }
        }
Exemplo n.º 10
0
        public LogMessageItem(LoggerItem parent, LogMessage logMsg)
        {
            Parent  = parent;
            Message = logMsg;

            // Create List View Item
            var    items   = new ListViewItem.ListViewSubItem[UserSettings.Instance.ColumnConfiguration.Length];
            string toolTip = string.Empty;

            //Add all the Standard Fields to the ListViewItem
            for (int i = 0; i < UserSettings.Instance.ColumnConfiguration.Length; i++)
            {
                items[i] = new ListViewItem.ListViewSubItem();

                switch (UserSettings.Instance.ColumnConfiguration[i].Field)
                {
                case LogMessageField.SequenceNr:
                    items[i].Text = logMsg.SequenceNr.ToString();
                    break;

                case LogMessageField.LoggerName:
                    items[i].Text = logMsg.LoggerName;
                    break;

                case LogMessageField.RootLoggerName:
                    items[i].Text = logMsg.RootLoggerName;
                    break;

                case LogMessageField.Level:
                    items[i].Text = logMsg.Level.Name;
                    break;

                case LogMessageField.Message:
                    string msg = logMsg.Message.Replace("\r\n", " ");
                    msg           = msg.Replace("\n", " ");
                    items[i].Text = msg;
                    toolTip       = msg;
                    break;

                case LogMessageField.ThreadName:
                    items[i].Text = logMsg.ThreadName;
                    break;

                case LogMessageField.TimeStamp:
                    items[i].Text = logMsg.TimeStamp.ToString(UserSettings.Instance.TimeStampFormatString);
                    break;

                case LogMessageField.Exception:
                    string exception = logMsg.ExceptionString.Replace("\r\n", " ");
                    exception     = exception.Replace("\n", " ");
                    items[i].Text = exception;
                    break;

                case LogMessageField.CallSiteClass:
                    items[i].Text = logMsg.CallSiteClass;
                    break;

                case LogMessageField.CallSiteMethod:
                    items[i].Text = logMsg.CallSiteMethod;
                    break;

                case LogMessageField.SourceFileName:
                    items[i].Text = logMsg.SourceFileName;
                    break;

                case LogMessageField.SourceFileLineNr:
                    items[i].Text = logMsg.SourceFileLineNr.ToString();
                    break;

                case LogMessageField.Properties:
                    break;
                }
            }

            //Add all the Properties in the Message to the ListViewItem
            foreach (var property in logMsg.Properties)
            {
                string propertyKey = property.Key;
                if (UserSettings.Instance.ColumnProperties.ContainsKey(propertyKey))
                {
                    int propertyColumnNumber = UserSettings.Instance.ColumnProperties[propertyKey];
                    if (propertyColumnNumber < items.Length)
                    {
                        items[propertyColumnNumber].Text = property.Value;
                    }
                }
            }

            Item = new ListViewItem(items, 0)
            {
                ToolTipText = toolTip, ForeColor = logMsg.Level.Color, Tag = this
            };
        }
Exemplo n.º 11
0
        public LogMessageItem(LoggerItem parent, LogMessage logMsg)
        {
            Parent = parent;
            Message = logMsg;

            string parentName = Parent.Name;
            if ((Parent.Name == logMsg.ThreadName) && (Parent.Parent != null))
                parentName = Parent.Parent.Name;

            // Create List View Item
            var items = new ListViewItem.ListViewSubItem[UserSettings.Instance.ColumnConfiguration.Length];
            string toolTip = string.Empty;

            //Add all the Standard Fields to the ListViewItem
            for (int i=0; i<UserSettings.Instance.ColumnConfiguration.Length; i++)
            {
                items[i] = new ListViewItem.ListViewSubItem();
                var fieldType = UserSettings.Instance.ColumnConfiguration[i];

                switch (fieldType.Field)
                {
                    case LogMessageField.SequenceNr:
                        items[i].Text = logMsg.SequenceNr.ToString();
                        break;
                    case LogMessageField.LoggerName:
                        items[i].Text = logMsg.LoggerName;
                        break;
                    case LogMessageField.Level:
                        items[i].Text = logMsg.Level.Name;
                        break;
                    case LogMessageField.Message:
                        string msg = logMsg.Message.Replace("\r\n", " ");
                        msg = msg.Replace("\n", " ");
                        items[i].Text = msg;
                        toolTip = msg;
                        break;
                    case LogMessageField.ThreadName:
                        items[i].Text = logMsg.ThreadName;
                        break;
                    case LogMessageField.TimeStamp:
                        items[i].Text = logMsg.TimeStamp.ToString(UserSettings.Instance.TimeStampFormatString);
                        break;
                    case LogMessageField.Exception:
                        string exception = logMsg.ExceptionString.Replace("\r\n", " ");
                        exception = exception.Replace("\n", " ");
                        items[i].Text = exception;
                        break;
                    case LogMessageField.CallSiteClass:
                        items[i].Text = logMsg.CallSiteClass;
                        break;
                    case LogMessageField.CallSiteMethod:
                        items[i].Text = logMsg.CallSiteMethod;
                        break;
                    case LogMessageField.SourceFileName:
                        items[i].Text = logMsg.SourceFileName;
                        break;
                    case LogMessageField.SourceFileLineNr:
                        items[i].Text = logMsg.SourceFileLineNr.ToString();
                        break;
                    case LogMessageField.Properties:
                        break;
                }
            }

            //Add all the Properties in the Message to the ListViewItem
            foreach (var property in logMsg.Properties)
            {
                string propertyKey = property.Key;
                if (UserSettings.Instance.ColumnProperties.ContainsKey(propertyKey))
                {
                    int propertyColumnNumber = UserSettings.Instance.ColumnProperties[propertyKey];
                    if(propertyColumnNumber < items.Length)
                    {
                        items[propertyColumnNumber].Text = property.Value;
                    }
                }
            }

            Item = new ListViewItem(items, 0) {ToolTipText = toolTip, ForeColor = logMsg.Level.Color, Tag = this};
        }
Exemplo n.º 12
0
        public void Initialize(ILoggerView loggerView, ListView logListView)
        {
            // Root Logger
            _rootLoggerItem = LoggerItem.CreateRootLoggerItem("Root", loggerView, logListView);

            // Quick Access Logger Collection
            _fullPathLoggers = new Dictionary<string, LoggerItem>();
        }
Exemplo n.º 13
0
        private static LoggerItem CreateLoggerItem(string name, string fullName, LoggerItem parent)
        {
            if (parent == null)
                throw new ArgumentNullException();

            // Creating the logger item.
            LoggerItem logger = new LoggerItem();
            logger.Name = name;
            logger.FullName = fullName;
            logger.Parent = parent;

            logger._logListView = logger.Parent._logListView;

            // Adding the logger as a child of the parent logger.
            logger.Parent.Loggers.Add(name, logger);

            // Creating a child logger view and saving it in the new logger.
            logger.LoggerView = parent.LoggerView.AddNew(name, logger);

            if (UserSettings.Instance.RecursivlyEnableLoggers)
            {
                logger._enabled = parent.Enabled;
                logger.LoggerView.Enabled = parent.LoggerView.Enabled;
            }

            // Group
            if (UserSettings.Instance.GroupLogMessages)
            {
                logger.Group = new ListViewGroup(fullName);
                logger._logListView.Groups.Add(logger.Group);
            }

            return logger;
        }
Exemplo n.º 14
0
        public static LoggerItem CreateRootLoggerItem(string name, ILoggerView loggerView, ListView logListView)
        {
            LoggerItem logger = new LoggerItem();
            logger.Name = name;
            logger._logListView = logListView;

            // Tree Node
            logger.LoggerView = loggerView.AddNew(name, logger);

            return logger;
        }
Exemplo n.º 15
0
        public LogMessageItem(LoggerItem parent, LogMessage logMsg)
        {
            Parent = parent;
            Message = logMsg;

            string parentName = Parent.Name;
            if ((Parent.Name == logMsg.ThreadName) && (Parent.Parent != null))
                parentName = Parent.Parent.Name;

            // Create List View Item
            Item = new ListViewItem(logMsg.TimeStamp.ToString(UserSettings.Instance.TimeStampFormatString));
            Item.SubItems.Add(logMsg.Level.Name);
            Item.SubItems.Add(parentName);
            Item.SubItems.Add(logMsg.ThreadName);

            string msg = logMsg.Message.Replace("\r\n", " ");
            msg = msg.Replace("\n", " ");
            Item.SubItems.Add(msg);
            Item.ToolTipText = msg;

            Item.ForeColor = logMsg.Level.Color;
            Item.Tag = this;
        }
Exemplo n.º 16
0
 public void Initialize(ILoggerView loggerView, ListView logListView) =>
 RootLoggerItem = LoggerItem.CreateRootLoggerItem("Root", loggerView, logListView);