def METHOD_NAME(array, start_time, errors_only=False, master_only=False):
    """ 
    This retrieves log messages from all segments that happened within the last
    'duration' seconds.  The tuples returned are (dbid, hostname, datadir, logdata), 
    sorted by dbid.
    """
    log_chunks = []
    for seg in array.getDbList():
        if master_only and seg.getSegmentContentId() != -1:
            continue
        duration = time.time() - start_time
        cmd = GpLogFilter('collect log chunk',
                          '\\`ls -rt %s | tail -1\\`' % os.path.join(seg.getSegmentDataDirectory(), 'pg_log', '*.csv'),
                          duration='0:0:%s' % (int(math.ceil(duration)) + 3),
                          trouble=errors_only,
                          ctxt=REMOTE,
                          remoteHost=seg.getSegmentHostName())
        cmd.run()
        log_data = cmd.get_results().stdout
        if log_data:
            log_chunks.append((seg.getSegmentDbId(), 
                               seg.getSegmentHostName(),
                               seg.getSegmentDataDirectory(),
                               log_data))
    log_chunks.sort(key=lambda chunk: chunk[0])
    return log_chunks