qdoc: Adding the -log-progress option

qdoc now sends progress log messages to stderr
only if -log-progress appears on the command line.
The progress messages are not printed to stderr
if -log-progress is not used. i.e., -log-progress
is off by default.

Task number: QTBUG-27707

Change-Id: Id605d943506ab38639730bf16473b156d061dc53
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
bb10
Martin Smith 2012-10-25 14:01:11 +02:00
parent 34d2a7e6b6
commit aca24f1146
4 changed files with 18 additions and 8 deletions

View File

@ -57,6 +57,7 @@ QT_STATIC_CONST_IMPL Location Location::null;
int Location::tabSize;
QString Location::programName;
QRegExp *Location::spuriousRegExp = 0;
bool Location::logProgress_ = false;
/*!
\class Location
@ -336,12 +337,15 @@ void Location::information(const QString& message)
}
/*!
Prints \a message to \c stderr followed by a \c{'\n'}.
Prints \a message to \c stderr followed by a \c{'\n'},
but only if the -log-progress option is set.
*/
void Location::logToStdErr(const QString& message)
{
fprintf(stderr, "%s\n", message.toLatin1().data());
fflush(stderr);
if (logProgress_) {
fprintf(stderr, "LOG: %s\n", message.toLatin1().data());
fflush(stderr);
}
}
/*!

View File

@ -97,6 +97,8 @@ public:
static void information(const QString& message);
static void internalError(const QString& hint);
static void logToStdErr(const QString& message);
static void startLoggingProgress() { logProgress_ = true; }
static void stopLoggingProgress() { logProgress_ = false; }
private:
enum MessageType { Warning, Error };
@ -124,6 +126,7 @@ private:
static int tabSize;
static QString programName;
static QRegExp *spuriousRegExp;
static bool logProgress_;
};
QT_END_NAMESPACE

View File

@ -293,10 +293,10 @@ static void processQdocconfFile(const QString &fileName)
QString phase;
if (Generator::runPrepareOnly())
phase = "in -prepare mode ";
phase = " in -prepare mode ";
else if (Generator::runGenerateOnly())
phase = "in -generate mode ";
QString msg = "Running qdoc " + phase + "for " + config.getString(CONFIG_PROJECT);
phase = " in -generate mode ";
QString msg = "Running qdoc for " + config.getString(CONFIG_PROJECT) + phase;
Location::logToStdErr(msg);
/*
@ -617,6 +617,9 @@ int main(int argc, char **argv)
else if (opt == "-generate") {
Generator::setQDocPass(Generator::Generate);
}
else if (opt == "-log-progress") {
Location::startLoggingProgress();
}
else {
qdocFiles.append(opt);
}

View File

@ -111,7 +111,7 @@ void QDocIndexFiles::destroyQDocIndexFiles()
void QDocIndexFiles::readIndexes(const QStringList& indexFiles)
{
foreach (const QString& indexFile, indexFiles) {
QString msg = " Loading index file: " + indexFile;
QString msg = "Loading index file: " + indexFile;
Location::logToStdErr(msg);
readIndexFile(indexFile);
}
@ -1052,7 +1052,7 @@ void QDocIndexFiles::generateIndex(const QString& fileName,
if (!file.open(QFile::WriteOnly | QFile::Text))
return;
QString msg = " Writing index file: " + fileName;
QString msg = "Writing index file: " + fileName;
Location::logToStdErr(msg);
gen_ = g;