serilog-contrib / serilog-sinks-richtextbox

A Serilog sink that writes log events to a WPF RichTextBox control with colors and theme support
Apache License 2.0
107 stars 25 forks source link

Consider using multiple paragraphs instead of multiple inlines in a single paragraph #11

Open augustoproiete opened 3 years ago

augustoproiete commented 3 years ago

Currently, each new log entry appends a corresponding Inline object to the last Paragraph in the RichTextBox.

One user reported that writing log entries creating multiple paragraphs seem to have a better performance than creating multiple inlines in a single paragraph once the number of entries is large (the example was ~6000 lines with 4-5 tokens in each entry).

If that is true (needs testing/PoC), then it probably makes sense to switch to using multiple paragraphs by default.

One downside of using multiple paragraphs is that by default the control appends a margin which visually looks like each entry is using two lines instead of one, thus the user would have to remove the default margin of the control:

<Style TargetType="{x:Type Paragraph}">
    <Setter Property="Margin" Value="0"/>
</Style>

I don't think the sink should be making any changes to the visual aspects of the RichTextBox control, thus if we go this route, we should document the margin issue above

TonyValenti commented 3 years ago

Hi @augustoproiete - Can I pay you to roll in this enhancement and a few others:

  1. If a URL is logged, please convert it to a clickable HyperLink
  2. Related to the above, add an option to auto-trim the text box. If, after writing, a log entry, the text box has more than X number of paragraphs, remove the first items from the text box until there are less than X.
augustoproiete commented 3 years ago

@TonyValenti Very interesting ideas. Tracking via https://github.com/serilog-contrib/serilog-sinks-richtextbox/issues/15 and https://github.com/serilog-contrib/serilog-sinks-richtextbox/issues/16 to discuss design. They could potentially be done independently of this issue though definitely related

TonyValenti commented 3 years ago

Any chance you could give me a quote on getting this work done?

TonyValenti commented 3 years ago

@augustoproiete ?

TonyValenti commented 3 years ago

We are having performance problems with longer running apps because this is not implemented. Any chance you can make it happen soon?

augustoproiete commented 3 years ago

@TonyValenti I'll see if I can block some time over the next few weeks, but happy to take a PR if you'd like to give it a go

c0nstexpr commented 4 months ago

Any update for this?

TonyValenti commented 4 months ago

I have code that does this and makes the library much more performant but the manager has stopped replying.

TonyValenti commented 4 months ago

https://github.com/serilog-contrib/serilog-sinks-richtextbox/issues/32