private void btnCreateLogMessage_Click(object sender, EventArgs e)
 {
     LogItem item = new LogItem(this,
                                 GetLogLevelFromListBox(lstLogMessageLevel),
                                 txtLogMessage.Text);
     GlobalLog.Instance.Add(item);
 }
 /// <summary>
 /// Called whenever a new item is added to the registered log.  Changes the text of
 /// the associated label to the item's Message value.  Ensures that the label update
 /// only occurs on the GUI thread via the InvokeRequired pattern.
 /// </summary>
 /// <param name="item">Details of newly-added log item</param>
 public override void ProcessLogMessage(LogItem item)
 {
     if (_label.InvokeRequired)
     {
         _label.Invoke(new MethodInvoker(() => { ProcessLogMessage(item); }));
     }
     else
     {
         _label.Text = item.Message;
         _label.Update();
     }
 }
 /// <summary>
 /// Called whenever a new item is added to the registered log.  Writes the log message
 /// to the system console.
 /// </summary>
 /// <param name="item">Details of newly-added log item</param>
 public override void ProcessLogMessage(LogItem item)
 {
     Console.WriteLine(item.ToString());
 }
 /// <summary>
 /// Called whenever a new item is added to the registered log.  Adds the LogItem
 /// to the assocaited ListBox control.
 /// </summary>
 /// <param name="item">Details of newly-added log item</param>
 public override void ProcessLogMessage(LogItem item)
 {
     this.AddMessageToListBox(item.ToString(" "));
 }
 /// <summary>
 /// Create a new logging event argument instance
 /// </summary>
 /// <param name="Item">The LogItem associated with this Logging Event</param>
 public LogEventArgs(LogItem Item)
 {
     this._Item = Item;
 }
 /// <summary>
 /// Called whenever a new item is added to the registered log.  Adds the LogItem
 /// to the assocaited ListBox control.
 /// </summary>
 /// <param name="item">Details of newly-added log item</param>
 public override void ProcessLogMessage(LogItem item)
 {
     this.ShowMessage(item.ToString(" "), item.Level.ToString());
 }
        /// <summary>
        /// Called whenever a new item is added to the registered log.  Adds the LogItem
        /// to the assocaited log file, creating the log file/path if needed.  File writes
        /// are performed on a seperate thread so that return is immediate.
        /// </summary>
        /// <param name="item">Details of newly-added log item</param>
        public override void ProcessLogMessage(LogItem item)
        {
            lock (_fileSync)
            {
                if ((_logWriterThread == null) && (!String.IsNullOrEmpty(_filePath)))
                {
                    _logWriterThread = new Thread(AddMessagesToFile);
                    _logWriterThread.IsBackground = true;
                    _logWriterThread.Name = "FileLog Listener: " + _filePath;
                    _logWriterThread.Start();
                }

                if (item != null)
                    _logMessages.Enqueue(item.ToString(" "));

                Monitor.Pulse(_fileSync);
            }
        }
 /// <summary>
 /// Send a general logging item to all registered log listeners
 /// </summary>
 /// <param name="item">Logging item to send</param>
 new public void Add(LogItem item)
 {
 }
 /// <summary>
 /// Virtual method called whenever a new item is added to the registered log.
 /// Base method simply writes the item message and level to the Visual Studio Debug output; 
 /// derived classes should override this method to do something more exotic.
 /// </summary>
 /// <param name="item">Details of newly-added log item</param>
 public virtual void ProcessLogMessage(LogItem item)
 {
     System.Diagnostics.Debug.WriteLine(item.ToString());
 }
Beispiel #10
0
 /// <summary>
 /// Send a general logging item to all registered log listeners
 /// </summary>
 /// <param name="item">Logging item to send</param>
 public void Add(LogItem item)
 {
     if (LogMessageHandler != null)
         LogMessageHandler.Invoke(this, new LogEventArgs(item));
 }