1
0
mirror of https://invent.kde.org/network/krfb synced 2024-07-01 07:24:29 +00:00

Declare and use logging categories

Adds the following logging categories:
- krfb.krfb (KRFB application)
- krfb.framebuffer.qt (Qt Framebuffer plugin)
- krfb.framebuffer.xcb (XCB Framebuffer plugin)
This commit is contained in:
Stefan Brüns 2020-08-11 19:50:46 +02:00
parent b135370c5c
commit 76c2f08c9e
13 changed files with 79 additions and 48 deletions

View File

@ -9,7 +9,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
project(krfb VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION 5.10.0)
set(KF5_MIN_VERSION 5.31.0)
set(KF5_MIN_VERSION 5.68.0)
find_package(ECM ${KF5_MIN_VERSION} NO_MODULE REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ${ECM_MODULE_PATH})
@ -20,6 +20,7 @@ include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMSetupVersion)
include(ECMQtDeclareLoggingCategory)
include(FeatureSummary)
include(CheckIncludeFile)
@ -103,4 +104,10 @@ add_subdirectory(framebuffers)
add_subdirectory(doc)
add_subdirectory(icons)
ecm_qt_install_logging_categories(
EXPORT KRFB
FILE krfb.categories
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)

View File

@ -7,6 +7,14 @@ set (krfb_framebuffer_qt_SRCS
qtframebufferplugin.cpp
)
ecm_qt_declare_logging_category(krfb_framebuffer_qt_SRCS
HEADER krfb_fb_qt_debug.h
IDENTIFIER KRFB_FB_QT
CATEGORY_NAME krfb.framebuffer.qt
DESCRIPTION "KRFB Qt framebuffer plugin"
EXPORT KRFB
)
add_library(krfb_framebuffer_qt
MODULE
${krfb_framebuffer_qt_SRCS}

View File

@ -7,6 +7,14 @@ set (krfb_framebuffer_xcb_SRCS
xcb_framebuffer.cpp
)
ecm_qt_declare_logging_category(krfb_framebuffer_xcb_SRCS
HEADER krfb_fb_xcb_debug.h
IDENTIFIER KRFB_FB_XCB
CATEGORY_NAME krfb.framebuffer.xcb
DESCRIPTION "KRFB XCB framebuffer plugin"
EXPORT KRFB
)
add_library(krfb_framebuffer_xcb MODULE ${krfb_framebuffer_xcb_SRCS})
target_link_libraries (krfb_framebuffer_xcb

View File

@ -8,6 +8,7 @@
*/
#include "xcb_framebuffer.h"
#include "krfb_fb_xcb_debug.h"
#include <xcb/xcb.h>
#include <xcb/xproto.h>
@ -23,7 +24,6 @@
#include <QGuiApplication>
#include <QScreen>
#include <QAbstractNativeEventFilter>
#include <QDebug>
class KrfbXCBEventFilter: public QAbstractNativeEventFilter
@ -68,7 +68,7 @@ KrfbXCBEventFilter::KrfbXCBEventFilter(XCBFrameBuffer *owner):
}
#ifdef _DEBUG
qDebug() << "xcb framebuffer: XDamage extension version:" <<
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: XDamage extension version:" <<
xdamage_version->major_version << "." << xdamage_version->minor_version;
#endif
@ -163,7 +163,7 @@ XCBFrameBuffer::XCBFrameBuffer(WId winid, QObject *parent):
QScreen *primaryScreen = QGuiApplication::primaryScreen();
if (primaryScreen) {
qDebug() << "xcb framebuffer: Primary screen: " << primaryScreen->name()
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Primary screen: " << primaryScreen->name()
<< ", geometry: " << primaryScreen->geometry()
<< ", depth: " << primaryScreen->depth();
//
@ -183,7 +183,7 @@ XCBFrameBuffer::XCBFrameBuffer(WId winid, QObject *parent):
XCB_IMAGE_FORMAT_Z_PIXMAP);
if (d->framebufferImage) {
#ifdef _DEBUG
qDebug() << "xcb framebuffer: Got primary screen image. bpp: " << d->framebufferImage->bpp
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Got primary screen image. bpp: " << d->framebufferImage->bpp
<< ", size (" << d->framebufferImage->width << d->framebufferImage->height << ")"
<< ", depth: " << d->framebufferImage->depth
<< ", padded width: " << d->framebufferImage->stride;
@ -211,15 +211,15 @@ XCBFrameBuffer::XCBFrameBuffer(WId winid, QObject *parent):
nullptr); // data = 0
if (d->updateTile) {
#ifdef _DEBUG
qDebug() << "xcb framebuffer: Successfully created new empty image in native format";
qDebug() << " size: " << d->updateTile->width << "x" << d->updateTile->height
<< "(stride: " << d->updateTile->stride << ")";
qDebug() << " bpp, depth: " << d->updateTile->bpp << d->updateTile->depth; // 32, 24
qDebug() << " addr of base, data: " << d->updateTile->base << (void *)d->updateTile->data;
qDebug() << " size: " << d->updateTile->size;
qDebug() << " image byte order = " << d->updateTile->byte_order; // == 0 .._LSB_FIRST
qDebug() << " image bit order = " << d->updateTile->bit_order; // == 1 .._MSB_FIRST
qDebug() << " image plane_mask = " << d->updateTile->plane_mask; // == 16777215 == 0x00FFFFFF
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: Successfully created new empty image in native format"
<< "\n size: " << d->updateTile->width << "x" << d->updateTile->height
<< "(stride: " << d->updateTile->stride << ")"
<< "\n bpp, depth: " << d->updateTile->bpp << d->updateTile->depth // 32, 24
<< "\n addr of base, data: " << d->updateTile->base << (void *)d->updateTile->data
<< "\n size: " << d->updateTile->size
<< "\n image byte order = " << d->updateTile->byte_order // == 0 .._LSB_FIRST
<< "\n image bit order = " << d->updateTile->bit_order // == 1 .._MSB_FIRST
<< "\n image plane_mask = " << d->updateTile->plane_mask; // == 16777215 == 0x00FFFFFF
#endif
// allocate shared memory block only once, make its size large enough
@ -237,7 +237,7 @@ XCBFrameBuffer::XCBFrameBuffer(WId winid, QObject *parent):
xcb_shm_attach(QX11Info::connection(), d->shminfo.shmseg, d->shminfo.shmid, 0);
#ifdef _DEBUG
qDebug() << " shm id: " << d->shminfo.shmseg << ", addr: " << (void *)d->shminfo.shmaddr;
qCDebug(KRFB_FB_XCB) << " shm id: " << d->shminfo.shmseg << ", addr: " << (void *)d->shminfo.shmaddr;
#endif
// will return 1 on success (yes!)
@ -273,7 +273,7 @@ XCBFrameBuffer::XCBFrameBuffer(WId winid, QObject *parent):
}
#ifdef _DEBUG
qDebug() << "xcb framebuffer: XCBFrameBuffer(), xshm base event = " << d->x11EvtFilter->xshmBaseEvent
qCDebug(KRFB_FB_XCB) << "xcb framebuffer: XCBFrameBuffer(), xshm base event = " << d->x11EvtFilter->xshmBaseEvent
<< ", xshm base error = " << d->x11EvtFilter->xdamageBaseError
<< ", xdamage base event = " << d->x11EvtFilter->xdamageBaseEvent
<< ", xdamage base error = " << d->x11EvtFilter->xdamageBaseError;
@ -420,10 +420,12 @@ void XCBFrameBuffer::getServerFormat(rfbPixelFormat &format) {
format.blueMax = root_visualtype->blue_mask >> format.blueShift;
#ifdef _DEBUG
qDebug() << " Calculated redShift =" << (int)format.redShift;
qDebug() << " Calculated greenShift =" << (int)format.greenShift;
qDebug() << " Calculated blueShift =" << (int)format.blueShift;
qDebug( " Calculated max values: R%d G%d B%d",
qCDebug(KRFB_FB_XCB,
" Calculated redShift = %d\n"
" Calculated greenShift = %d\n"
" Calculated blueShift = %d\n"
" Calculated max values: R%d G%d B%d",
format.redShift, format.greenShift, format.blueShift
format.redMax, format.greenMax, format.blueMax);
#endif
} else {

View File

@ -66,6 +66,14 @@ set (krfb_SRCS
invitationsrfbclient.cpp
)
ecm_qt_declare_logging_category(krfb_SRCS
HEADER krfbdebug.h
IDENTIFIER KRFB
CATEGORY_NAME krfb.krfb
DESCRIPTION "KRFB Application"
EXPORT KRFB
)
kconfig_add_kcfg_files (krfb_SRCS
krfbconfig.kcfgc
)

View File

@ -23,8 +23,8 @@
#include "eventsplugin.h"
#include "krfbconfig.h"
#include "rfbservermanager.h"
#include "krfbdebug.h"
#include <QDebug>
#include <QGlobalStatic>
#include <KPluginFactory>
@ -79,18 +79,18 @@ void EventsManager::loadPlugins()
KPluginFactory *factory = KPluginLoader(data.fileName()).factory();
if (!factory) {
qDebug() << "KPluginFactory could not load the plugin:" << data.fileName();
qCDebug(KRFB) << "KPluginFactory could not load the plugin:" << data.fileName();
continue;
} else {
qDebug() << "found plugin at " << data.fileName();
qCDebug(KRFB) << "found plugin at " << data.fileName();
}
EventsPlugin *plugin = factory->create<EventsPlugin>(this);
if (plugin) {
m_plugins.insert(data.pluginId(), plugin);
qDebug() << "Loaded plugin with name " << data.pluginId();
qCDebug(KRFB) << "Loaded plugin with name " << data.pluginId();
} else {
qDebug() << "unable to load plugin for " << data.fileName();
qCDebug(KRFB) << "unable to load plugin for " << data.fileName();
}
unique.insert (data.name());
}
@ -113,6 +113,6 @@ QSharedPointer<EventHandler> EventsManager::eventHandler()
}
// No valid events plugin found.
qDebug() << "No valid event handlers found. returning null.";
qCDebug(KRFB) << "No valid event handlers found. returning null.";
return QSharedPointer<EventHandler>();
}

View File

@ -22,8 +22,8 @@
#include "framebufferplugin.h"
#include "krfbconfig.h"
#include "krfbdebug.h"
#include <QDebug>
#include <QGlobalStatic>
#include <KPluginFactory>
@ -78,18 +78,18 @@ void FrameBufferManager::loadPlugins()
KPluginFactory *factory = KPluginLoader(data.fileName()).factory();
if (!factory) {
qDebug() << "KPluginFactory could not load the plugin:" << data.fileName();
qCDebug(KRFB) << "KPluginFactory could not load the plugin:" << data.fileName();
continue;
} else {
qDebug() << "found plugin at " << data.fileName();
qCDebug(KRFB) << "found plugin at " << data.fileName();
}
FrameBufferPlugin *plugin = factory->create<FrameBufferPlugin>(this);
if (plugin) {
m_plugins.insert(data.pluginId(), plugin);
qDebug() << "Loaded plugin with name " << data.pluginId();
qCDebug(KRFB) << "Loaded plugin with name " << data.pluginId();
} else {
qDebug() << "unable to load pluign for " << data.fileName();
qCDebug(KRFB) << "unable to load pluign for " << data.fileName();
}
unique.insert (data.name());
}
@ -118,7 +118,7 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
while (iter != m_plugins.constEnd()) {
if (iter.key() == KrfbConfig::preferredFrameBufferPlugin()) {
qDebug() << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
qCDebug(KRFB) << "Using FrameBuffer:" << KrfbConfig::preferredFrameBufferPlugin();
QSharedPointer<FrameBuffer> frameBuffer(iter.value()->frameBuffer(id));
@ -133,6 +133,6 @@ QSharedPointer<FrameBuffer> FrameBufferManager::frameBuffer(WId id)
}
// No valid framebuffer plugin found.
qDebug() << "No valid framebuffer found. returning null.";
qCDebug(KRFB) << "No valid framebuffer found. returning null.";
return QSharedPointer<FrameBuffer>();
}

View File

@ -24,11 +24,11 @@
#include "krfbconfig.h"
#include "sockethelpers.h"
#include "connectiondialog.h"
#include "krfbdebug.h"
#include <KNotification>
#include <KLocalizedString>
#include <QDebug>
#include <QSocketNotifier>
#include <poll.h>
#include <KConfigGroup>
@ -115,7 +115,7 @@ void PendingInvitationsRfbClient::onSocketActivated()
//the clientGoneHook which in turn will remove this RfbClient instance
//from the server manager and will call deleteLater() to delete it
if (d->client->sock == -1) {
qDebug() << "disconnected from socket signal";
qCDebug(KRFB) << "disconnected from socket signal";
d->notifier->setEnabled(false);
rfbClientConnectionGone(d->client);
break;
@ -125,7 +125,7 @@ void PendingInvitationsRfbClient::onSocketActivated()
bool PendingInvitationsRfbClient::checkPassword(const QByteArray & encryptedPassword)
{
qDebug() << "about to start authentication";
qCDebug(KRFB) << "about to start authentication";
if(InvitationsRfbServer::instance->allowUnattendedAccess() && vncAuthCheckPassword(
InvitationsRfbServer::instance->unattendedPassword().toLocal8Bit(),

View File

@ -22,10 +22,10 @@
#include "invitationsrfbclient.h"
#include "krfbconfig.h"
#include "rfbservermanager.h"
#include "krfbdebug.h"
#include <QTimer>
#include <QApplication>
#include <QHostInfo>
#include <QDebug>
#include <QRandomGenerator>
#include <KLocalizedString>
@ -188,7 +188,7 @@ void InvitationsRfbServer::walletOpened(bool opened)
} else {
qDebug() << "Could not open KWallet, Falling back to config file";
qCDebug(KRFB) << "Could not open KWallet, Falling back to config file";
KConfigGroup krfbConfig(KSharedConfig::openConfig(),"Security");
desktopPassword = KStringHandler::obscure(krfbConfig.readEntry(

View File

@ -20,6 +20,7 @@
#include "invitationsrfbserver.h"
#include "krfbconfig.h"
#include "krfb_version.h"
#include "krfbdebug.h"
#include <KAboutData>
#include <KDBusService>
@ -27,7 +28,6 @@
#include <KMessageBox>
#include <KWindowSystem>
#include <QDebug>
#include <QPixmap>
#include <qwindowdefs.h>
#include <QX11Info>
@ -59,13 +59,13 @@ static bool checkX11Capabilities()
static void checkOldX11PluginConfig() {
if (KrfbConfig::preferredFrameBufferPlugin() == QStringLiteral("x11")) {
qDebug() << "Detected deprecated configuration: preferredFrameBufferPlugin = x11";
qCDebug(KRFB) << "Detected deprecated configuration: preferredFrameBufferPlugin = x11";
KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem(
QStringLiteral("preferredFrameBufferPlugin"));
if (config_item) {
config_item->setProperty(QStringLiteral("xcb"));
KrfbConfig::self()->save();
qDebug() << " Fixed preferredFrameBufferPlugin from x11 to xcb.";
qCDebug(KRFB) << " Fixed preferredFrameBufferPlugin from x11 to xcb.";
}
}
}
@ -81,7 +81,7 @@ static void checkWaylandPluginConfig()
if (config_item) {
config_item->setProperty(QStringLiteral("pw"));
KrfbConfig::self()->save();
qDebug() << "Wayland: Fixed preferredFrameBufferPlugin to \"pw\".";
qCDebug(KRFB) << "Wayland: Fixed preferredFrameBufferPlugin to \"pw\".";
}
}
}

View File

@ -23,7 +23,6 @@
#include "sockethelpers.h"
#include "eventsmanager.h"
#include <QSocketNotifier>
#include <QDebug>
#include <poll.h>
#include <strings.h> //for bzero()

View File

@ -19,11 +19,11 @@
*/
#include "rfbserver.h"
#include "rfbservermanager.h"
#include "krfbdebug.h"
#include <QSocketNotifier>
#include <QApplication>
#include <QClipboard>
#include <QPointer>
#include <QDebug>
#include <QX11Info>
struct RfbServer::Private
@ -92,7 +92,7 @@ bool RfbServer::start()
if (!d->screen) {
d->screen = RfbServerManager::instance()->newScreen();
if (!d->screen) {
qDebug() << "Unable to get rbfserver screen";
qCDebug(KRFB) << "Unable to get rbfserver screen";
return false;
}
@ -125,14 +125,14 @@ bool RfbServer::start()
d->screen->authPasswdData = (void *)nullptr;
}
qDebug() << "Starting server. Listen port:" << listeningPort()
qCDebug(KRFB) << "Starting server. Listen port:" << listeningPort()
<< "Listen Address:" << listeningAddress()
<< "Password enabled:" << passwordRequired();
rfbInitServer(d->screen);
if (!rfbIsActive(d->screen)) {
qDebug() << "Failed to start server";
qCDebug(KRFB) << "Failed to start server";
rfbShutdownServer(d->screen, false);
return false;
};

View File

@ -29,7 +29,6 @@
#include <QDesktopWidget>
#include <QGlobalStatic>
#include <QHostInfo>
#include <QDebug>
#include <KLocalizedString>
#include <KUser>