From 7dc1a5eda3cd596ed0b018850a8ebc3414176c23 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 19 Jun 2015 02:23:44 +0300 Subject: [PATCH] implement datetime logging feature --- sources/.kdev4/netctl-gui.kdev4 | 2 +- sources/3rdparty/pdebug | 2 +- sources/dataengine/CMakeLists.txt | 7 ++++++- sources/dataengine/netctl.cpp | 4 ++++ sources/gui/src/CMakeLists.txt | 13 ++++++++++--- sources/gui/src/main.cpp | 7 +++++++ sources/helper/src/CMakeLists.txt | 13 ++++++++++--- sources/helper/src/main.cpp | 5 +++++ sources/netctlgui/src/CMakeLists.txt | 7 ++++++- sources/plasmoid-kf5/plugin/CMakeLists.txt | 3 ++- sources/plasmoid-kf5/plugin/netctladds.cpp | 9 +++++++++ 11 files changed, 61 insertions(+), 11 deletions(-) diff --git a/sources/.kdev4/netctl-gui.kdev4 b/sources/.kdev4/netctl-gui.kdev4 index 587b19d..d7d83c5 100644 --- a/sources/.kdev4/netctl-gui.kdev4 +++ b/sources/.kdev4/netctl-gui.kdev4 @@ -8,7 +8,7 @@ ProjectRootRelative=./ [CMake][CMake Build Directory 0] Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build -Build Type=Debug +Build Type=Release CMake Binary=file:///usr/bin/cmake Environment Profile= Extra Arguments= diff --git a/sources/3rdparty/pdebug b/sources/3rdparty/pdebug index 9be4fe3..75e4a0d 160000 --- a/sources/3rdparty/pdebug +++ b/sources/3rdparty/pdebug @@ -1 +1 @@ -Subproject commit 9be4fe36819cc48a574b5f649ddb210b432e2097 +Subproject commit 75e4a0df83478802bba53345486b42c56713fe09 diff --git a/sources/dataengine/CMakeLists.txt b/sources/dataengine/CMakeLists.txt index 12553f9..9805f39 100644 --- a/sources/dataengine/CMakeLists.txt +++ b/sources/dataengine/CMakeLists.txt @@ -39,7 +39,12 @@ include_directories (${CMAKE_SOURCE_DIR} set (PLUGIN_NAME ${SUBPROJECT}) file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN}) -file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp) +if (BUILD_KDE4) + file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp) +else () + file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp + ${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp) +endif () set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h) file (GLOB SUBPROJECT_CONF *.conf) diff --git a/sources/dataengine/netctl.cpp b/sources/dataengine/netctl.cpp index 3460826..44fae30 100644 --- a/sources/dataengine/netctl.cpp +++ b/sources/dataengine/netctl.cpp @@ -36,6 +36,7 @@ #include #else #include +#include #endif /* BUILD_KDE4 */ @@ -44,6 +45,9 @@ Netctl::Netctl(QObject *parent, const QVariantList &args) { Q_UNUSED(args) +#if QT_VERSION >= 0x050000 + qInstallMessageHandler(debugString); +#endif /* QT_VERSION >= 0x050000 */ // debug QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); QString debugEnv = environment.value(QString("DEBUG"), QString("no")); diff --git a/sources/gui/src/CMakeLists.txt b/sources/gui/src/CMakeLists.txt index 8081317..ed55285 100644 --- a/sources/gui/src/CMakeLists.txt +++ b/sources/gui/src/CMakeLists.txt @@ -1,7 +1,14 @@ # set files -file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp - ${PROJECT_TRDPARTY_DIR}/language/*.cpp - ${PROJECT_TRDPARTY_DIR}/listmap/*.cpp) +if (USE_QT5) + file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp + ${PROJECT_TRDPARTY_DIR}/language/*.cpp + ${PROJECT_TRDPARTY_DIR}/listmap/*.cpp + ${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp) +else () + file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp + ${PROJECT_TRDPARTY_DIR}/language/*.cpp + ${PROJECT_TRDPARTY_DIR}/listmap/*.cpp) +endif () file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h ${PROJECT_TRDPARTY_DIR}/language/*.h) file (GLOB_RECURSE FORMS *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui) diff --git a/sources/gui/src/main.cpp b/sources/gui/src/main.cpp index 86a6a85..73af727 100644 --- a/sources/gui/src/main.cpp +++ b/sources/gui/src/main.cpp @@ -32,6 +32,10 @@ #include "messages.h" #include "version.h" +#if QT_VERSION >= 0x050000 +#include +#endif /* QT_VERSION >= 0x050000 */ + using namespace std; @@ -157,6 +161,9 @@ int main(int argc, char *argv[]) // detach from console if (args[QString("detached")].toBool()) daemon(0, 0); +#if QT_VERSION >= 0x050000 + qInstallMessageHandler(debugString); +#endif QApplication a(argc, argv); QApplication::setQuitOnLastWindowClosed(false); // reread translations according to flags diff --git a/sources/helper/src/CMakeLists.txt b/sources/helper/src/CMakeLists.txt index d4757dd..7ba6256 100644 --- a/sources/helper/src/CMakeLists.txt +++ b/sources/helper/src/CMakeLists.txt @@ -1,7 +1,14 @@ # set files -file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp - ${PROJECT_TRDPARTY_DIR}/language/*.cpp - ${PROJECT_TRDPARTY_DIR}/listmap/*.cpp) +if (USE_QT5) + file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp + ${PROJECT_TRDPARTY_DIR}/language/*.cpp + ${PROJECT_TRDPARTY_DIR}/listmap/*.cpp + ${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp) +else () + file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp + ${PROJECT_TRDPARTY_DIR}/language/*.cpp + ${PROJECT_TRDPARTY_DIR}/listmap/*.cpp) +endif () file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h ${PROJECT_TRDPARTY_DIR}/language/*.h) diff --git a/sources/helper/src/main.cpp b/sources/helper/src/main.cpp index 32a5fd1..1809d00 100644 --- a/sources/helper/src/main.cpp +++ b/sources/helper/src/main.cpp @@ -32,6 +32,10 @@ #include "netctlhelper.h" #include "version.h" +#if QT_VERSION >= 0x050000 +#include +#endif /* QT_VERSION >= 0x050000 */ + using namespace std; @@ -115,6 +119,7 @@ int main(int argc, char *argv[]) #if QT_VERSION >= 0x050000 QCoreApplication::setSetuidAllowed(true); + qInstallMessageHandler(debugString); #endif QCoreApplication a(argc, argv); // reread translations according to flags diff --git a/sources/netctlgui/src/CMakeLists.txt b/sources/netctlgui/src/CMakeLists.txt index d9ead4f..025f632 100644 --- a/sources/netctlgui/src/CMakeLists.txt +++ b/sources/netctlgui/src/CMakeLists.txt @@ -1,5 +1,10 @@ # set files -file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp) +if (USE_QT5) + file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp + ${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp) +else () + file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp) +endif () file (GLOB_RECURSE HEADERS *.h ${SUBPROJECT_INCLUDE_DIR}/*h ${PROJECT_TRDPARTY_DIR}/task/*.h) diff --git a/sources/plasmoid-kf5/plugin/CMakeLists.txt b/sources/plasmoid-kf5/plugin/CMakeLists.txt index 9bd0efd..b69c4b6 100644 --- a/sources/plasmoid-kf5/plugin/CMakeLists.txt +++ b/sources/plasmoid-kf5/plugin/CMakeLists.txt @@ -21,7 +21,8 @@ include_directories (${CMAKE_SOURCE_DIR} ${Qt_INCLUDE} ${Kf5_INCLUDE}) -file (GLOB SUBPROJECT_SOURCE *.cpp) +file (GLOB_RECURSE SUBPROJECT_SOURCE ${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp + *.cpp) file (GLOB SUBPROJECT_NOTIFY *.notifyrc) add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE}) diff --git a/sources/plasmoid-kf5/plugin/netctladds.cpp b/sources/plasmoid-kf5/plugin/netctladds.cpp index 4a9b5a5..d55a158 100644 --- a/sources/plasmoid-kf5/plugin/netctladds.cpp +++ b/sources/plasmoid-kf5/plugin/netctladds.cpp @@ -27,6 +27,7 @@ #include #include +#include #include "netctladds.h" #include "version.h" @@ -35,6 +36,7 @@ NetctlAdds::NetctlAdds(QObject *parent) : QObject(parent) { + qInstallMessageHandler(debugString); // debug QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); QString debugEnv = environment.value(QString("DEBUG"), QString("no")); @@ -169,6 +171,13 @@ void NetctlAdds::setDataBySource(const QString sourceName, const QVariantMap dat void NetctlAdds::sendNotification(const QString eventId, const QString message) { + QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); + QString debugEnv = environment.value(QString("DEBUG"), QString("no")); + bool debugLocal = (debugEnv == QString("yes")); + if (debugLocal) qDebug() << PDEBUG; + if (debugLocal) qDebug() << PDEBUG << ":" << "Event" << eventId; + if (debugLocal) qDebug() << PDEBUG << ":" << "Message" << message; + KNotification *notification = KNotification::event(eventId, QString("Netctl ::: %1").arg(eventId), message); notification->setComponentName(QString("plasma-applet-org.kde.plasma.netctl")); }