refactoring: extract some common code out of log viewers