You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
@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:
A single log operation may alter the text box multiple times (resulting in multiple calls to the trimming function).
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:
The log entries are added in batch
The trimming/scrolling code happens once after the batch is processed.
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.
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
The text was updated successfully, but these errors were encountered: