Utility Classes

The loglab.utils module provides utility classes that may be helpful when developing log processing applications.

class loglab.utils.LineDisplay(iterable)[source]

Display a count of the number of lines processed.

A single line display can sum lines through more than one pipeline.

instrument(iter)[source]

Return an generator that iterators through the values of iter. However as a side-effect, the LineDisplay will add the number of lines received through this iterator to its total, printing the total at regular intervals.

class loglab.utils.RandomLineFilter(iterable)[source]

Select a random subset of lines from a log.

Useful for shortening a 1e6-line logfile for testing.

class loglab.utils.AssertLogNotEmpty(iterable)[source]

Raises an error when iterated if no lines are received.

This class provides a useful sanity check, especially when working with logs merged from multiple sources, when it can be hard to spot that some filter or source is not yielding any log lines.

Previous topic

Date-aware Globbing

Next topic

Splitting logs by date

This Page