def runner_data_format(runner_data, from_tail=0,
                       filter_fn=lambda r: r.returncode not in (0,-9,-15)):
    """
    Format runners' STDOUTs for printing or for inclusion in an error
    - `runners` is a list of Runner instances
    - `from_tail` is the number of lines to keep from the tail of each
      runner's log. The default is to keep the entire log.
    - `filter_fn` is a function to apply to each runner to determine
      whether or not to include its output in the log. The function
      should return `True` if the runner's output is to be included.
      Default is to keep all outputs.
    """
    return '\n===\n'.join(
        ('{identifier} ->\n\n{stdout}'
         '\n\n{identifier} <-'
         .format(identifier="--- {name} (pid: {pid}, rc: {rc})".format(
                    name=rd.name,
                    pid=rd.pid,
                    rc=rd.returncode),
                 stdout='\n'.join(rd.stdout.splitlines()[-from_tail:]))
         for rd in runner_data
         if filter_fn(rd)))