code: def _merge_logfiles(self):
          
          # open files, read first lines, extract first dates
          lines = [next(iter(logfile), None) for logfile in self.args['logfile']]
  
          # adjust lines by timezone
          for i in range(len(lines)):
              if lines[i] and lines[i].datetime:
                  lines[i]._datetime = (lines[i].datetime +
                                        timedelta(hours=self.args['timezone']
                                                  [i]))
  
          while any(lines):
              min_line = min(lines, key=self._datetime_key_for_merge)
              min_idx = lines.index(min_line)
  
              if self.args['markers'][min_idx]:
                  min_line.merge_marker_str = self.args['markers'][min_idx]
  
              yield min_line
  
              # update lines array with a new line from the min_idx'th logfile
              lines[min_idx] = next(iter(self.args['logfile'][min_idx]), None)
              if lines[min_idx] and lines[min_idx].datetime:
                  lines[min_idx]._datetime = (
                      lines[min_idx].datetime +
                      timedelta(hours=self.args['timezone'][min_idx]))
docs: Helper method to merge several files together by datetime.