Beispiel #1
0
        private void ForwardLogEntry(object sender, LoggedEventArgs loggedEventArgs)
        {
            if (!IsEnabled)
            {
                return;
            }

            Logged?.Invoke(this, loggedEventArgs);
        }
Beispiel #2
0
        private void AppendLogMessage(object sender, LoggedEventArgs e)
        {
            RichTextBox.Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
            {
                var message = $"{e.Entry.Timestamp:HH:mm:ss.fff}: {e.Entry.Message}\r";

                var existingTextRange = new TextRange(RichTextBox.Document.ContentStart, RichTextBox.Document.ContentEnd);
                if (existingTextRange.Text.Length > _maxLogLength)
                {
                    existingTextRange.Text = string.Empty;
                }

                var textRange = new TextRange(RichTextBox.Document.ContentEnd, RichTextBox.Document.ContentEnd)
                {
                    Text = message
                };

                textRange.ApplyPropertyValue(TextElement.ForegroundProperty, GetBrushForSeverity(e.Entry.Severity));

                RichTextBox.ScrollToEnd();
            }));
        }
 private void Logger_Logged(object sender, LoggedEventArgs e)
 {
     richTextBoxLog.InvokeIfRequired(log => log.AppendLine(e.Message, LogLevelToColor(e.LogLevel)));
 }
Beispiel #4
0
 private static void LoggedCallback(object sender,
                                    LoggedEventArgs e) =>
 AddLogEntry(e.Message);
Beispiel #5
0
 //Event handler for scraping events.  Log to console.
 private static void Scraper_LoggedEvent(object sender, LoggedEventArgs e)
 {
     //log event to console
     Console.WriteLine(e.TimeStamp.ToString() + ": " + e.Message);
 }