/// <summary> /// Causes the plugin to report its status or errors to a <see cref="ILogger"/>, /// without requesting permission from an <see cref="IPluginHost"/>. /// </summary> protected void ReportImmediately(CWLoggerEntryType eventType, string msg) { try { lock (loggers) { foreach (ILogger logger in loggers) { switch (eventType) { case CWLoggerEntryType.Info: logger.LogInfo(msg); break; case CWLoggerEntryType.Warning: logger.LogWarning(msg); break; case CWLoggerEntryType.Error: logger.LogError(msg); break; default: logger.LogWarning(msg); break; } } } } catch {} }
private void Log(string msg, CWLoggerEntryType type) { if ((this.Text.Length + msg.Length) >= this.MaxLength) { try { this.Select(0, this.TextLength / 2); this.ReadOnly = false; this.Cut(); this.ClearUndo(); Clipboard.SetDataObject(new DataObject()); } catch {} finally { this.ReadOnly = true; GC.Collect(); } } if (useColors) { int pos = this.TextLength - 1; this.SelectionStart = (pos != -1)?pos:0; this.AppendText(msg + "\n"); this.SelectionStart = pos + 1; this.SelectionLength = msg.Length; switch (type) { case CWLoggerEntryType.Error: this.SelectionColor = Color.Red; break; case CWLoggerEntryType.Warning: this.SelectionColor = Color.Blue; break; default: this.SelectionColor = Color.Black; break; } this.SelectionLength = 0; } else { this.SelectionStart = this.TextLength - 1; this.AppendText(msg); this.SelectionLength = 0; } }
/// <summary> /// Enqueues an event message to the internal event queue. /// </summary> /// <param name="eventType">The <see cref="CWLoggerEntryType"/> of the event.</param> /// <param name="msg">The message related to the event.</param> protected void AddToReportQueue(CWLoggerEntryType eventType, string msg) { try { if (events != null) { lock (events.SyncRoot) { events.Enqueue(new EventLoggerEntry(eventType, DateTime.Now, name + ": " + msg)); } } } catch {} }
/// <summary> /// Constructs a new instance of the <see cref="EventLoggerEntry"/> struct with the /// data provided. /// </summary> /// <param name="eventType">The type of the event.</param> /// <param name="eventDate">The date and time the event took place.</param> /// <param name="eventMsg">The message related to the event.</param> public EventLoggerEntry(CWLoggerEntryType eventType, DateTime eventDate, string eventMsg) { EventType = eventType; EventDate = eventDate; EventMessage = eventMsg; }
/// <summary> /// Causes the plugin to report its status or errors to a <see cref="ILogger"/>, /// without requesting permission from an <see cref="IPluginHost"/>. /// </summary> protected void ReportImmediately(CWLoggerEntryType eventType, string msg) { try { lock(loggers) { foreach(ILogger logger in loggers) { switch(eventType) { case CWLoggerEntryType.Info: logger.LogInfo(msg); break; case CWLoggerEntryType.Warning: logger.LogWarning(msg); break; case CWLoggerEntryType.Error: logger.LogError(msg); break; default: logger.LogWarning(msg); break; } } } } catch {} }
/// <summary> /// Enqueues an event message to the internal event queue. /// </summary> /// <param name="eventType">The <see cref="CWLoggerEntryType"/> of the event.</param> /// <param name="msg">The message related to the event.</param> protected void AddToReportQueue(CWLoggerEntryType eventType, string msg) { try { if(events!=null) { lock(events.SyncRoot) { events.Enqueue(new EventLoggerEntry(eventType, DateTime.Now, name + ": " + msg)); } } } catch {} }
private void Log(string msg, CWLoggerEntryType type) { if((this.Text.Length + msg.Length) >= this.MaxLength) { try { this.Select(0, this.TextLength /2); this.ReadOnly = false; this.Cut(); this.ClearUndo(); Clipboard.SetDataObject(new DataObject()); } catch {} finally { this.ReadOnly = true; GC.Collect(); } } if(useColors) { int pos = this.TextLength-1; this.SelectionStart = (pos!=-1)?pos:0; this.AppendText(msg + "\n"); this.SelectionStart = pos+1; this.SelectionLength = msg.Length; switch(type) { case CWLoggerEntryType.Error: this.SelectionColor = Color.Red; break; case CWLoggerEntryType.Warning: this.SelectionColor = Color.Blue; break; default: this.SelectionColor = Color.Black; break; } this.SelectionLength = 0; } else { this.SelectionStart = this.TextLength-1; this.AppendText(msg); this.SelectionLength = 0; } }