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

            Logged?.Invoke(this, loggedEventArgs);
        }
コード例 #2
0
ファイル: LogView.xaml.cs プロジェクト: chkr1011/LightPi
        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();
            }));
        }
コード例 #3
0
 private void Logger_Logged(object sender, LoggedEventArgs e)
 {
     richTextBoxLog.InvokeIfRequired(log => log.AppendLine(e.Message, LogLevelToColor(e.LogLevel)));
 }
コード例 #4
0
 private static void LoggedCallback(object sender,
                                    LoggedEventArgs e) =>
 AddLogEntry(e.Message);
コード例 #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);
 }