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.

120 lines
4.1KB

  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 <tqpair.h>
  21. #include <tdelocale.h>
  22. #include <tdemessagebox.h>
  23. #include "xorgReader.h"
  24. #define CONFIG_FILE_LOG_LEVEL_ICON "configure"
  25. #define DEFAULT_SETTING_LOG_LEVEL_ICON "configure_toolbars"
  26. #define COMMAND_LINE_LOG_LEVEL_ICON "konsole"
  27. #define PROBED_LOG_LEVEL_ICON "wizard"
  28. #define NOT_IMPLEMENTED_LOG_LEVEL_ICON "document-new"
  29. XorgReader::XorgReader(TQObject *parent, const char *name) :
  30. DefaultReader(parent, name),
  31. newLineTime(),
  32. newLineDate(TQDate::currentDate()),
  33. lineCount(1)
  34. {
  35. initializeTypeName();
  36. }
  37. XorgReader::~XorgReader() {
  38. }
  39. void XorgReader::initColumns(LogViewColumns* columns) {
  40. lineCount=1;
  41. columns->append(new LogViewColumn(i18n("Line"), false, false));
  42. columns->append(new LogViewColumn(i18n("Type"), false, false));
  43. columns->append(new LogViewColumn(i18n("Message"), false, false));
  44. columns->setGroupByDay(false);
  45. columns->setGroupByHour(false);
  46. }
  47. LogLine* XorgReader::parseMessage(TQString& string, LogFile* originalFile) {
  48. TQString type;
  49. type=string.left(4);
  50. LogLevel* logLineType=this->getTypeName(type);
  51. //If the type is not empty, the log message has a type, so we can delete it
  52. if (logLineType!=NULL) {
  53. string=string.remove(0, 5);
  54. }
  55. else {
  56. logLineType=Globals::informationLogLevel;
  57. }
  58. TQStringList list;
  59. //list.append(i18n("# %1").arg(lineCount));
  60. list.append(logLineType->name);
  61. list.append(string);
  62. lineCount++;
  63. //Substracts 1 millisec to the line time, to allow sorting
  64. newLineTime=newLineTime.addMSecs(-1);
  65. TQString filePath=originalFile->url.path();
  66. LogLine* logLine=new LogLine(newLineDate, newLineTime, list, filePath, logLineType, Globals::xorgMode->id);
  67. return(logLine);
  68. }
  69. void XorgReader::initializeTypeName() {
  70. xorgLevels["(--)"]=new LogLevel(20, i18n("probed"), PROBED_LOG_LEVEL_ICON, TQColor(240, 220, 3));
  71. xorgLevels["(**)"]=new LogLevel(21, i18n("from config file"), CONFIG_FILE_LOG_LEVEL_ICON, TQColor(161, 133, 240));
  72. xorgLevels["(==)"]=new LogLevel(22, i18n("default setting"), DEFAULT_SETTING_LOG_LEVEL_ICON, TQColor(169, 189, 165));
  73. xorgLevels["(++)"]=new LogLevel(23, i18n("from command Line"), COMMAND_LINE_LOG_LEVEL_ICON, TQColor(179, 181, 214));
  74. xorgLevels["(!!)"]=Globals::noticeLogLevel;
  75. xorgLevels["(II)"]=Globals::informationLogLevel;
  76. xorgLevels["(WW)"]=Globals::warningLogLevel;
  77. xorgLevels["(EE)"]=Globals::errorLogLevel;
  78. xorgLevels["(NI)"]=new LogLevel(24, i18n("not implemented"), NOT_IMPLEMENTED_LOG_LEVEL_ICON, TQColor(136, 146, 240));
  79. xorgLevels["(\?\?)"]=Globals::noneLogLevel;
  80. }
  81. LogLevel* XorgReader::getTypeName(const TQString type) {
  82. TQMap<TQString, LogLevel*>::iterator it;
  83. it=xorgLevels.find(type);
  84. if (it!=xorgLevels.end())
  85. return(*it);
  86. else
  87. return(NULL);
  88. }
  89. #include "xorgReader.moc"