1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/***************************************************************************
* Copyright (C) 2005 by Nicolas Ternisien *
* nicolas.ternisien@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <tqpair.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include "xorgReader.h"
#define CONFIG_FILE_LOG_LEVEL_ICON "configure"
#define DEFAULT_SETTING_LOG_LEVEL_ICON "configure_toolbars"
#define COMMAND_LINE_LOG_LEVEL_ICON "konsole"
#define PROBED_LOG_LEVEL_ICON "wizard"
#define NOT_IMPLEMENTED_LOG_LEVEL_ICON "filenew"
XorgReader::XorgReader(TQObject *parent, const char *name) :
DefaultReader(parent, name),
newLineTime(),
newLineDate(TQDate::currentDate()),
lineCount(1)
{
initializeTypeName();
}
XorgReader::~XorgReader() {
}
void XorgReader::initColumns(LogViewColumns* columns) {
lineCount=1;
columns->append(new LogViewColumn(i18n("Line"), false, false));
columns->append(new LogViewColumn(i18n("Type"), false, false));
columns->append(new LogViewColumn(i18n("Message"), false, false));
columns->setGroupByDay(false);
columns->setGroupByHour(false);
}
LogLine* XorgReader::parseMessage(TQString& string, LogFile* originalFile) {
TQString type;
type=string.left(4);
LogLevel* logLineType=this->getTypeName(type);
//If the type is not empty, the log message has a type, so we can delete it
if (logLineType!=NULL) {
string=string.remove(0, 5);
}
else {
logLineType=Globals::informationLogLevel;
}
TQStringList list;
//list.append(i18n("# %1").arg(lineCount));
list.append(logLineType->name);
list.append(string);
lineCount++;
//Substracts 1 millisec to the line time, to allow sorting
newLineTime=newLineTime.addMSecs(-1);
TQString filePath=originalFile->url.path();
LogLine* logLine=new LogLine(newLineDate, newLineTime, list, filePath, logLineType, Globals::xorgMode->id);
return(logLine);
}
void XorgReader::initializeTypeName() {
xorgLevels["(--)"]=new LogLevel(20, i18n("probed"), PROBED_LOG_LEVEL_ICON, TQColor(240, 220, 3));
xorgLevels["(**)"]=new LogLevel(21, i18n("from config file"), CONFIG_FILE_LOG_LEVEL_ICON, TQColor(161, 133, 240));
xorgLevels["(==)"]=new LogLevel(22, i18n("default setting"), DEFAULT_SETTING_LOG_LEVEL_ICON, TQColor(169, 189, 165));
xorgLevels["(++)"]=new LogLevel(23, i18n("from command Line"), COMMAND_LINE_LOG_LEVEL_ICON, TQColor(179, 181, 214));
xorgLevels["(!!)"]=Globals::noticeLogLevel;
xorgLevels["(II)"]=Globals::informationLogLevel;
xorgLevels["(WW)"]=Globals::warningLogLevel;
xorgLevels["(EE)"]=Globals::errorLogLevel;
xorgLevels["(NI)"]=new LogLevel(24, i18n("not implemented"), NOT_IMPLEMENTED_LOG_LEVEL_ICON, TQColor(136, 146, 240));
xorgLevels["(\?\?)"]=Globals::noneLogLevel;
}
LogLevel* XorgReader::getTypeName(const TQString type) {
TQMap<TQString, LogLevel*>::iterator it;
it=xorgLevels.find(type);
if (it!=xorgLevels.end())
return(*it);
else
return(NULL);
}
#include "xorgReader.moc"
|