A small module builds a summary from an input stream of events. After a recent PR, the preview and final statistics started behaving inconsistently on streaming input and when filtering by level.
EventDigest.build() accepts an iterable source of strings in the format LEVEL: message.preview — the first preview_size matching lines in their original form;counts — the number of matching events for each level from levels.levels.: separator must be ignored.python demo.py
levels={"warn"}.preview and counts must be computed from the same set of matching events.levels is restricted, events of other levels must not appear in the counters or the preview.python demo.pyUse line comments to explain the problem, its impact, the fix and how to test it.