@Override public LogMessage readNextLogMessage(){
  while (true) {
    if (fileCounter.get() >= logPaths.size()) {
      break;
    }
    if (reader == null) {
      String filePath=logPaths.get(fileCounter.get());
      try {
        reader=new LogReader(filePath,request,status,basename);
      }
 catch (      Exception e) {
        status.append(String.format("Failed to open log file %s",e.getMessage()));
        logger.error("Failed to generate log reader for {}",e.getMessage());
        return null;
      }
      logger.debug("Reading file - " + filePath);
      File f=new File(filePath);
      sizeCounter.addAndGet(f.length());
    }
    if (currentLog != null) {
      prevLogTime=currentLog.getTime();
    }
    currentLog=reader.readNextLogMessage();
    if (currentLog != null) {
      logCounter.incrementAndGet();
      currentLog.setService(LogUtil.serviceToBytes(basename));
      if (!LogUtil.permitCurrentLog(request.getMaxCount(),logCounter.get(),currentLog.getTime(),prevLogTime)) {
        break;
      }
      return currentLog;
    }
 else {
      reader=null;
      fileCounter.incrementAndGet();
    }
  }
  return null;
}

@ Override public LogMessage readNextLogMessage ( ) { while ( true ) { if ( fileCounter . get ( ) >= logPaths . size ( ) ) { break ; } if ( reader == null ) { String filePath = logPaths . get ( fileCounter . get ( ) ) ; try { reader = new LogReader ( filePath , request , status , basename ) ; } catch ( Exception e ) { status . append ( String . format ( "Failed to open log file %s" , e . getMessage ( ) ) ) ; logger . error ( "Failed to generate log reader for {}" , e . getMessage ( ) ) ; return null ; } logger . debug ( "Reading file - " + filePath ) ; File f = new File ( filePath ) ; sizeCounter . addAndGet ( f . length ( ) ) ; } if ( currentLog != null ) { prevLogTime = currentLog . getTime ( ) ; } currentLog = reader . readNextLogMessage ( ) ; if ( currentLog != null ) { logCounter . incrementAndGet ( ) ; currentLog . setService ( LogUtil . serviceToBytes ( basename ) ) ; if ( ! LogUtil . permitCurrentLog ( request . getMaxCount ( ) , logCounter . get ( ) , currentLog . getTime ( ) , prevLogTime ) ) { break ; } return currentLog ; } else { reader = null ; fileCounter . incrementAndGet ( ) ; } } return null ; }
read log files one by one and , line by line from the data folder .
