From aca24f114627b66e902b4621326cf2b8bc8dbcf6 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 25 Oct 2012 14:01:11 +0200 Subject: qdoc: Adding the -log-progress option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jędrzej Nowacki Reviewed-by: Martin Smith --- src/tools/qdoc/location.cpp | 10 +++++++--- src/tools/qdoc/location.h | 3 +++ src/tools/qdoc/main.cpp | 9 ++++++--- src/tools/qdoc/qdocindexfiles.cpp | 4 ++-- 4 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qdoc/location.cpp b/src/tools/qdoc/location.cpp index 48e5d6153c..ca6521c002 100644 --- a/src/tools/qdoc/location.cpp +++ b/src/tools/qdoc/location.cpp @@ -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); + } } /*! diff --git a/src/tools/qdoc/location.h b/src/tools/qdoc/location.h index 71492e619f..0d22e94b46 100644 --- a/src/tools/qdoc/location.h +++ b/src/tools/qdoc/location.h @@ -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 diff --git a/src/tools/qdoc/main.cpp b/src/tools/qdoc/main.cpp index d46580bbea..c70160f6ec 100644 --- a/src/tools/qdoc/main.cpp +++ b/src/tools/qdoc/main.cpp @@ -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); } diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index 6d697c61b0..33b489d6d0 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -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; -- cgit v1.2.3