KSystemLog – system log viewer tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.7KB

  1. /***************************************************************************
  2. * Copyright (C) 2005 by Nicolas Ternisien *
  3. * nicolas.ternisien@gmail.com *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
  19. ***************************************************************************/
  20. #include <tdelocale.h>
  21. #include <tdemessagebox.h>
  22. #include "parsingHelper.h"
  23. #include "cupsAccessReader.h"
  24. CupsAccessReader::CupsAccessReader(TQObject *parent, const char *name) :
  25. DefaultReader(parent, name)
  26. {
  27. }
  28. CupsAccessReader::~CupsAccessReader() {
  29. }
  30. void CupsAccessReader::initColumns(LogViewColumns* columns) {
  31. columns->append(new LogViewColumn(i18n("Date"), true, false));
  32. columns->append(new LogViewColumn(i18n("Host Name"), true, true));
  33. columns->append(new LogViewColumn(i18n("Id."), true, true)); //=Identification protocol [From RFC1413 (see Google for more infos)]
  34. columns->append(new LogViewColumn(i18n("User"), true, true));
  35. columns->append(new LogViewColumn(i18n("Response"), true, true));
  36. columns->append(new LogViewColumn(i18n("Bytes Sent"), true, false));
  37. columns->append(new LogViewColumn(i18n("HTTP Request"), true, false));
  38. }
  39. LogLine* CupsAccessReader::parseMessage(TQString& logLine, LogFile* logFile) {
  40. int spacePos=logLine.find(' ');
  41. TQString hostName=logLine.left(spacePos);
  42. logLine=logLine.remove(0, spacePos+1);
  43. spacePos=logLine.find(' ');
  44. TQString identd=logLine.left(spacePos);
  45. logLine=logLine.remove(0, spacePos+1);
  46. spacePos=logLine.find(' ');
  47. TQString userName=logLine.left(spacePos);
  48. logLine=logLine.remove(0, spacePos+1);
  49. int endDate=logLine.find(']');
  50. TQString strDateTime=logLine.left(endDate);
  51. logLine=logLine.remove(0, endDate+3);
  52. TQDateTime dateTime=ParsingHelper::parseDateTimeFromHTTP(strDateTime);
  53. TQDate date=dateTime.date();
  54. TQTime time=dateTime.time();
  55. int endQuote=logLine.find('\"');
  56. TQString message=logLine.left(endQuote);
  57. logLine=logLine.remove(0, endQuote+2);
  58. spacePos=logLine.find(' ');
  59. TQString httpResponse=ParsingHelper::parseHTTPResponse(logLine.left(spacePos));
  60. logLine=logLine.remove(0, spacePos+1);
  61. spacePos=logLine.find(' ');
  62. TQString bytesSent=ParsingHelper::parseSize(logLine.left(spacePos));
  63. TQStringList list;
  64. list.push_back(hostName);
  65. list.push_back(identd);
  66. list.push_back(userName);
  67. list.push_back(httpResponse);
  68. list.push_back(bytesSent);
  69. list.push_back(message);
  70. TQString filePath=logFile->url.path();
  71. LogLine* line=new LogLine(date, time, list, filePath, Globals::informationLogLevel, Globals::cupsAccessMode->id);
  72. return(line);
  73. }
  74. #include "cupsAccessReader.moc"