code: def get_log_by_name(log_group_name, log_stream_name, out_file=None,
                      verbose=True):
      
      logs = boto3.client('logs')
      kwargs = {'logGroupName': log_group_name,
                'logStreamName': log_stream_name,
                'startFromHead': True}
      lines = []
      while True:
          response = logs.get_log_events(**kwargs)
          # If we've gotten all the events already, the nextForwardToken for
          # this call will be the same as the last one
          if response.get('nextForwardToken') == kwargs.get('nextToken'):
              break
          else:
              events = response.get('events')
              if events:
                  lines += ['%s: %s\n' % (evt['timestamp'], evt['message'])
                            for evt in events]
              kwargs['nextToken'] = response.get('nextForwardToken')
          if verbose:
              logger.info('%d %s' % (len(lines), lines[-1]))
      if out_file:
          with open(out_file, 'wt') as f:
              for line in lines:
                  f.write(line)
      return lines
docs: Download a log given the log's group and stream name.
  
      Parameters
      ----------
      log_group_name : str
          The name of the log group, e.g. /aws/batch/job.
  
      log_stream_name : str
          The name of the log stream, e.g. run_reach_jobdef/default/<UUID>
  
      Returns
      -------
      lines : list[str]
          The lines of the log as a list.