From 1639c9a80490fc56c2bb1438dfa0d84455be55ed Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Fri, 9 Aug 2019 13:46:08 +0200 Subject: QDoc: Move logging to helper method Change-Id: I39d10454442178e6f1292d136eea8ee990ad162f Reviewed-by: Edward Welbourne --- src/qdoc/main.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index 2b2b7a6f8..79cb471ce 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -223,6 +223,27 @@ static void loadIndexFiles(Config &config, const QSet &formats) qdb->readIndexes(indexFiles); } +/*! + \internal + Prints to stderr the name of the project that QDoc is running for, + in which mode and which phase. + + If QDoc is running in debug mode, also logs the command line arguments. + */ +void logStartEndMessage(const QLatin1String &startStop, const Config &config) +{ + const QString runName = " qdoc for " + + config.getString(CONFIG_PROJECT) + + QLatin1String(" in ") + + QLatin1String(Generator::singleExec() ? "single" : "dual") + + QLatin1String(" process mode, (") + + QLatin1String(Generator::preparing() ? "prepare" : "generate") + + QLatin1String(" phase)"); + + const QString msg = startStop + runName; + Location::logToStdErrAlways(msg); +} + /*! Processes the qdoc config file \a fileName. This is the controller for all of QDoc. The \a config instance represents the configuration data for QDoc. @@ -255,22 +276,13 @@ static void processQdocconfFile(const QString &fileName, Config &config) if (!config.currentDir().isEmpty()) QDir::setCurrent(config.currentDir()); - QString phase = " in "; - if (Generator::singleExec()) - phase += "single process mode, "; - else - phase += "dual process mode, "; - if (Generator::preparing()) - phase += "(prepare phase)"; - else if (Generator::generating()) - phase += "(generate phase)"; + logStartEndMessage(QLatin1String("Start"), config); - QString msg = "Start qdoc for " + config.getString(CONFIG_PROJECT) + phase; - Location::logToStdErrAlways(msg); if (config.getDebug()) { Utilities::startDebugging(QString("command line")); qCDebug(lcQdoc).noquote() << "Arguments:" << QCoreApplication::arguments(); } + /* Initialize all the classes and data structures with the qdoc configuration. This is safe to do for each qdocconf @@ -505,8 +517,7 @@ static void processQdocconfFile(const QString &fileName, Config &config) if (Utilities::debugging()) Utilities::stopDebugging(project); - msg = "End qdoc for " + config.getString(CONFIG_PROJECT) + phase; - Location::logToStdErrAlways(msg); + logStartEndMessage(QLatin1String("End"), config); QDocDatabase::qdocDB()->setVersion(QString()); Generator::terminate(); CodeParser::terminate(); -- cgit v1.2.3