Akonadi

storagedebugger.h
1/*
2 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 */
7
8#pragma once
9
10#include <QFile>
11#include <QList>
12#include <QMap>
13#include <QMutex>
14#include <QObject>
15#include <QVariant>
16
17#include <atomic>
18#include <memory>
19
20class QSqlQuery;
21class QDBusArgument;
22
23struct DbConnection {
24 qint64 id;
25 QString name;
26 qint64 start;
27 QString trxName;
28 qint64 transactionStart;
29};
30
31QDBusArgument &operator<<(QDBusArgument &arg, const DbConnection &con);
32QDBusArgument &operator>>(QDBusArgument &arg, DbConnection &con);
33
34namespace Akonadi
35{
36namespace Server
37{
38class StorageDebugger : public QObject
39{
41
42public:
43 static StorageDebugger *instance();
44
45 ~StorageDebugger() override;
46
47 void addConnection(qint64 id, const QString &name);
48 void removeConnection(qint64 id);
49 void changeConnection(qint64 id, const QString &name);
50 void addTransaction(qint64 connectionId, const QString &name, uint duration, const QString &error);
51 void removeTransaction(qint64 connectionId, bool commit, uint duration, const QString &error);
52
53 void enableSQLDebugging(bool enable);
54 inline bool isSQLDebuggingEnabled() const
55 {
56 return mEnabled;
57 }
58
59 void queryExecuted(qint64 connectionId, const QSqlQuery &query, int duration);
60
61 inline void incSequence()
62 {
63 ++mSequence;
64 }
65
66 void writeToFile(const QString &file);
67
68 Q_SCRIPTABLE QList<DbConnection> connections() const;
69
71 void connectionOpened(qint64 id, qint64 timestamp, const QString &name);
72 void connectionChanged(qint64 id, const QString &name);
73 void connectionClosed(qint64 id, qint64 timestamp);
74
75 void transactionStarted(qint64 connectionId, const QString &name, qint64 timestamp, uint duration, const QString &error);
76 void transactionFinished(qint64 connectionId, bool commit, qint64 timestamp, uint duration, const QString &error);
77 void queryExecuted(double sequence,
78 qint64 connectionId,
79 qint64 timestamp,
80 uint duration,
81 const QString &query,
82 const QVariantList &values,
83 int resultsCount,
84 const QList<QList<QVariant>> &result,
85 const QString &error);
86
87private:
88 StorageDebugger();
89
90 static StorageDebugger *mSelf;
91 static QMutex mMutex;
92
93 std::unique_ptr<QFile> mFile;
94
95 std::atomic_bool mEnabled = {false};
96 std::atomic_int64_t mSequence = {0};
97 QList<DbConnection> mConnections;
98};
99
100} // namespace Server
101} // namespace Akonadi
Helper integration between Akonadi and Qt.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.