diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ include(ECMSetupVersion) include(ECMMarkNonGuiExecutable) +include(ECMQtDeclareLoggingCategory) include(CMakePackageConfigHelpers) include(GenerateExportHeader) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,8 +25,15 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_custom_dtd_kdex}.install DESTINATION ${KDE_INSTALL_DATADIR_KF5}/kdoctools/customization/dtd RENAME ${_custom_dtd_kdex_name}) endif() +ecm_qt_declare_logging_category(kdoctoolslog_core_SRCS + HEADER loggingcategory.h + IDENTIFIER KDocToolsLog + CATEGORY_NAME kf5.kdoctools + DEFAULT_SEVERITY Warning +) + # needed by KIO, need to export it -add_library(KF5DocTools SHARED xslt.cpp xslt_kde.cpp) +add_library(KF5DocTools SHARED xslt.cpp xslt_kde.cpp ${kdoctoolslog_core_SRCS}) generate_export_header(KF5DocTools BASE_NAME KDocTools EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/kdoctools_export.h") add_library(KF5::DocTools ALIAS KF5DocTools) if (NOT MEINPROC_NO_KARCHIVE) @@ -102,7 +109,7 @@ set(meinproc_additional_LIBS KF5::Archive) endif() -add_executable(meinproc5 meinproc.cpp meinproc_common.cpp xslt.cpp ${meinproc_additional_SRCS}) +add_executable(meinproc5 meinproc.cpp meinproc_common.cpp xslt.cpp ${meinproc_additional_SRCS} ${kdoctoolslog_core_SRCS}) ecm_mark_nongui_executable(meinproc5) target_link_libraries(meinproc5 Qt5::Core KF5::DocTools ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBXSLT_EXSLT_LIBRARIES} ${meinproc_additional_LIBS}) install(TARGETS meinproc5 EXPORT KF5DocToolsTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) @@ -198,7 +205,7 @@ ########### l10n xml helper ############### -set( docbookl10nhelper_SRCS docbookl10nhelper.cpp ) +set( docbookl10nhelper_SRCS docbookl10nhelper.cpp ${kdoctoolslog_core_SRCS}) add_executable( docbookl10nhelper ${docbookl10nhelper_SRCS} ) ecm_mark_nongui_executable( docbookl10nhelper ) target_link_libraries( docbookl10nhelper Qt5::Core ) @@ -225,7 +232,7 @@ ########### checkxml5 helper ############### -set( checkXML5_SRCS checkXML5.cpp ) +set( checkXML5_SRCS checkXML5.cpp ${kdoctoolslog_core_SRCS}) add_executable( checkXML5 ${checkXML5_SRCS} ) ecm_mark_nongui_executable( checkXML5 ) target_link_libraries( checkXML5 Qt5::Core ) diff --git a/src/checkXML5.cpp b/src/checkXML5.cpp --- a/src/checkXML5.cpp +++ b/src/checkXML5.cpp @@ -18,6 +18,8 @@ License along with this library. If not, see . */ +#include "loggingcategory.h" + #include #include #include @@ -30,7 +32,7 @@ const QStringList arguments = app.arguments(); if (arguments.count() != 2) { - qCritical() << "wrong argument count"; + qCCritical(KDocToolsLog) << "wrong argument count"; return (1); } diff --git a/src/docbookl10nhelper.cpp b/src/docbookl10nhelper.cpp --- a/src/docbookl10nhelper.cpp +++ b/src/docbookl10nhelper.cpp @@ -18,6 +18,8 @@ License along with this library. If not, see . */ +#include "loggingcategory.h" + #include #include #include @@ -50,8 +52,8 @@ QFile outFile(fname); if (! outFile.open(QIODevice::WriteOnly)) { - qCritical() << QStringLiteral("Could not write %1") - .arg(outFile.fileName()); + qCCritical(KDocToolsLog) << QStringLiteral("Could not write %1") + .arg(outFile.fileName()); return (1); } @@ -62,7 +64,7 @@ LangListType::const_iterator i = langMap.constBegin(); while (i != langMap.constEnd()) { - //qDebug() << (*i).first << ": " << (*i).second; + //qCDebug(KDocToolsLog) << (*i).first << ": " << (*i).second; outStream << QStringLiteral("") .arg((*i).first).arg((*i).second) << endl; ++i; @@ -93,8 +95,8 @@ QFile outFile(fname); if (! outFile.open(QIODevice::WriteOnly)) { - qCritical() << QStringLiteral("Could not write %1") - .arg(outFile.fileName()); + qCCritical(KDocToolsLog) << QStringLiteral("Could not write %1") + .arg(outFile.fileName()); return (1); } @@ -132,7 +134,7 @@ const QStringList arguments = app.arguments(); if (arguments.count() != 4) { - qCritical() << "wrong argument count"; + qCCritical(KDocToolsLog) << "wrong argument count"; return (1); } @@ -143,7 +145,7 @@ QFile i18nFile(l10nDir + QStringLiteral("common/l10n.xml")); if (! i18nFile.open(QIODevice::ReadOnly)) { - qCritical() << i18nFile.fileName() << " not found"; + qCCritical(KDocToolsLog) << i18nFile.fileName() << " not found"; return (1); } @@ -173,10 +175,10 @@ case 0: if (rxDocType.indexIn(line) != -1) { parsingState = 1; - //qDebug() << "DTD found"; + //qCDebug(KDocToolsLog) << "DTD found"; } else if (rxDocType2.indexIn(line) != -1) { parsingState = 1; - //qDebug() << "DTD found"; + //qCDebug(KDocToolsLog) << "DTD found"; } break; case 1: @@ -186,13 +188,13 @@ langCode = rxEntity.cap(1); langFile = l10nDir + QStringLiteral("common/") + rxEntity.cap(2); allLangs += qMakePair(langCode, langFile); - //qDebug() << langCode << " - " << langFile; + //qCDebug(KDocToolsLog) << langCode << " - " << langFile; } else if (rxEntity2.indexIn(line) != -1 && !foundRxEntity) { foundRxEntity2 = true; langCode = rxEntity2.cap(1); langFile = l10nDir + QStringLiteral("common/") + rxEntity2.cap(2); allLangs += qMakePair(langCode, langFile); - //qDebug() << langCode << " - " << langFile; + //qCDebug(KDocToolsLog) << langCode << " - " << langFile; } break; } @@ -213,7 +215,7 @@ */ customLangFiles.removeOne(QStringLiteral("all-l10n.xml")); customLangFiles.removeOne(QStringLiteral("kde-custom-l10n.xml")); - //qDebug() << "customLangFiles:" << customLangFiles; + //qCDebug(KDocToolsLog) << "customLangFiles:" << customLangFiles; /* * for each custom language (from directory listing), if it is not diff --git a/src/meinproc.cpp b/src/meinproc.cpp --- a/src/meinproc.cpp +++ b/src/meinproc.cpp @@ -3,6 +3,7 @@ #include "docbookxslt.h" #include "docbookxslt_p.h" #include "meinproc_common.h" +#include "loggingcategory.h" #include #include @@ -48,7 +49,7 @@ typedef QList PairList; -#define DIE(x) do { qCritical() << "Error:" << x; exit(1); } while (0) +#define DIE(x) do { qCCritical(KDocToolsLog) << "Error:" << x; exit(1); } while (0) void parseEntry(PairList &list, xmlNodePtr cur, int base) { @@ -202,7 +203,7 @@ const QString cache = parser.value(QStringLiteral("cache")); #else if (parser.isSet("cache")) { - qWarning() << QCoreApplication::translate("main", "The cache option is not available, please re-compile with KArchive support. See MEINPROC_NO_KARCHIVE in KDocTools"); + qCWarning(KDocToolsLog) << QCoreApplication::translate("main", "The cache option is not available, please re-compile with KArchive support. See MEINPROC_NO_KARCHIVE in KDocTools"); } #endif const bool usingStdOut = parser.isSet(QStringLiteral("stdout")); @@ -217,7 +218,7 @@ #ifndef MEINPROC_NO_KARCHIVE if (!cache.isEmpty()) { if (!saveToCache(output, cache)) { - qWarning() << QCoreApplication::translate("main", "Could not write to cache file %1.").arg(cache); + qCWarning(KDocToolsLog) << QCoreApplication::translate("main", "Could not write to cache file %1.").arg(cache); } goto end; } diff --git a/src/meinproc_common.h b/src/meinproc_common.h --- a/src/meinproc_common.h +++ b/src/meinproc_common.h @@ -2,7 +2,6 @@ #ifndef MEINPROC_COMMON_H #define MEINPROC_COMMON_H -#include #include enum CheckFileResult { diff --git a/src/xslt.cpp b/src/xslt.cpp --- a/src/xslt.cpp +++ b/src/xslt.cpp @@ -8,6 +8,7 @@ #endif #include "../config-kdoctools.h" +#include "loggingcategory.h" #include #include @@ -67,7 +68,7 @@ for (i = replaceURLList.constBegin(); i != replaceURLList.constEnd(); i++) { if (url.startsWith(i.key())) { url.replace(i.key(), i.value()); - qDebug() << "converted" << _URL << "to" << url; + qCDebug(KDocToolsLog) << "converted" << _URL << "to" << url; } } char URL[1024]; @@ -96,7 +97,7 @@ if (warning != NULL) { ctxt->sax->warning = warning; } - qDebug() << "Loaded URL=\"" << URL << "\" ID=\"" << ID << "\""; + qCDebug(KDocToolsLog) << "Loaded URL=\"" << URL << "\" ID=\"" << ID << "\""; return (ret); } } @@ -112,7 +113,7 @@ if (warning != NULL) { ctxt->sax->warning = warning; } - qDebug() << "Loaded URL=\"" << newURL << "\" ID=\"" << ID << "\""; + qCDebug(KDocToolsLog) << "Loaded URL=\"" << newURL << "\" ID=\"" << ID << "\""; xmlFree(newURL); return (ret); } @@ -257,11 +258,11 @@ int endindex = parsed.indexOf(QStringLiteral(""), index); int startindex = parsed.indexOf(QStringLiteral(" 0) { if (startindex < endindex) { - // //qDebug() << "finding another"; + //qCDebug(KDocToolsLog) << "finding another"; index = startindex + 8; inside++; } else { @@ -396,7 +397,7 @@ catalogs += QUrl::fromLocalFile(srcdir + QStringLiteral("/customization/catalog.xml")).toEncoded(); s_dtdDirs()->srcdir = srcdir; } - //qDebug() << "XML_CATALOG_FILES: " << catalogs; + //qCDebug(KDocToolsLog) << "XML_CATALOG_FILES: " << catalogs; qputenv("XML_CATALOG_FILES", catalogs); xmlInitializeCatalog(); } @@ -420,7 +421,7 @@ if (QFile::exists(test)) { return QStringList() << test; } - qDebug() << "Could not locate file" << file << "in" << srcdir; + qCDebug(KDocToolsLog) << "Could not locate file" << file << "in" << srcdir; return QStringList(); } // Using locateAll() is necessary to be able to find all catalogs when @@ -444,7 +445,7 @@ } if (result.isEmpty()) { - qDebug() << "Could not locate file" << fileName << "in" << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + qCDebug(KDocToolsLog) << "Could not locate file" << fileName << "in" << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); } return result; } @@ -478,6 +479,6 @@ foreach (const QString &aCatalog, catalogFiles) { catalogs << aCatalog; } - //qDebug() << "Found catalogs: " << catalogs; + //qCDebug(KDocToolsLog) << "Found catalogs: " << catalogs; return catalogs; } diff --git a/src/xslt_kde.cpp b/src/xslt_kde.cpp --- a/src/xslt_kde.cpp +++ b/src/xslt_kde.cpp @@ -2,6 +2,7 @@ #ifndef MEINPROC_NO_KARCHIVE #include #else +#include "loggingcategory.h" #include #endif @@ -17,7 +18,7 @@ fd.write(contents.toUtf8()); fd.close(); #else - qWarning() << "This function is dummy because KArchive support has been disabled. " + qCWarning(KDocToolsLog) << "This function is dummy because KArchive support has been disabled. " "This mode should be enabled only for specific usage on KDE infrastructure."; Q_UNUSED(contents) Q_UNUSED(filename)