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.

82 lines
2.8KB

  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 "cronReader.h"
  21. #include <tdelocale.h>
  22. #include <tdemessagebox.h>
  23. CronReader::CronReader(TQObject *parent, const char *name) :
  24. DefaultReader(parent, name)
  25. {
  26. }
  27. CronReader::~CronReader() {
  28. }
  29. void CronReader::initColumns(LogViewColumns* columns) {
  30. columns->append(new LogViewColumn(i18n("Date"), true, false));
  31. columns->append(new LogViewColumn(i18n("Host Name"), true, true));
  32. columns->append(new LogViewColumn(i18n("Process"), true, true));
  33. columns->append(new LogViewColumn(i18n("User"), true, true));
  34. columns->append(new LogViewColumn(i18n("Message"), true, false));
  35. }
  36. /**
  37. * TODO Improve speed of this method
  38. */
  39. LogLine* CronReader::parseMessage(TQString& line, LogFile* logFile) {
  40. //Use the default parsing
  41. LogLine* logLine=DefaultReader::parseMessage(line, logFile);
  42. TQStringList& list=logLine->getItemList();
  43. //Gets the message column (last item) and deletes it
  44. TQString message=list.back();
  45. list.pop_back();
  46. int leftBracket=message.find('(');
  47. int rightBracket=message.find(')');
  48. TQString user=message.mid(leftBracket+1, rightBracket-leftBracket-1);
  49. list.push_back(user);
  50. message=message.right(message.length() - rightBracket-2);
  51. list.push_back(message);
  52. //This log line comes from Cron Reader
  53. logLine->setType(Globals::cronMode->id);
  54. return(logLine);
  55. }
  56. #include "cronReader.moc"