diff --git a/CMakeLists.txt b/CMakeLists.txt index 9223904..dc6f668 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ include(ECMInstallIcons) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) - +include(ECMQtDeclareLoggingCategory) add_definitions( -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS @@ -48,4 +48,5 @@ endif() add_subdirectory(src) add_subdirectory(data) add_subdirectory(doc) +install( FILES kigo.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/kigo.categories b/kigo.categories new file mode 100644 index 0000000..a33a116 --- /dev/null +++ b/kigo.categories @@ -0,0 +1 @@ +org.kde.kdegames.kigo kigo (kdegames) IDENTIFIER [KIGO_LOG] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b54c74..a383a0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,8 @@ ki18n_wrap_ui(kigo_SRCS gui/widgets/gamewidget.ui gui/widgets/setupwidget.ui ) +ecm_qt_declare_logging_category(kigo_SRCS HEADER kigo_debug.h IDENTIFIER KIGO_LOG CATEGORY_NAME org.kde.kdegames.kigo) + kconfig_add_kcfg_files(kigo_SRCS preferences.kcfgc) file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/*-apps-kigo.png") ecm_add_app_icon(kigo_SRCS ICONS ${ICONS_SRCS}) diff --git a/src/game/game.cpp b/src/game/game.cpp index e5dda92..0ca9220 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include "kigo_debug.h" #include namespace Kigo { @@ -72,11 +72,11 @@ bool Game::start(const QString &command) m_process.start(command); // Start new process with provided command if (!m_process.waitForStarted()) { // Blocking wait for process start m_response = QLatin1String("Unable to execute command: ") + command; - //qDebug() << m_response; + //qCDebug(KIGO_LOG) << m_response; return false; } m_engineCommand = command; - ////qDebug() << "Game" << command << "started..."; + ////qCDebug(KIGO_LOG) << "Game" << command << "started..."; // Test if we started a GTP-compatible Go game m_process.write("name\n"); @@ -84,13 +84,13 @@ bool Game::start(const QString &command) const QString response = m_process.readAllStandardOutput(); if (response.isEmpty() || !response.startsWith(QLatin1Char('='))) { m_response = QStringLiteral("Game did not respond to GTP command \"name\""); - //qDebug() << m_response; + //qCDebug(KIGO_LOG) << m_response; stop(); return false; } else { m_engineName = m_response; } - //qDebug() << "Game is a GTP-compatible Go game"; + //qCDebug(KIGO_LOG) << "Game is a GTP-compatible Go game"; m_process.write("version\n"); if (waitResponse()) { @@ -113,7 +113,7 @@ bool Game::init() return false; } - //qDebug() << "Init game!"; + //qCDebug(KIGO_LOG) << "Init game!"; m_process.write("clear_board\n"); if (waitResponse()) { @@ -160,7 +160,7 @@ bool Game::init(const QString &fileName, int moveNumber) if (waitResponse()) { m_fixedHandicap = m_response.toInt(); } - //qDebug() << "Loaded komi is" << m_komi << "and handicap is" << m_fixedHandicap; + //qCDebug(KIGO_LOG) << "Loaded komi is" << m_komi << "and handicap is" << m_fixedHandicap; m_consecutivePassMoveNumber = 0; m_currentMove = moveNumber; @@ -247,7 +247,7 @@ bool Game::setFixedHandicap(int handicap) return false; } } else { - //qWarning() << "Handicap" << handicap << " not set, it is too high!"; + //qCWarning(KIGO_LOG) << "Handicap" << handicap << " not set, it is too high!"; return false; } } @@ -285,7 +285,7 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable) const Player *tmp = &player; if (!tmp->isValid()) { - //qDebug() << "Invalid player argument, using current player!"; + //qCDebug(KIGO_LOG) << "Invalid player argument, using current player!"; tmp = m_currentPlayer; } @@ -339,7 +339,7 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable) undoStr = i18n("Black passed"); } } - //qDebug() << "Push new undo command" << undoStr; + //qCDebug(KIGO_LOG) << "Push new undo command" << undoStr; m_undoStack.push(new UndoCommand(playerTemp, moveType, undoStr)); } @@ -363,7 +363,7 @@ bool Game::generateMove(const Player &player, bool undoable) } const Player *tmp = &player; if (!tmp->isValid()) { - //qDebug() << "Invalid player argument, using current player!"; + //qCDebug(KIGO_LOG) << "Invalid player argument, using current player!"; tmp = m_currentPlayer; } @@ -424,7 +424,7 @@ bool Game::generateMove(const Player &player, bool undoable) } if (undoable) { - //qDebug() << "Push new undo command" << undoStr; + //qCDebug(KIGO_LOG) << "Push new undo command" << undoStr; m_undoStack.push(new UndoCommand(playerTemp, moveType, undoStr)); } if (tmp->isWhite()) { @@ -489,17 +489,17 @@ bool Game::redoMove() const Player *player = undoCmd->player(); if (undoCmd->moveType() == UndoCommand::MoveType::Passed) { - //qDebug() << "Redo a pass move for" << player << undoCmd->text(); + //qCDebug(KIGO_LOG) << "Redo a pass move for" << player << undoCmd->text(); playMove(*player, Stone(), false); // E.g. pass move } else if (undoCmd->moveType() == UndoCommand::MoveType::Resigned) { // Note: Although it is possible to undo after a resign and redo it, // it is a bit questionable whether this makes sense logically. - //qDebug() << "Redo a resign for" << player << undoCmd->text(); + //qCDebug(KIGO_LOG) << "Redo a resign for" << player << undoCmd->text(); emit resigned(*player); m_gameFinished = true; //emit resigned(*m_currentPlayer); } else { - //qDebug() << "Redo a normal move for" << player << undoCmd->text(); + //qCDebug(KIGO_LOG) << "Redo a normal move for" << player << undoCmd->text(); playMove(*player, Stone(undoCmd->text()), false); } m_undoStack.redo(); @@ -722,7 +722,7 @@ bool Game::waitResponse(bool nonBlocking) case QProcess::ReadError: m_response = m_process.readAllStandardError(); break; case QProcess::UnknownError: m_response = QStringLiteral("Unknown error!"); break; } - qWarning() << "Command failed:" << m_response; + qCWarning(KIGO_LOG) << "Command failed:" << m_response; return false; } diff --git a/src/game/move.cpp b/src/game/move.cpp index 80a13cb..e1106c6 100644 --- a/src/game/move.cpp +++ b/src/game/move.cpp @@ -20,7 +20,7 @@ #include "move.h" -#include +#include "kigo_debug.h" namespace Kigo { diff --git a/src/game/player.cpp b/src/game/player.cpp index d2482ec..204197d 100644 --- a/src/game/player.cpp +++ b/src/game/player.cpp @@ -20,7 +20,7 @@ #include "player.h" -#include +#include "kigo_debug.h" namespace Kigo { diff --git a/src/game/stone.cpp b/src/game/stone.cpp index b7c673a..e670f49 100644 --- a/src/game/stone.cpp +++ b/src/game/stone.cpp @@ -20,7 +20,7 @@ #include "stone.h" -#include +#include "kigo_debug.h" namespace Kigo { diff --git a/src/gui/graphicsview/gamescene.cpp b/src/gui/graphicsview/gamescene.cpp index 47cfbee..409fc7a 100644 --- a/src/gui/graphicsview/gamescene.cpp +++ b/src/gui/graphicsview/gamescene.cpp @@ -249,7 +249,7 @@ void GameScene::updateTerritoryItems() if (m_showTerritory) { QPixmap stonePixmap; const int halfCellSize = m_cellSize / 2; - //qDebug() << "Fetching territory from engine ..."; + //qCDebug(KIGO_LOG) << "Fetching territory from engine ..."; stonePixmap = ThemeRenderer::self()->renderElement(ThemeRenderer::Element::WhiteTerritory, QSize(m_cellSize, m_cellSize)); foreach (const Stone &stone, m_game->finalStates(Game::FinalState::FinalWhiteTerritory)) { diff --git a/src/gui/graphicsview/themerenderer.cpp b/src/gui/graphicsview/themerenderer.cpp index 5666e55..42e1715 100644 --- a/src/gui/graphicsview/themerenderer.cpp +++ b/src/gui/graphicsview/themerenderer.cpp @@ -38,7 +38,7 @@ ThemeRenderer::ThemeRenderer() { QPixmapCache::setCacheLimit(3 * 1024); if (!loadTheme(Preferences::theme())) { - //qDebug() << "Failed to load any game theme!"; + //qCDebug(KIGO_LOG) << "Failed to load any game theme!"; } } @@ -52,7 +52,7 @@ bool ThemeRenderer::loadTheme(const QString &themeName) bool discardCache = !m_currentTheme.isEmpty(); if (!m_currentTheme.isEmpty() && m_currentTheme == themeName) { - //qDebug() << "Notice: Loading the same theme"; + //qCDebug(KIGO_LOG) << "Notice: Loading the same theme"; return true; // We don't have to do anything } @@ -60,8 +60,8 @@ bool ThemeRenderer::loadTheme(const QString &themeName) KGameTheme theme; if (themeName.isEmpty() || !theme.load(themeName)) { - //qDebug() << "Failed to load theme" << Preferences::theme(); - //qDebug() << "Trying to load default"; + //qCDebug(KIGO_LOG) << "Failed to load theme" << Preferences::theme(); + //qCDebug(KIGO_LOG) << "Trying to load default"; if (!theme.loadDefault()) { return true; } @@ -70,13 +70,13 @@ bool ThemeRenderer::loadTheme(const QString &themeName) m_currentTheme = QStringLiteral("default"); } - //qDebug() << "Loading" << theme.graphics(); + //qCDebug(KIGO_LOG) << "Loading" << theme.graphics(); if (!m_renderer->load(theme.graphics())) { return false; } if (discardCache) { - //qDebug() << "Discarding cache"; + //qCDebug(KIGO_LOG) << "Discarding cache"; QPixmapCache::clear(); } emit themeChanged(m_currentTheme); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 471623e..e092857 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -268,7 +268,7 @@ void MainWindow::finishGame() m_undoView->setEnabled(false); - //qDebug() << "Fetching final score from engine ..."; + //qCDebug(KIGO_LOG) << "Fetching final score from engine ..."; Score score = m_game->estimatedScore(); QString name; if (score.color() == QLatin1Char('W')) { @@ -333,7 +333,7 @@ void MainWindow::showPreferences() void MainWindow::applyPreferences() { - //qDebug() << "Update settings based on changed configuration..."; + //qCDebug(KIGO_LOG) << "Update settings based on changed configuration..."; m_gameScene->showLabels(Preferences::showBoardLabels()); ThemeRenderer::self()->loadTheme(Preferences::theme()); diff --git a/src/gui/widgets/gamewidget.cpp b/src/gui/widgets/gamewidget.cpp index a29189a..0a63cd0 100644 --- a/src/gui/widgets/gamewidget.cpp +++ b/src/gui/widgets/gamewidget.cpp @@ -45,7 +45,7 @@ GameWidget::GameWidget(Game *game, QWidget *parent) void GameWidget::init() { if (!m_game->isRunning()) { - //qDebug() << "Game is not running, no information update"; + //qCDebug(KIGO_LOG) << "Game is not running, no information update"; return; }