hyperplatform_log_parser/log_parser.cpp
// Opens a log file and checks if the length is the same as the last check. If
// not, parse newly added lines.
Opens a log file and checks if the length is the same as the last check. If
not, parse newly added lines.
Opens a log file and checks if the length is the same as the last check . If not parse newly added lines .
bool LogParser::ParseFile() {
  std::ifstream log_file(log_path_);
  if (!log_file) {
    return false;
  }
  log_file.seekg(0, log_file.end);
  const auto end_position = log_file.tellg();
  if (end_position < old_position_) {
    old_position_ = 0;
  }
  if (end_position == old_position_) {
    return false;
  }
  log_file.seekg(old_position_, log_file.beg);
  std::string log_line;
  while (!log_file.eof()) {
    std::getline(log_file, log_line);
    log_line_parser_.Parse(log_line);
  }
  old_position_ = end_position;
  return true;
}
bool LogParser :: ParseFile ( ) { std :: ifstream log_file ( log_path_ ) ; if ( ! log_file ) { return false ; } log_file . seekg ( 0 , log_file . end ) ; const auto end_position = log_file . tellg ( ) ; if ( end_position < old_position_ ) { old_position_ = 0 ; } if ( end_position == old_position_ ) { return false ; } log_file . seekg ( old_position_ , log_file . beg ) ; std :: string log_line ; while ( ! log_file . eof ( ) ) { std :: getline ( log_file , log_line ) ; log_line_parser_ . Parse ( log_line ) ; } old_position_ = end_position ; return true ; }
Opens a log file and checks if the length is the same as the last check.
Opens a log file and checks if the length is the same as the last check .
// Parse new lines