// filter out log entries which we view as superflous or distracting
void filterLatexLog(const core::tex::LogEntries& logEntries,
                    core::tex::LogEntries* pFilteredLogEntries)
{
   core::algorithm::copy_if(logEntries.begin(),
                            logEntries.end(),
                            std::back_inserter(*pFilteredLogEntries),
                            includeLogEntry);
}
void writeLogEntriesOutput(const core::tex::LogEntries& logEntries)
{
   if (logEntries.empty())
      return;

   std::string output = "\n";
   BOOST_FOREACH(const core::tex::LogEntry& logEntry, logEntries)
   {
      switch(logEntry.type())
      {
         case core::tex::LogEntry::Error:
            output += "Error: ";
            break;
         case core::tex::LogEntry::Warning:
            output += "Warning: ";
            break;
         case core::tex::LogEntry::Box:
            output += "Bad Box: ";
            break;
      }

      output += logEntry.filePath().filename();
      int line = logEntry.line();
      if (line >= 0)
         output += ":" + safe_convert::numberToString(line);

      output += ": " + logEntry.message() + "\n";
   }
   output += "\n";

   enqueOutputEvent(output);

}
std::string buildIssuesMessage(const core::tex::LogEntries& logEntries)
{
   if (logEntries.empty())
      return std::string();

   // count error types
   int errors = 0, warnings = 0, badBoxes = 0;
   BOOST_FOREACH(const core::tex::LogEntry& logEntry, logEntries)
   {
      if (logEntry.type() == core::tex::LogEntry::Error)
         errors++;
      else if (logEntry.type() == core::tex::LogEntry::Warning)
         warnings++;
      else if (logEntry.type() == core::tex::LogEntry::Box)
         badBoxes++;
   }

   std::string issues;
   boost::format fmt("%1% %2%");
   if (errors > 0)
   {
      issues += boost::str(fmt % errors % "error");
      if (errors > 1)
         issues += "s";
   }
   if (warnings > 0)
   {
      if (!issues.empty())
         issues += ", ";
      issues += boost::str(fmt % warnings % "warning");
      if (warnings > 1)
         issues += "s";
   }
   if (badBoxes > 0)
   {
      if (!issues.empty())
         issues += ", ";
      issues += boost::str(fmt % badBoxes % "bad");
      if (badBoxes > 1)
         issues += "boxes";
      else
         issues += "box";
   }

   if (!issues.empty())
      return "Issues: " + issues;
   else
      return std::string();
}