Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to auto-trim the RichTextBox contents (i.e. fixed number of lines or paragraphs) #16

Open
augustoproiete opened this issue Sep 4, 2021 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed needs-design up-for-grabs
Milestone

Comments

@augustoproiete
Copy link
Member

Discussed in #11 (comment)

Originally posted by TonyValenti September 3, 2021
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

@TonyValenti
Copy link

Using a paragraph per log entry simplifies this so that A log entry won't be broken in half.

@TonyValenti
Copy link

@augustoproiete -
After a lot of testing, we determined that autotrimming is something that is best implemented in the logger and not in the control itself.

When the control is responsible for trimming, it has to hook into the "Text/Document" Changed event which triggers with every change to the document. This is bad because:

  1. A single log operation may alter the text box multiple times (resulting in multiple calls to the trimming function).
  2. Even if you consolidate (1) down into a single DOM change per log entry, when lots of log entries output at once, you'll still have multiple invocations of the trimming code.

By implementing scroll and trimming in the logger, you can be much more efficient. In my PR, if multiple log entries are appended at once:

  1. The log entries are added in batch
  2. The trimming/scrolling code happens once after the batch is processed.

@TonyValenti
Copy link

TonyValenti commented Dec 20, 2021

Also, by allowing the logger to implement trimming itself, it keeps the consumer from having to worry about implementation details changing. For example: "How are log entries separated?" If the control implements the trimming, then the consumer has to know how the newlines are being appended and respond accordingly.

Imagine how differently people would feel if serilog took the approach "We're not going to create a rolling file logger. We're going to make everyone be responsible for cleaning up their own logs." Yes, people would do it (and they'd do it a million different ways with varying goodness), but it is such a common and necessary scenario, it should be built right in (and it is!).

The auto-trim on the text box is essentially the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed needs-design up-for-grabs
Development

No branches or pull requests

2 participants