Rev 1104 | Rev 1182 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1104 | Rev 1157 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | ********************************************************************************************/
|
19 | ********************************************************************************************/
|
20 | 20 | ||
21 | #include "consoleshell.h"
|
21 | #include "consoleshell.h"
|
22 | 22 | ||
23 | #include <QtCore>
|
23 | #include <QtCore>
|
- | 24 | #include <QtDebug>
|
|
24 | //#include <QKeyEvent>
|
25 | //#include <QKeyEvent>
|
25 | 26 | ||
26 | #include "global.h"
|
27 | #include "global.h"
|
27 | #include "model.h"
|
28 | #include "model.h"
|
28 | #include "modelcontroller.h"
|
29 | #include "modelcontroller.h"
|
Line 95... | Line 96... | ||
95 | mParams.clear(); |
96 | mParams.clear(); |
96 | if (QCoreApplication::arguments().count()>3) { |
97 | if (QCoreApplication::arguments().count()>3) { |
97 | qWarning() << "set command line values:"; |
98 | qWarning() << "set command line values:"; |
98 | for (int i=3;i<QCoreApplication::arguments().count();++i) { |
99 | for (int i=3;i<QCoreApplication::arguments().count();++i) { |
99 | QString line = QCoreApplication::arguments().at(i); |
100 | QString line = QCoreApplication::arguments().at(i); |
- | 101 | line = line.remove(QChar('"')); // drop quotes |
|
100 | mParams.append(line); |
102 | mParams.append(line); |
- | 103 | //qDebug() << qPrintable(line);
|
|
101 | QString key = line.left(line.indexOf('=')); |
104 | QString key = line.left(line.indexOf('=')); |
102 | QString value = line.mid(line.indexOf('=')+1); |
105 | QString value = line.mid(line.indexOf('=')+1); |
103 | const_cast<XmlHelper&>(GlobalSettings::instance()->settings()).setNodeValue(key, value); |
106 | const_cast<XmlHelper&>(GlobalSettings::instance()->settings()).setNodeValue(key, value); |
104 | qWarning() << "set" << key << "to value:" << value << "(set:" << GlobalSettings::instance()->settings().value(key) << ")."; |
- | |
- | 107 | qWarning() << QString("set '%1' to value '%2'. result: '%3'").arg(key).arg(value).arg(GlobalSettings::instance()->settings().value(key)); |
|
105 | }
|
108 | }
|
106 | }
|
109 | }
|
107 | setupLogging(); |
110 | setupLogging(); |
108 | 111 | ||
109 | qDebug() << "**************************************************"; |
112 | qDebug() << "**************************************************"; |
110 | qDebug() << "*********** iLand console session ********"; |
113 | qDebug() << "*********** iLand console session ********"; |
111 | qDebug() << "**************************************************"; |
114 | qDebug() << "**************************************************"; |
112 | qDebug() << "started at: " << QDateTime::currentDateTime().toString(Qt::ISODate); |
- | |
- | 115 | qDebug() << "started at: " << QDateTime::currentDateTime().toString("hh:mm:ss"); |
|
113 | qDebug() << "iLand " << currentVersion() << " (" << svnRevision() << ")"; |
116 | qDebug() << "iLand " << currentVersion() << " (" << svnRevision() << ")"; |
114 | qDebug() << "**************************************************"; |
117 | qDebug() << "**************************************************"; |
115 | 118 | ||
116 | qWarning() << "*** creating model..."; |
119 | qWarning() << "*** creating model..."; |
117 | qWarning() << "**************************************************"; |
120 | qWarning() << "**************************************************"; |
Line 139... | Line 142... | ||
139 | }
|
142 | }
|
140 | runJavascript("onFinish"); |
143 | runJavascript("onFinish"); |
141 | 144 | ||
142 | qWarning() << "**************************************************"; |
145 | qWarning() << "**************************************************"; |
143 | qWarning() << "*** model run finished."; |
146 | qWarning() << "*** model run finished."; |
144 | qWarning() << "*** " << QDateTime::currentDateTime(); |
- | |
145 | qWarning() << "**************************************************"; |
147 | qWarning() << "**************************************************"; |
146 | 148 | ||
147 | } catch (const IException &e) { |
149 | } catch (const IException &e) { |
148 | qWarning() << "*** An exception occured ***"; |
150 | qWarning() << "*** An exception occured ***"; |
149 | qWarning() << e.message(); |
151 | qWarning() << e.message(); |
Line 157... | Line 159... | ||
157 | 159 | ||
158 | }
|
160 | }
|
159 | 161 | ||
160 | void ConsoleShell::runYear(int year) |
162 | void ConsoleShell::runYear(int year) |
161 | {
|
163 | {
|
162 | printf("simulating year %d ...\n", year-1); |
- | |
- | 164 | printf("%s: simulating year %d ...\n", QDateTime::currentDateTime().toString("hh:mm:ss").toLocal8Bit().data(), year-1); |
|
163 | }
|
165 | }
|
164 | 166 | ||
165 | QMutex qdebug_mutex;
|
- | |
- | 167 | static QMutex qdebug_mutex; |
|
166 | void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) |
168 | void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) |
167 | {
|
169 | {
|
168 | Q_UNUSED(context); |
170 | Q_UNUSED(context); |
169 | QMutexLocker m(&qdebug_mutex); |
171 | QMutexLocker m(&qdebug_mutex); |
170 | 172 | ||
171 | switch (type) { |
173 | switch (type) { |
172 | case QtDebugMsg: |
- | |
- | 174 | case QtDebugMsg: |
|
173 | *ConsoleShell::logStream() << msg << endl; |
175 | *ConsoleShell::logStream() << msg << endl; |
174 | if (ConsoleShell::flush()) |
176 | if (ConsoleShell::flush()) |
175 | ConsoleShell::logStream()->flush();; |
- | |
176 | break; |
- | |
177 | case QtWarningMsg: |
- | |
- | 177 | ConsoleShell::logStream()->flush(); |
|
- | 178 | break; |
|
- | 179 | case QtWarningMsg: |
|
178 | *ConsoleShell::logStream() << msg << endl; |
180 | *ConsoleShell::logStream() << msg << endl; |
179 | if (ConsoleShell::flush()) |
181 | if (ConsoleShell::flush()) |
180 | ConsoleShell::logStream()->flush();; |
- | |
181 | printf("Warning: %s\n", msg.toLocal8Bit().data()); |
- | |
- | 182 | ConsoleShell::logStream()->flush(); |
|
- | 183 | printf("%s: %s\n", QDateTime::currentDateTime().toString("hh:mm:ss").toLocal8Bit().data(), msg.toLocal8Bit().data()); |
|
- | 184 | break; |
|
- | 185 | // available from qt5.5
|
|
- | 186 | // case QtInfoMsg:
|
|
- | 187 | // *ConsoleShell::logStream() << msg << endl;
|
|
- | 188 | // if (ConsoleShell::flush())
|
|
- | 189 | // ConsoleShell::logStream()->flush();
|
|
- | 190 | // printf("%s: %s\n", QDateTime::currentDateTime().toString("hh:mm:ss").toLocal8Bit().data(), msg.toLocal8Bit().data());
|
|
182 | 191 | ||
183 | break; |
- | |
184 | case QtCriticalMsg: |
- | |
- | 192 | // break;
|
|
- | 193 | case QtCriticalMsg: |
|
185 | *ConsoleShell::logStream() << msg << endl; |
194 | *ConsoleShell::logStream() << msg << endl; |
186 | if (ConsoleShell::flush()) |
195 | if (ConsoleShell::flush()) |
187 | ConsoleShell::logStream()->flush();; |
- | |
- | 196 | ConsoleShell::logStream()->flush(); |
|
188 | printf("Critical: %s\n", msg.toLocal8Bit().data()); |
197 | printf("Critical: %s\n", msg.toLocal8Bit().data()); |
189 | break; |
- | |
190 | case QtFatalMsg: |
- | |
- | 198 | break; |
|
- | 199 | case QtFatalMsg: |
|
191 | *ConsoleShell::logStream() << msg << endl; |
200 | *ConsoleShell::logStream() << msg << endl; |
192 | if (ConsoleShell::flush()) |
201 | if (ConsoleShell::flush()) |
193 | ConsoleShell::logStream()->flush();; |
- | |
- | 202 | ConsoleShell::logStream()->flush(); |
|
194 | printf("Fatal: %s\n", msg.toLocal8Bit().data()); |
203 | printf("Fatal: %s\n", msg.toLocal8Bit().data()); |
195 | }
|
- | |
- | 204 | }
|
|
196 | }
|
205 | }
|
197 | 206 | ||
198 | 207 | ||
199 | void ConsoleShell::setupLogging() |
208 | void ConsoleShell::setupLogging() |
200 | {
|
209 | {
|