Debian Codegraph @

src/readLogFile.cpp

raw symbols SCIP
1 /* ---------------------------------- readLogFile.cpp ---------------------------------------------------------------------------
2 Class to read a logfile from disk in a seperate thread
3
4 ===============================================================================================================================
5 ===============================================================================================================================
6 This file is part of "luckyBackup" project
7 Copyright, Loukas Avgeriou
8 luckyBackup is distributed under the terms of the GNU General Public License
9 luckyBackup is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 luckyBackup is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with luckyBackup. If not, see <http://www.gnu.org/licenses/>.
21
22
23 project version : Please see "main.cpp" for project version
24
25 developer : luckyb
26 last modified : 22 May 2016
27 ===============================================================================================================================
28 ===============================================================================================================================
29 */
30
31
32 #include "readLogFile.h"cxx . . $ `<file>/src/readLogFile.h`/
33
34 #include <QTextStream>
35
36 #include "global.h"cxx . . $ `<file>/src/global.h`/
37
38 // class ReadLogFile Constructor=================================================================================================
39 ReadLogFilecxx . . $ ReadLogFile#::ReadLogFilecxx . . $ ReadLogFile#ReadLogFile(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) : QThreadcxx . . $ QThread#QThread(749de1b6ae65bddd).(parent)
40 {
41 textcxx . . $ ReadLogFile#text. =cxx . . $ QString#`operator=`(d02845eef0c33901). "";
42 errorsTotalcxx . . $ ReadLogFile#errorsTotal. = 0;
43 }
44
45 // class ReadLogFile Destructor=================================================================================================
46 ReadLogFilecxx . . $ ReadLogFile#::~cxx . . $ ReadLogFile#`~ReadLogFile`(ced63f7c635d850d).ReadLogFilecxx . . $ ReadLogFile# ()
47 {
48 logfilecxx . . $ Global/logfile..closecxx . . $ QFileDevice#close(49f6e7a06ebc5aa8).();
49 }
50
51 // run the QThread=================================================================================================
52 void ReadLogFilecxx . . $ ReadLogFile#::runcxx . . $ ReadLogFile#run(49f6e7a06ebc5aa8). ()
53 {
54 if (logUrlcxx . . $ ReadLogFile#logUrl. ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "file:Does_not_exist") // if the logfile does not exist for a reason display a message
55 {
56 textcxx . . $ ReadLogFile#text. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). trcxx . . $ ReadLogFile#tr(75d9f1c324b4579d).("Could not locate the logfile") +cxx . . $ operator+(3d22f08efddf8107). "!!";
57 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! errorcxx . . $ ReadLogFile#error(3520e46b33348bf6).(textcxx . . $ ReadLogFile#text.);
58 return;
59 }
60 else
61 {
62 if (!logfilecxx . . $ Global/logfile..opencxx . . $ QFile#open(dca164408be960c8).(QIODevicecxx . . $ QIODevice#::ReadOnlycxx . . $ QIODevice#ReadOnly. |cxx . . $ `operator|`(c9e45f682471e48d). QIODevicecxx . . $ QIODevice#::Textcxx . . $ QIODevice#Text.)) //if it exists try to open it
63 {
64 textcxx . . $ ReadLogFile#text. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). trcxx . . $ ReadLogFile#tr(75d9f1c324b4579d).("Could not open the logfile") +cxx . . $ operator+(3d22f08efddf8107). "!!<br><font color=red>"+cxx . . $ operator+(fab9b4f80031f353). logfilecxx . . $ Global/logfile..errorStringcxx . . $ QIODevice#errorString(6ef7b6c27b00b43d).() +cxx . . $ operator+(3d22f08efddf8107). "</font>";
65 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! errorcxx . . $ ReadLogFile#error(3520e46b33348bf6).(textcxx . . $ ReadLogFile#text.);
66 return;
67 }
68 else
69 readFilecxx . . $ ReadLogFile#readFile(49f6e7a06ebc5aa8).();
70 }
71 }
72
73 // set the log url=================================================================================================
74 void ReadLogFilecxx . . $ ReadLogFile#::setLogUrlcxx . . $ ReadLogFile#setLogUrl(7df51288a9ebd664).(QStringcxx . . $ QString# logurl)
75 {
76 this -> logUrlcxx . . $ ReadLogFile#logUrl. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). logurl;
77 }
78
79 // Return the total errors found =================================================================================================
80 int ReadLogFilecxx . . $ ReadLogFile#::TotalErrorscxx . . $ ReadLogFile#TotalErrors(b126dc7c1de90089).()
81 {
82 return errorsTotalcxx . . $ ReadLogFile#errorsTotal.;
83 }
84
85 // Read the logfile from disk ===============================================================================================
86 void ReadLogFilecxx . . $ ReadLogFile#::readFilecxx . . $ ReadLogFile#readFile(49f6e7a06ebc5aa8).()
87 {
88 QTextStreamcxx . . $ QTextStream# incxx . . $ QTextStream#QTextStream(bebe8f2dee7f9e86).(&logfilecxx . . $ Global/logfile.);
89
90 QStringcxx . . $ QString# readLine = ""cxx . . $ QString#QString(85c52e162fed56f9).;
91 int countLines = 0;
92 while (!in.atEndcxx . . $ QTextStream#atEnd(50ce9a9e25b4a850).()) // read the logfile line by line
93 {
94 readLine =cxx . . $ QString#`operator=`(4f35bf974e7f8568). in.readLinecxx . . $ QTextStream#readLine(20e0a2766677f583).();
95 countLines++;
96
97 if (readLine.startsWithcxx . . $ QString#startsWith(8cce4688c16f48f3).("<a name=\"error"cxx . . $ QString#QString(85c52e162fed56f9).)) // if the line is an error increase the total errors
98 errorsTotalcxx . . $ ReadLogFile#errorsTotal.++;
99
100 textcxx . . $ ReadLogFile#text..appendcxx . . $ QString#append(6a89d0b7f4d2681c).(readLine +cxx . . $ operator+(3d22f08efddf8107). "<br>");
101
102 if ((countLines > 2000) || (in.atEndcxx . . $ QTextStream#atEnd(50ce9a9e25b4a850).())) //when 5000 lines are read or file is at end, append text to the logviewer
103 {
104 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! newTextcxx . . $ ReadLogFile#newText(3520e46b33348bf6).(textcxx . . $ ReadLogFile#text.);
105 textcxx . . $ ReadLogFile#text. =cxx . . $ QString#`operator=`(d02845eef0c33901). "";
106 countLines = 0;
107 }
108 }
109 }
110
111 // end of readLogFile.cpp ---------------------------------------------------------------------------
112